shall be augmented with a new version of a root or \f[C]/usr\f[R]
partition along with its Verity partition and unified kernel.
.TP
-\f[B]\f[CB]NoChown=\f[B]\f[R], \f[B]\f[CB]--no-chown\f[B]\f[R]
+\f[B]\f[CB]Chown=\f[B]\f[R], \f[B]\f[CB]--chown\f[B]\f[R]
By default, if \f[C]mkosi\f[R] is run inside a \f[C]sudo\f[R]
environment all generated artifacts have their UNIX user/group ownership
changed to the user which invoked \f[C]sudo\f[R].
-With this option this may be turned off and all generated files are
-owned by \f[C]root\f[R].
+This behaviour can be disabled with \f[C]--chown=no\f[R].
.TP
\f[B]\f[CB]TarStripSELinuxContext=\f[B]\f[R], \f[B]\f[CB]--tar-strip-selinux-context\f[B]\f[R]
If running on a SELinux-enabled system (Fedora Linux, CentOS, Rocky
unlink_try_hard(cache_path)
shutil.move(cast(str, state.root), cache_path) # typing bug, .move() accepts Path
- if not state.config.no_chown:
+ if state.config.chown:
chown_to_running_user(cache_path)
os.link(oldpath, newpath)
- if config.no_chown:
- return
-
- relpath = path_relative_to_cwd(newpath)
- chown_to_running_user(relpath)
+ if config.chown:
+ relpath = path_relative_to_cwd(newpath)
+ chown_to_running_user(relpath)
def link_output(state: MkosiState, artifact: Optional[BinaryIO]) -> None:
cache = workspace / "cache"
else:
cache = config.cache_path
- mkdirp_chown_current_user(cache, skip_chown=config.no_chown, mode=0o755)
+ mkdirp_chown_current_user(cache, chown=config.chown, mode=0o755)
return cache
group.add_argument("--image-version", help="Set version for image")
group.add_argument("--image-id", help="Set ID for image")
group.add_argument(
- "--no-chown",
+ "--chown",
metavar="BOOL",
action=BooleanAction,
- help="When running with sudo, disable reassignment of ownership of the generated files to the original user",
+ default=True,
+ help="When running with sudo, reassign ownership of the generated files to the original user",
) # NOQA: E501
group.add_argument(
"--tar-strip-selinux-context",
if config.output_dir is None:
return
- mkdirp_chown_current_user(config.output_dir, skip_chown=config.no_chown, mode=0o755)
+ mkdirp_chown_current_user(config.output_dir, chown=config.chown, mode=0o755)
def make_build_dir(config: MkosiConfig) -> None:
if config.build_dir is None:
return
- mkdirp_chown_current_user(config.build_dir, skip_chown=config.no_chown, mode=0o755)
+ mkdirp_chown_current_user(config.build_dir, chown=config.chown, mode=0o755)
def make_cache_dir(config: MkosiConfig) -> None:
# return on None unreachable code. I can't see right now, why it *should* be
# unreachable, so invert the structure here to be on the safe side.
if config.cache_path is not None:
- mkdirp_chown_current_user(config.cache_path, skip_chown=config.no_chown, mode=0o755)
+ mkdirp_chown_current_user(config.cache_path, chown=config.chown, mode=0o755)
def configure_ssh(state: MkosiState, cached: bool) -> Optional[TextIO]:
image_version: Optional[str]
image_id: Optional[str]
hostname: Optional[str]
- no_chown: bool
+ chown: bool
tar_strip_selinux_context: bool
incremental: bool
minimize: bool
def mkdirp_chown_current_user(
path: PathString,
*,
- skip_chown: bool = False,
+ chown: bool = True,
mode: int = 0o777,
exist_ok: bool = True
) -> None:
path.mkdir(mode=mode, exist_ok=exist_ok)
- if skip_chown:
- continue
-
- chown_to_running_user(path)
+ if chown:
+ chown_to_running_user(path)
def safe_tar_extract(tar: tarfile.TarFile, path: Path=Path("."), *, numeric_owner: bool=False) -> None: