diff --git a/borg/platform_linux.pyx b/borg/platform_linux.pyx index 6144c76ff..19041a71c 100644 --- a/borg/platform_linux.pyx +++ b/borg/platform_linux.pyx @@ -35,10 +35,10 @@ def acl_use_local_uid_gid(acl): if entry: fields = entry.split(':') if fields[0] == 'user' and fields[1]: - fields[1] = user2uid(fields[1], fields[3]) + fields[1] = str(user2uid(fields[1], int(fields[3]))) elif fields[0] == 'group' and fields[1]: - fields[1] = group2gid(fields[1], fields[3]) - entries.append(':'.join(entry.split(':')[:3])) + fields[1] = str(group2gid(fields[1], int(fields[3]))) + entries.append(':'.join(fields[:3])) return ('\n'.join(entries)).encode('ascii') diff --git a/borg/testsuite/platform.py b/borg/testsuite/platform.py index 1dd6b31dc..df1e53542 100644 --- a/borg/testsuite/platform.py +++ b/borg/testsuite/platform.py @@ -97,6 +97,13 @@ def test_non_ascii_acl(self): self.assert_in(user_entry_numeric, acl_access) self.assert_in(group_entry_numeric, acl_access) + def test_utils(self): + from ..platform_linux import acl_use_local_uid_gid + self.assert_equal(acl_use_local_uid_gid(b'user:nonexistent1234:rw-:1234'), b'user:1234:rw-') + self.assert_equal(acl_use_local_uid_gid(b'group:nonexistent1234:rw-:1234'), b'group:1234:rw-') + self.assert_equal(acl_use_local_uid_gid(b'user:root:rw-:0'), b'user:0:rw-') + self.assert_equal(acl_use_local_uid_gid(b'group:root:rw-:0'), b'group:0:rw-') + @unittest.skipUnless(sys.platform.startswith('darwin'), 'OS X only test') @unittest.skipIf(fakeroot_detected(), 'not compatible with fakeroot')