Articles April 24, 2007 at 8:59 am

The State of rsync on Tiger

10.4.9 brings some welcome improvements to rsync on OS X, but they might not be everything that you're looking for.

An exhaustive look at what is and what doesn't seem to be working with rsync through various iterations of OS X 10.4. Read on for the gory details…

(Ed. Note: It would appear that both versions of the 2007-004 Security Update re-breaks much of the rsync progress. This is corrected by the 2007-005 SecUpd, so be sure to test those patches!)


<code>   &lt;p&gt;Mac OS X 10.4.9 comes with a new version of rsync, the third one to be officially released by Apple since 10.4.&lt;br /&gt;    The release gives us a good opportunity to check whether the previous trend towards reliability and useability has been maintained, as it would be bad to continuously have an incomplete/unreliable out-of-the-box way to preserve our servers&amp;#39; precious data... [1]&lt;br /&gt; &lt;br /&gt;  To make rsync HFS+ aware, Apple introduced as few changes to rsync&amp;#39;s code as possible.&lt;br /&gt;    Basically, they are centered around the building (by the sender) and the interpretation (by the receiver) of the list of files to be transferred, and on the ability to pack all &amp;quot;non conventional&amp;quot; attributes of a file in an additional regular file that may be transferred over the wire, then unpacked on the other side.&lt;br /&gt;  &lt;br /&gt;  This way, rsync&amp;#39;s protocol is preserved: invoking it without its -E flag allows it to work with any regular rsync server, provided the protocol versions are compatible of course.&lt;br /&gt;    Moreover, when invoked with the -E flag, it should prove consistent with what would have been achieved without the flag, just with the addition of all the other OS X bits being carried across.&lt;br /&gt;  &lt;br /&gt;  The aforementioned packing/unpacking capability is provided by a library function, copyfile(), which also allows for rsync to find out about the various pieces related to a given file.&lt;br /&gt;  That function in fact is the building block for the HFS+ awareness of other unix file tools too. Having a well-behaved rsync should thus also increase the odds that the other tools will behave correctly as well.&lt;br /&gt;   &lt;br /&gt;  Some small illustrative pieces of code are provided hereafter; they are supposed to be run under following environment:&lt;br /&gt;   1. Volume &amp;quot;Data&amp;quot;, which is not the boot volume, is a Journaled HFS+ formatted volume.&lt;br /&gt;   2. Unless otherwise stated, ACLs are not enabled on the boot volume nor on volume &amp;quot;Data&amp;quot;; when needed, they are explicitely enabled in the sample pieces of code.&lt;br /&gt;   3. A copy of SimpleText, the pre-OSX application with an empty data fork and everything in the resource fork, is available at the top level of volume &amp;quot;Data&amp;quot;.&lt;br /&gt;   4. A copy of command line tool &amp;quot;xarg&amp;quot; is available at the top level of volume &amp;quot;Data&amp;quot;, and the Developer tools are installed.&lt;br /&gt;  5. The working directory is /Volumes/Data.&lt;/p&gt;  &lt;p&gt;&lt;br /&gt;   &lt;strong&gt;10.4 and rsync&lt;/strong&gt;&lt;br /&gt;   &lt;br /&gt;  The Darwin projects for 10.4.0:&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;Libc-391&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync-20 (based on rsync 2.6.3)&lt;br /&gt;    &lt;br /&gt;  Apple&amp;#39;s changes to rsync&amp;#39;s original code are conveniently summarized in two .diff files, EA.diff being the one related to the handling of extended attributes.&lt;br /&gt;    &lt;br /&gt;  The truth is that rsync was almost unuseable with the -E flag: when applied to a sufficently large set of files, the likelihood of a crash was nearing 100%.&lt;br /&gt;  &lt;br /&gt;  Moreover, even with smaller transfers, the results proved rather erratic, and it was often needed to run rsync twice or thrice on the same data, so as to have all files (or all of their parts) transfered.&lt;br /&gt;  &lt;br /&gt;  As a result, rsync could only be reasonably considered without its -E flag, and thus be used for providing the same functionality as in pre-Tiger times.&lt;/p&gt;    &lt;p&gt;&lt;br /&gt;   &lt;strong&gt;10.4.6 and rsync&lt;/strong&gt;&lt;br /&gt; &lt;br /&gt;  The projects have evolved to:&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;Libc-391.2.5&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync-24 (based on rsync 2.6.3)&lt;br /&gt;    for the PPC version, and to&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;Libc-391.4.2&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync-24 (based on rsync 2.6.3)&lt;br /&gt;    for the Intel version.&lt;br /&gt;    &lt;br /&gt;  Note that the code for copyfile() seems to be virtually the same for both architectures, as the differences are confined to the handling of byte-ordering and data alignment; this seems to be the case in subsequent versions as well.&lt;br /&gt;   &lt;br /&gt;  With rsync-24, Apple addressed the main problems encountered under 10.4: rsync wouldn&amp;#39;t crash anymore while trying to insert an entry for a &amp;quot;synthetic file&amp;quot; in the file list; the same way, a spurious file unlinking, which could lead to some of the aforementioned mysterious failures, has been removed.&lt;br /&gt;   &lt;br /&gt;  In other words, with 10.4.6, rsync had begun to be a candidate for large file transfers.&lt;br /&gt;  &lt;br /&gt;  Some surprising, not to say inconsistent however, behaviors from the previous version were still maintained.&lt;br /&gt;  &lt;br /&gt;  For example:&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;mkdir B&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE SimpleText B/&lt;br /&gt;    systematically yielded a copy whose modification date was set to the time of the transfer; on the other hand, the creation date was preserved.&lt;br /&gt;    &lt;br /&gt;  By contrast, in such a case:&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;mkdir A B&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;touch A/empty&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;osascript -e &amp;#39;tell app &amp;quot;Finder&amp;quot; to set label index of file &amp;quot;Data:A:empty&amp;quot; to 2&amp;#39;&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE A/empty B/&lt;br /&gt;   the copy had both its creation and modification dates set to the modification date of the original file... [2]&lt;br /&gt;    &lt;br /&gt;  But the biggest problems became apparent as soon as one enabled ACLs on the source volume; for example, with the following:&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;mkdir A B&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;sudo fsaclctl -p . -e&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE SimpleText B/&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;touch A/empty&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;chmod +a &amp;quot;www allow write&amp;quot; A/empty&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE A/empty B/&lt;br /&gt;   you would just get those infamous error messages related to &amp;quot;vanished&amp;quot; files, while neither the resource fork nor the ACL were transferred.&lt;br /&gt; &lt;br /&gt;  It was possible to have rsync working again by enabling ACLs on the boot volume. This was clearly erroneous, as the creation of the synthetic files in &amp;quot;/tmp&amp;quot; obviously doesn&amp;#39;t require any ACL capability at all: they are just regular files.&lt;br /&gt; &lt;br /&gt;  Now, rsync&amp;#39;s code shows that the --temp-dir (-T) option has been reaped by Apple for defining the temporary directory to be used on the sender&amp;#39;s side (it still governs the receiver&amp;#39;s temporary location, as in rsync&amp;#39;s original code).&lt;br /&gt;  So, instead of enabling ACLs on the boot volume, one had a partial workaround, as this worked for file &amp;quot;empty&amp;quot;:&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;mkdir A B&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;sudo fsaclctl -p . -e&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;touch A/empty&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;chmod +a &amp;quot;www allow write&amp;quot; A/empty&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE --temp-dir=/Volumes/Data/C A/empty B/&lt;br /&gt;    but still not for SimpleText...&lt;br /&gt;   &lt;br /&gt;  In fact, for having a file with a resource fork to be rsynced from an ACL-enabled volume, one had to somehow &amp;quot;trigger&amp;quot; that capability, for example by creating an ACL for it, even an empty one.&lt;br /&gt;   But this anyway required either to run FixupResourceForks afterwards, or to run rsync as root, as the POSIX permissions weren&amp;#39;t correctly transferred.&lt;br /&gt;    &lt;br /&gt;  But that was not the whole story:&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;mkdir A B C&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;sudo fsaclctl -p / -e&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;sudo fsaclctl -p . -e&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;touch A/empty&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;chmod +a &amp;quot;www allow write&amp;quot; A/empty&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE A/empty B/&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE B/empty C/&lt;br /&gt;   The second rsync command just crashed.&lt;br /&gt;    &lt;br /&gt;  As a general rule, it appeared that files that had been rsynced once from an ACL-enabled volume were not rsyncable anymore (the mess introduced in those files being a very persisting one).&lt;br /&gt;  Rather annoying, isn&amp;#39;t it?&lt;br /&gt;    &lt;br /&gt;  So, running rsync with its -E flag on &amp;quot;regular&amp;quot; volumes started to be feasible, and even rather reliable.&lt;br /&gt;   But running it on ACL-enabled volumes was still kind of suicidal...&lt;/p&gt; &lt;p&gt;&lt;br /&gt;   &lt;strong&gt;10.4.9 and rsync&lt;/strong&gt;&lt;br /&gt; &lt;br /&gt;  For the PPC architecture, the project versions are now:&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;Libc-391.2.9&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync-24.1 (based on rsync 2.6.3)&lt;br /&gt;  while, on Intel, they are:&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;Libc-391.5.21&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync-24.1 (based on rsync 2.6.3)&lt;br /&gt;  &lt;br /&gt;  As far as copyfile() is concerned, return values of some calls are now correctly handled: they do not cancel each other out anymore and thus, for example, make a success appear as an error. Moreover, previously overlooked cases or error conditions are now taken into account.&lt;br /&gt;   Rsync&amp;#39;s code shows very few changes, mostly related to some data initialization/release, as well as to the correct handling of the -E flag during the cleanup of synthetic files.&lt;br /&gt; &lt;br /&gt;  Consistency has been reintroduced with regards to he handling of creation dates; now,&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;mkdir A B&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;cp -p SimpleText A/&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;touch A/SimpleText&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;sleep 10&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE A/SimpleText B/&lt;br /&gt;  yields a copy whose creation and modification dates are both set to the modification date of the source file.&lt;br /&gt; OK, perhaps not the most wanted move, but it&amp;#39;s at least consistent with every other transfer done through rsync.&lt;br /&gt;  &lt;br /&gt;  But the most striking improvements that came with 10.4.9 are related to ACL-enabled volumes.&lt;br /&gt;  &lt;br /&gt;  It isn&amp;#39;t required to have ACLs enabled on the sender&amp;#39;s boot volume anymore (nor to resort to the --temp-dir trick).&lt;br /&gt;   This is a very nice improvement, as the requirement was logically flawed, and very likely revealed underlying problems anyway.&lt;br /&gt;    &lt;br /&gt;  Moreover, provided rsync runs with sufficient privileges, a file located on an ACL-enabled volume and with only a non empty resource fork as an &amp;quot;extended attribute&amp;quot; may now be rsynced with the -E option.&lt;br /&gt; &lt;br /&gt;  Last but not least, an rsynced file may be rsynced again.&lt;br /&gt; &lt;br /&gt;  As a result, rsync may now realistically be applied on ACL-enabled volumes, as shown by this sample code:&lt;br /&gt; &lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;# Let&amp;#39;s create various test cases.&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;sudo fsaclctl -p . -e&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;mkdir A B C&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;echo &amp;quot;1234567890&amp;quot; &amp;gt;A/rawfile&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;echo &amp;quot;1234567890&amp;quot; &amp;gt;A/rawfile-ACL&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;chmod +a &amp;quot;www allow write&amp;quot; A/rawfile-ACL&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;echo &amp;quot;1234567890&amp;quot; &amp;gt;A/rawfile-ACL-ATTR&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;chmod +a &amp;quot;www allow write&amp;quot; A/rawfile-ACL-ATTR&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;./xattr --set &amp;#39;color&amp;#39; &amp;#39;blue&amp;#39; A/rawfile-ACL-ATTR&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;echo &amp;quot;1234567890&amp;quot; &amp;gt;A/rawfile-ATTR&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;./xattr --set &amp;#39;color&amp;#39; &amp;#39;blue&amp;#39; A/rawfile-ATTR&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;echo &amp;quot;1234567890&amp;quot; &amp;gt;A/rawfile-ATTR-XFI&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;./xattr --set &amp;#39;color&amp;#39; &amp;#39;blue&amp;#39; A/rawfile-ATTR-XFI&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;osascript -e &amp;#39;tell app &amp;quot;Finder&amp;quot; to set label index of file &amp;quot;Data:A:rawfile-ATTR-XFI&amp;quot; to 2&amp;#39;&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;echo &amp;quot;1234567890&amp;quot; &amp;gt;A/rawfile-ACL-ATTR-XFI&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;chmod +a &amp;quot;www allow write&amp;quot; A/rawfile-ACL-ATTR-XFI&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;./xattr --set &amp;#39;color&amp;#39; &amp;#39;blue&amp;#39; A/rawfile-ACL-ATTR-XFI&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;osascript -e &amp;#39;tell app &amp;quot;Finder&amp;quot; to set label index of file &amp;quot;Data:A:rawfile-ACL-ATTR-XFI&amp;quot; to 2&amp;#39;&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;echo &amp;quot;1234567890&amp;quot; &amp;gt;A/rawfile-ACL-ATTR-XFI-FI&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;chmod +a &amp;quot;www allow write&amp;quot; A/rawfile-ACL-ATTR-XFI-FI&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;./xattr --set &amp;#39;color&amp;#39; &amp;#39;blue&amp;#39; A/rawfile-ACL-ATTR-XFI-FI&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;osascript -e &amp;#39;tell app &amp;quot;Finder&amp;quot; to set label index of file &amp;quot;Data:A:rawfile-ACL-ATTR-XFI-FI&amp;quot; to 2&amp;#39;&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;/Developer/Tools/SetFile -a V A/rawfile-ACL-ATTR-XFI-FI&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;cp -p SimpleText A/&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;cp -p SimpleText A/SimpleText-ACL&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;chmod +a &amp;quot;www allow write&amp;quot; A/SimpleText-ACL&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;cp -p SimpleText A/SimpleText-ACL-ATTR&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;chmod +a &amp;quot;www allow write&amp;quot; A/SimpleText-ACL-ATTR&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;./xattr --set &amp;#39;color&amp;#39; &amp;#39;blue&amp;#39; A/SimpleText-ACL-ATTR&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;cp -p SimpleText A/SimpleText-ATTR&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;./xattr --set &amp;#39;color&amp;#39; &amp;#39;blue&amp;#39; A/SimpleText-ATTR&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;# Let&amp;#39;s enjoy the relief to be able to rsync rsynced files.&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE A/ B/&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE B/ C/&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;# Let&amp;#39;s fetch some info about the original files...&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;ls -ales A&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;./xattr --get color A/*&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;for f in A/*; do /Developer/Tools/GetFileInfo &amp;quot;&amp;#36;f&amp;quot;; done&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;# ... as well as about their final copies.&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;ls -ales C&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;./xattr --get color C/*&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;for f in C/*; do /Developer/Tools/GetFileInfo &amp;quot;&amp;#36;f&amp;quot;; done&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;# Looking at them in the Finder will tell about their visibility and labels.&lt;br /&gt;   &lt;br /&gt;  It appears that, with the above code, both sets of file info are identical (tested on a PPC box and an Intel one).&lt;br /&gt;    Of course, a similar conclusion holds when volume &amp;quot;Data&amp;quot; is not ACL-enabled (just remove the parts of the sample code devoted to the creation of ACLs).&lt;br /&gt; &lt;br /&gt;  So, looks like 10.4.9 came with a much more capable rsync than ever.&lt;br /&gt;  Locally:&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;- it sustains large file lists,&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;- it may reliably be used with its -E flag on &amp;quot;regular&amp;quot; volumes&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;- as well as on ACL-enabled volumes&lt;br /&gt;    &lt;br /&gt;  So far, so good.&lt;br /&gt;  But then, what about current rsync&amp;#39;s capabilities as a server?&lt;br /&gt;    &lt;br /&gt;  Let&amp;#39;s configure on each of our test boxes (PPC and Intel) an rsync server:&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;- with a daemon running as root&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;- with a module named &amp;quot;test&amp;quot;&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;- that module being accessible by an rsync user named &amp;quot;test&amp;quot; too&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;- the module&amp;#39;s directory being /Volumes/Data/rsync_test&lt;br /&gt;    &lt;br /&gt;  Assuming folder &amp;quot;A&amp;quot; still contains the 11 files created with above code, running this command on the Intel box:&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE A/ [email protected]::test/&lt;br /&gt; fills the module&amp;#39;s directory with the expected files (ie the same ones as those created by the local rsync into folder &amp;quot;C&amp;quot;).&lt;br /&gt;    &lt;br /&gt;  But trying the same to the remote server:&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;rsync -aE A/ [email protected]::test/&lt;br /&gt;  tends to show that some old demons are still alive...&lt;br /&gt; Indeed, on the remote server, an:&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;ls -Ales rsync_folder&lt;br /&gt;  shows this:&lt;br /&gt;   &amp;nbsp;&amp;nbsp;&amp;nbsp; 240 -r--------&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp; 121847 Jun&amp;nbsp; 3&amp;nbsp; 1999 ._SimpleText-ACL-ATTR&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -r--------&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 245 Apr 23 19:26 ._rawfile-ACL-ATTR&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -r--------&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 245 Apr 23 19:26 ._rawfile-ACL-ATTR-XFI&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -r--------&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 245 Apr 23 19:26 ._rawfile-ACL-ATTR-XFI-FI&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;240 -rw-rwxr--&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Jun&amp;nbsp; 3&amp;nbsp; 1999 SimpleText&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;240 -rw-rwxr-- + 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Jun&amp;nbsp; 3&amp;nbsp; 1999 SimpleText-ACL&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp; 0: user:www allow write&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0 -rw-rwxr--&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Jun&amp;nbsp; 3&amp;nbsp; 1999 SimpleText-ACL-ATTR&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;240 -rw-rwxr--&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Jun&amp;nbsp; 3&amp;nbsp; 1999 SimpleText-ATTR&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -rw-r--r--&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11 Apr 23 19:26 rawfile&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -rw-r--r-- + 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11 Apr 23 19:26 rawfile-ACL&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp; 0: user:www allow write&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -rw-r--r--&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11 Apr 23 19:26 rawfile-ACL-ATTR&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -rw-r--r--&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11 Apr 23 19:26 rawfile-ACL-ATTR-XFI&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -rw-r--r--&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11 Apr 23 19:26 rawfile-ACL-ATTR-XFI-FI&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -rw-r--r--&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11 Apr 23 19:26 rawfile-ATTR&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 8 -rw-r--r--&amp;nbsp;&amp;nbsp; 1 luttgens&amp;nbsp; admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11 Apr 23 19:26 rawfile-ATTR-XFI&lt;br /&gt;  That is, with the sample files under consideration, for each file having both an ACL and an attribute, the remote receiver &amp;quot;forgot&amp;quot; to merge the synthetic file back with the data file.&lt;br /&gt;    And this time, as could have been expected, running FixupResourceForks is only a partial workaround: if it allows to restore resource forks and Finder info, both the ACLs and the attributes are lost on the &amp;quot;repaired&amp;quot; files.&lt;br /&gt; &lt;br /&gt;  Fortunately (?), exactly the same behavior may be observed on the PPC box too; the problem thus doesn&amp;#39;t seem to be architecture-dependent. [3]&lt;br /&gt;    Moreover, I couldn&amp;#39;t find any other combination triggering such a behavior.&lt;br /&gt;   And, let&amp;#39;s be abysmally optimistic, that behavior is a rather benign one, in the sense that it doesn&amp;#39;t abruptly crash the process as would probably have been the case with earlier versions.&lt;/p&gt;   &lt;p&gt;&lt;br /&gt;   &lt;strong&gt;So, what do we preserve (loose) with rsync -E?&lt;/strong&gt;&lt;br /&gt;   &lt;br /&gt;  Current rsync&amp;#39;s incarnation has a lot going for it, as:&lt;br /&gt;   &lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;- it doesn&amp;#39;t fear large file transfers anymore [4]&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;- it now reliably works with ACL-enabled volumes&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;- beside a very special case, it behaves well as a server too.&lt;br /&gt; &lt;br /&gt;  This of course raises the question: what&amp;#39;s the price, dude?&lt;br /&gt;   &lt;br /&gt;  I sure don&amp;#39;t have a full answer, but here are some thoughts (any addition and, of course, amendments, are welcome!).&lt;br /&gt;  &lt;br /&gt;  File types for which it make sense to keep a copy seem to be correctly handled by rsync:&lt;br /&gt;  &lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;regular files&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;directories&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;aliases&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;symbolic links&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;hard links&lt;br /&gt; &lt;br /&gt;  As far as I can tell, following information seems to be consistently preserved under any circumstances:&lt;br /&gt;   &lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;data fork&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;resource fork&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;owner/group&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;permissions (ie rwx, suid, sgid, sticky)&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;POSIX dates&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;basic Finder information&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;label&lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;custom icon&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;ACLs - but see below&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;attributes - but see below&lt;br /&gt; &lt;br /&gt;  And now the less pleasant news:&lt;br /&gt;   &lt;br /&gt;  &amp;nbsp;&amp;nbsp; &amp;nbsp;creation date: always set to the source file&amp;#39;s modification date&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;Spotlight comments (formerly known as Finder comments): always lost&lt;br /&gt;    &amp;nbsp;&amp;nbsp; &amp;nbsp;icon position: always lost&lt;br /&gt; &amp;nbsp;&amp;nbsp; &amp;nbsp;locked flag: always lost [5]&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;ACLs: irrecoverable after remote transfers when combined with attributes&lt;br /&gt;   &amp;nbsp;&amp;nbsp; &amp;nbsp;attributes: irrecoverable after remote transfers when combined with ACLs&lt;br /&gt;   &lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;  [1] Of course, there are many other ways to preserve that data (tar, asr,...); but amongst available tools, its versatility makes of rsync a rather atypical and potentially extremely useful one.&lt;br /&gt;    [2] Such discrepancies at least tell us one thing: as far as their handling is concerned, a resource fork is not Finder info, nor is it a POSIX filemode...; until the code of copyfile() is stabilized, it is probably safer to check with each new version for possible regressions.&lt;br /&gt;    [3] It is fortunate in the sense that the bug should be rather easy to locate, very likely in rsync&amp;#39;s receiver code, not in an deeply buried architecture-dependent system library.&lt;br /&gt;   [4] To be sure, I just tested this again on about 1,300,000 files, for a full copy as well as a differential one, in both cases locally and remotely.&lt;br /&gt; [5] Which also is the uchg flag from a POSIX point of view; note that when transferred, locked files leave synthetic files in the sender&amp;#39;s temporary directory. A persisting old bug.&lt;/p&gt;

No Comments

  • This one goes around the ACL-ATTR combination during a remote transfer, which still lets me rather amazed.

    It could well be that the problem is architecture-related, after all.
    If yes, the conclusions should read:
    – ACLs: irrecoverable after remote transfers between PPC-Intel when combined with attributes
    – attributes: irrecoverable after remote transfers between PPC-Intel when combined with ACLs
    which also means that remote transfers between similar archictectures should be OK.

    It looks like the problem isn’t related to rsync’s receiver code, but well to copyfile() – or even something deeper, in which case my third footnote really really starts to be outdated…

    In fact, that combination ACL-ATTR seems to end with "synthetic files" which are not architecture-agnostic anymore.

    In a word, when created on a PPC (Intel) box, they should be understood on a PPC (Intel) box, but raise an error on an Intel (PPC) box.

    Because of stupid medical reasons, I’m currently stuck here with two boxes: an Intel one, and a PPC one. I thus can’t perform remote PPC-PPC or Intel-Intel remote transfers; as I couldn’t only try PPC <-> Intel, I would be pleased to hear about about PPC <-> PPC and Intel <-> Intel remote trials.

    Moreover, compiling something like this:

    #include <sys/param.h>
    #include <sys/stat.h>

    #include <err.h>
    #include <errno.h>
    #include <fts.h>
    #include <limits.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <sys/param.h>

    #include <libc.h>

    #include <stdio.h>
    #include <libgen.h>
    #include <copyfile.h>

    /* Frankly didn’t bother about optimizing the includes 😉 */

    int main (int argc, const char * argv[]) {

    char * src_path;
    struct stat src_info;
    char dst_path[MAXPATHLEN];

    setenv("COPYFILE_DEBUG", "5", 1);

    /* Some really poor args checking… */

    if (argc != 2)
    err(65, "Needs one argument.");

    src_path = argv[1];
    if (stat(src_path, &src_info) != 0)
    err(65, "Bad path: %s", src_path);

    snprintf(dst_path, MAXPATHLEN, "%s-pck", src_path);

    if (copyfile(src_path, dst_path, NULL, COPYFILE_PACK | COPYFILE_METADATA | COPYFILE_VERBOSE | (1<<31)) != 0)
    err(70, "Seems to have failed while creating ", dst_path);

    return 0;

    should provide a command-line tool much more verbose than copyfile() as called by rsync, and also completely independant of rsync.
    Such a tool should allow to see how "somefile" becomes "somefile-pck", which may then analyzed through hexdump or a similar tool.

    Any feedback?

  • OK, the bug is in copyfile() on Intel, more exactly in a helper function swap_attrhdr().
    The latter treats attribute entries (the ones of type attr_entry_t) as if they were of fixed size; as a result, as soon as there are more then one such entries, the helper function will swap the wrong pieces of data.
    A synthetic file with more than one attribute entry created on an Intel won’t comply to the AppleDouble format anymore; but, as swap_attrhdr() is also used when reading a synthetic file, an Intel box will just undo the mess it has introduced in the file.
    Because of that bug, a synthetic file with more than one attribute entry and created on an Intel can’t be exploited on a PPC, and vice-versa.

  • Thanks for the article 🙂
    Further valuable input can be found re: discussion of the same, on Apple’s OS X Server mailing-list

    A few typos and/or awkward translations still in the article. “Loose” is not “lose,” a common error.

  • Looks like Security Update 2007-005 corrects the problems that came with 2007-004 v1.0 and v1.1.

    • Thanks a lot for your kind comment.
      But I still have overlooked a big problem when Apple’s rsync binary is applied against items bearing ACLs (see my latest comment).
      May I be forgiven by just saying that nobody is perfect? 🙁
      And that the main conclusions are still valid?


  • It is only rather recently that I performed really heavy testings with Apple’s rsync against files/folders with ACLs.

    Please agree my apologies for having missed those rather huge memory leaks occuring in such a case: not only are those leaks really noticeable during the building of the file list, but they also lead to increasing memory consumption during the file transfer.
    As a result, even if the file list gets successfully built, problems are anyway likely to happen during the transfer of numerous items bearing ACLs (lots of error messages related to malloc, with rather random tranfers of metadata in a broad sense).

    An update of the article should appear on the site.
    In the meantime, should you mainly have items with ACLs to rsync, a good rule of thumb would be to split your operations into chunks of about 100-200.000 items.
    Apple has acknowleged the problem, mainly located in copyfile’s code, so that one may expect an update.
    But for those interested in an immediate solution, a home brewed patched binary is at disposal (just ask me); it doesn’t touch the overall logics built into Apple’s binary, it just tries to minimize the memory leaks.


Leave a reply

You must be logged in to post a comment.