Bug 2913 - rsync of symlinks on >=bsd needs lutimes(2) and lchmod(2)
Summary: rsync of symlinks on >=bsd needs lutimes(2) and lchmod(2)
Status: CLOSED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 2.6.5
Hardware: All FreeBSD
: P3 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-24 01:16 UTC by rsync user
Modified: 2006-03-12 02:56 UTC (History)
0 users

See Also:


Attachments
Use lchmod and lutimes, if present (4.88 KB, patch)
2005-07-26 09:27 UTC, Wayne Davison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description rsync user 2005-07-24 01:16:23 UTC
on at least freebsd, symlinks have settable
 times/perms as well as u/g/flags.

true, use of a symlink is time/perm/u/g/flag agnostic
 however, unsynchronized time/perm do cause problems
 elsewhere on systems that have the above syscalls. ie:
  1 - find <path> -newer <stampfile> -ls
   print if any/all types, rather than a single, are newer
  2 - find <path> -perm +7022 -ls
   print if any/all types, rather than a single, are not isolated

rsync created slinks earn the time of the symlink(2) call
 by rsync. further, an lutimes(2) run elsewhere against the
 slink is not picked up by later rsync runs. both break ex1.
similarly, rsync ignores both umask and src perms when
 creatings slinks. neither are updated in later runs. breaking ex2.

rm -r ./dstdir
srcdir:
lrwxrwx---  1 u  g  1 Jul 24 03:29:58 2005 a -> b
-rw-r-----  1 u  g  0 Jul 24 03:29:58 2005 b
prw-rw----  1 u  g  0 Jul 24 03:29:58 2005 fifo
srwxrwx---  1 u  g  0 Jul 24 03:29:58 2005 sockfile

umask 0022
[root] rsync -axv --delete ./srcdir/ ./dstdir/
dstdir:
lrwxrwxrwx  1 u  g    1 Jul 24 03:30:36 2005 a -> b
-rw-r-----  1 u  g    0 Jul 24 03:29:58 2005 b
prw-rw----  1 u  g    0 Jul 24 03:29:58 2005 fifo
srwxrwx---  1 u  g    0 Jul 24 03:29:58 2005 sockfile

last time i looked this required passing the
source stat structure through to the affected
rsync functions and extending the fn to use it
with the above syscalls, perhaps ifdef'd if not
present.

reply only to bugzilla/rsync list, thx.
Comment 1 Wayne Davison 2005-07-26 09:27:23 UTC
Created attachment 1336 [details]
Use lchmod and lutimes, if present

Please test this patch and see if it works for you.  You will need to run
"autoconf; autoheader; make proto" (or "make gen" if you already have a
Makefile) and then re-run configure (e.g. "./config.status --recheck;
./config.status" if you already ran configure in that dir) before running
"make".
Comment 2 hoffa 2005-07-31 03:38:44 UTC
the patch applies clean to: cvs co -D '2005-07-07 22:53:59-0000'
which refers to the latest src rev in the patch [not knowing which
tag or date to apply to]. ./configures ok, but make tanks with... 

gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt  -c rsync.c -o rsync.o
rsync.c: In function `set_perms':
rsync.c:75: too many arguments to function `set_modtime'
*** Error code 1
Stop in /tmp/rsync.


so skipping ahead and using this instead...
 cvs co -D '2005-07-31 00:00:00-0000'
...slinks work great. the following changes to the source slinks
are now transferred to the destination correctly...
 create/delete/user/group/perm/mtime
ran against a couple million mixed inodes. all but a
device and/or hardlink issue check out so far. checking...

HUGE THANKS TO THE RSYNC DEVEL[S] FOR THIS SLINK WORK!!!
Comment 3 Wayne Davison 2005-07-31 15:43:10 UTC
I checked this fix in to CVS a few days ago, so this appears to be fixed now. 
Thanks for your help testing this.