Bug 6422 - rsync needlessly aborts when getcwd() fails
Summary: rsync needlessly aborts when getcwd() fails
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.0.6
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
Depends on:
Reported: 2009-05-30 14:02 UTC by Mike Frysinger
Modified: 2018-02-08 20:01 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Mike Frysinger 2009-05-30 14:02:09 UTC
rsync will abort if getcwd() fails even though the current working directory is irrelevant to the request in question

for example, this should not fail:
cd ~/
mkdir -p src dst foo/a/b/c
touch src/a
cd foo/a/b/c
rm -rf ~/foo
rsync -a ~/src/ ~/dst/

that rsync command errors out with:
rsync: getcwd(): No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at util.c(992) [receiver=3.0.6]

and looking in ~/dst/, i see no files have been transferred
Comment 1 Wayne Davison 2009-09-05 10:46:56 UTC
There are all sorts of options and args that can depend on the current directory.  If we allow the determination of what the current directory is to fail, we'd need to set a flag that the failure happened and then add code to every case that made sure that if curr_dir was used to construct a path that it should error out at that point.  I don't think this is worth the complexity.

For scripts, you can add a "cd /" to make sure that your current directory is always valid.
Comment 2 Mike Frysinger 2009-09-05 16:31:59 UTC
i'd agree if i was attempting to do an actual operation on the current directory (like `rsync -a ./ foo:/`), but when the current directory is wholly irrelevant, it shouldnt fail imo

i wasnt running scripts, i was running rsync by hand in a terminal
Comment 3 Florian Weimer 2018-02-06 13:21:06 UTC
I posted a patch: https://lists.samba.org/archive/rsync/2018-February/031476.html