rsync icon indicating copy to clipboard operation
rsync copied to clipboard

Destination --chmod and --fake-super: chmod applied to fake-super, backup permissions lost

Open minfrin opened this issue 8 months ago • 2 comments

When attempting a backup of a source system running as root, and a destination system running as a normal user, --fake-super is used to keep track of source permissions, and --chmod is used to ensure that the backup is accessible to backup users on the target system.

In the process however, the addition of --chmod causes permissions to change both on the target filesystem, and within the attributes stored by fake super.

Once such a backup is restored, it is discovered that all source permissions are lost, replaced with the permissions specified by chmod.

With existing behaviour unchanged, a new option --chmod-dest is proposed that will affect the permissions of files and/or directories on the target system.

Patch to follow.

This question on superuser is relevant: https://superuser.com/questions/1406902/can-i-use-override-permissions-in-rsync-and-store-original-in-xattrs

minfrin avatar Apr 15 '25 12:04 minfrin

The rsync daemon supports destination chmod (calling it incoming chmod), and the place where it is applied is here:

https://github.com/RsyncProject/rsync/blob/9994933c8ccf7ead27c81fe4ce2eb4e08af20c7f/rsync.c#L518

This does exclude symlinks.

minfrin avatar Apr 16 '25 09:04 minfrin

Patch available here: https://github.com/RsyncProject/rsync/pull/751

minfrin avatar Apr 16 '25 14:04 minfrin