Ensure unpacked files are owned by user

This is necessary for CI pipelines which run tests as root, otherwise
unpacked files could be owned by unknown users or groups.

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2023-07-31 22:46:08 +02:00
parent 0274ccdef4
commit ab129bb1f5
2 changed files with 10 additions and 2 deletions

View file

@ -159,7 +159,11 @@ def test_process_distgit(
"dummy-test-package-gloster-git.tar.gz", "dummy-test-package-gloster-git.tar.gz",
) )
) as tar: ) as tar:
tar.extractall(path=workdir) # Ensure unpackaged files are owned by user
for member in tar:
member.uid = os.getuid()
member.gid = os.getgid()
tar.extractall(path=workdir, numeric_owner=True)
unpacked_repo_dir = os.path.join(workdir, "dummy-test-package-gloster") unpacked_repo_dir = os.path.join(workdir, "dummy-test-package-gloster")
test_spec_file_path = os.path.join( test_spec_file_path = os.path.join(

View file

@ -28,7 +28,11 @@ class TestRelease:
"dummy-test-package-gloster-git.tar.gz", "dummy-test-package-gloster-git.tar.gz",
) )
) as tar: ) as tar:
tar.extractall(path=workdir) # Ensure unpackaged files are owned by user
for member in tar:
member.uid = os.getuid()
member.gid = os.getgid()
tar.extractall(path=workdir, numeric_owner=True)
unpacked_repo_dir = Path(workdir) / "dummy-test-package-gloster" unpacked_repo_dir = Path(workdir) / "dummy-test-package-gloster"