]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Change ownership of output files in staging directory
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 18 Oct 2023 21:13:59 +0000 (23:13 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 18 Oct 2023 21:13:59 +0000 (23:13 +0200)
There might be other files in the output directory. Make sure we
only chown the files we produced by iterating over the staging
directory.

mkosi/__init__.py

index 29b2ca5edbcc06bb3eb29b8ed51bc8244796ae3f..7a4fc01d4d3e04a4744aaa4cf6d513617aec9131 100644 (file)
@@ -1973,6 +1973,9 @@ def finalize_staging(state: MkosiState) -> None:
             f.rename(state.staging / name)
 
     for f in state.staging.iterdir():
+        # Make sure all build outputs that are not directories are owned by the user running mkosi.
+        if not f.is_dir():
+            os.chown(f, INVOKING_USER.uid, INVOKING_USER.gid, follow_symlinks=False)
         move_tree(state.config, f, state.config.output_dir_or_cwd())
 
 
@@ -2558,11 +2561,6 @@ def run_verb(args: MkosiArgs, presets: Sequence[MkosiConfig]) -> None:
             with acl_toggle_build(config, INVOKING_USER.uid):
                 build_image(args, config)
 
-            # Make sure all build outputs that are not directories are owned by the user running mkosi.
-            for p in config.output_dir_or_cwd().iterdir():
-                if not p.is_dir():
-                    os.chown(p, INVOKING_USER.uid, INVOKING_USER.gid, follow_symlinks=False)
-
             build = True
 
     if build and args.auto_bump: