From 7e3d305a985bbe8a8b96f74cedd20c09bd489fb5 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 6 Oct 2026 13:00:14 +0200 Subject: [PATCH] test_tar_acl_to_borg: look up the current user, not root Haiku has no "root" user, so the name lookup fell back to the name and the test expected uid 0 in vain. Co-Authored-By: Claude Opus 5.5 --- src/borg/testsuite/archive_test.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/borg/testsuite/archive_test.py b/src/borg/testsuite/archive_test.py index c359a1d53..23069054c 100644 --- a/src/borg/testsuite/archive_test.py +++ b/src/borg/testsuite/archive_test.py @@ -807,32 +807,39 @@ def test_get_item_uid_gid(): [ # GNU tar: newline separated, no numeric id for named entries ( - "user::rw-\nuser:root:rw-\ngroup::r--\nmask::rw-\nother::r--\n", - b"user::rw-\nuser:root:rw-:0\ngroup::r--\nmask::rw-\nother::r--", + "user::rw-\nuser:{user}:rw-\ngroup::r--\nmask::rw-\nother::r--\n", + "user::rw-\nuser:{user}:rw-:{uid}\ngroup::r--\nmask::rw-\nother::r--", ), # star: comma separated, numeric id appended ( "user::rw-,user:root:rw-:0,group::r--,mask::rw-,other::r--", - b"user::rw-\nuser:root:rw-:0\ngroup::r--\nmask::rw-\nother::r--", + "user::rw-\nuser:root:rw-:0\ngroup::r--\nmask::rw-\nother::r--", ), # borg export-tar: newline separated, numeric id appended ( "user::rw-\nuser:root:rw-:0\ngroup::r--\nmask::rw-\nother::r--", - b"user::rw-\nuser:root:rw-:0\ngroup::r--\nmask::rw-\nother::r--", + "user::rw-\nuser:root:rw-:0\ngroup::r--\nmask::rw-\nother::r--", ), # unknown names fall back to the name (Windows maps every name to 0) pytest.param( "group:nosuchgroup-borgtest:r--", - b"group:nosuchgroup-borgtest:r--:nosuchgroup-borgtest", + "group:nosuchgroup-borgtest:r--:nosuchgroup-borgtest", marks=pytest.mark.skipif(is_win32, reason="no name lookups on Windows"), ), # comments get removed - ("user:root:r--\t#effective:r--\n", b"user:root:r--:0"), - ("", b""), + ("user:{user}:r--\t#effective:r--\n", "user:{user}:r--:{uid}"), + ("", ""), ], ) def test_tar_acl_to_borg(acl, expected): - assert tar_acl_to_borg(acl) == expected + # the name lookups need an existing user, e.g. Haiku has no "root" user. + try: + uid = os.getuid() # UNIX only + except AttributeError: + uid = 0 + user = uid2user(uid) + acl, expected = acl.format(user=user, uid=uid), expected.format(user=user, uid=uid) + assert tar_acl_to_borg(acl) == expected.encode() def test_reject_non_sanitized_item():