1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 09:19:31 +00:00

acls (linux): add a test for acl_use_local_uid_gid and fix this function

this has never worked as intended as the function was not using the computed "fields[1]" value at all.
plus there were type issues after that was fixed.
This commit is contained in:
Thomas Waldmann 2015-10-18 23:20:01 +02:00
parent 45b04cd3c1
commit 55179fe64d
2 changed files with 10 additions and 3 deletions

View file

@ -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')

View file

@ -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')