if needs_build(config) or config.verb == Verb.clean:
def target() -> None:
- if os.getuid() != 0:
- become_root()
+ become_root()
unlink_output(config)
fork_and_wait(target)
if needs_build(config):
def target() -> None:
# Get the user UID/GID either on the host or in the user namespace running the build
- uid, gid = become_root() if os.getuid() != 0 else current_user_uid_gid()
+ uid, gid = become_root()
init_mount_namespace()
build_stuff(uid, gid, config)
from types import TracebackType
from typing import Any, Callable, Mapping, Optional, Sequence, Type, TypeVar
-from mkosi.backend import MkosiState
+from mkosi.backend import MkosiState, current_user_uid_gid
from mkosi.log import ARG_DEBUG, MkosiPrinter, die
from mkosi.types import _FILE, CompletedProcess, PathString, Popen
The function returns the UID-GID pair of the invoking user in the namespace (65436, 65436).
"""
+ if os.getuid() == 0:
+ return current_user_uid_gid()
subuid = read_subrange(Path("/etc/subuid"))
subgid = read_subrange(Path("/etc/subgid"))