From: Daan De Meyer Date: Wed, 18 Oct 2023 21:13:59 +0000 (+0200) Subject: Change ownership of output files in staging directory X-Git-Tag: v19~66^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8584a166cbc29629f9794d22bae4ddafc91f33e;p=thirdparty%2Fmkosi.git Change ownership of output files in staging directory There might be other files in the output directory. Make sure we only chown the files we produced by iterating over the staging directory. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 29b2ca5ed..7a4fc01d4 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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: