rsync icon indicating copy to clipboard operation
rsync copied to clipboard

Rsync does not map UID for POSIX ACL entries where USER = FILE OWNER

Open iizhikov opened this issue 2 years ago • 3 comments

Rsync does not map UID for POSIX ACL entries where USER = FILE OWNER.

Steps to reproduce: Create two test users. Users must have different UIDs on the localhost and remotehost.

> ssh testuser1@remotehost touch testfile1
> ssh testuser1@remotehost setfacl -m u:testuser1:rwx,u:testuser2:rwx testfile1
> ssh testuser1@remotehost getfacl testfile1
# file: testfile1
# owner: testuser1
# group: testuser1
user::rw-
user:testuser1:rwx
user:testuser2:rwx
group::r--
mask::rwx
other::r--

> ssh testuser2@remotehost touch testfile2
> ssh testuser2@remotehost setfacl -m u:testuser1:rwx,u:testuser2:rwx testfile2
> ssh testuser2@remotehost getfacl testfile2
# file: testfile2
# owner: testuser2
# group: testuser2
user::rw-
user:testuser1:rwx
user:testuser2:rwx
group::r--
mask::rwx
other::r--

> rsync -Aav testuser1@remotehost:testfile1 .
receiving incremental file list
testfile1

sent 43 bytes  received 121 bytes  109.33 bytes/sec
total size is 0  speedup is 0.00

> rsync -Aav testuser2@remotehost:testfile2 .
receiving incremental file list
testfile2

sent 43 bytes  received 123 bytes  36.89 bytes/sec
total size is 0  speedup is 0.00

> getfacl testfile1 testfile2
# file: testfile1
# owner: testuser1
# group: testuser1
user::rw-
user:104:rwx
user:testuser2:rwx
group::r--
mask::rwx
other::r--

# file: testfile2
# owner: testuser1
# group: testuser1
user::rw-
user:testuser1:rwx
user:1104:rwx
group::r--
mask::rwx
other::r--

iizhikov avatar May 30 '24 11:05 iizhikov

It seems like the problem is in recv_ida_entries() function in acls.c.

                if (has_name) {
                        if (access & NAME_IS_USER)
                                id = recv_user_name(f, id);
                        else
                                id = recv_group_name(f, id, NULL);
                } else if (access & NAME_IS_USER) {
                        if (inc_recurse && am_root && !numeric_ids)   <--- THIS LINE
                                id = match_uid(id);
                } else {
                        if (inc_recurse && (!am_root || !numeric_ids))
                                id = match_gid(id, NULL);
                }

UIDs are not mapped if rsync works on behalf of a non-privileged user. Not sure what’s the idea behind this logic. For me it looks like a bug.

iizhikov avatar May 30 '24 11:05 iizhikov

sorry for the slow response, fixed in PR #844 - your proposed change was right of course

tridge avatar Jan 19 '26 00:01 tridge

https://github.com/RsyncProject/rsync/issues/618