From d83f98814b3ac8e6a61d199b677f34d98e74515f Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 5 Jan 2024 14:26:06 +0100 Subject: [PATCH] Add groupadd script --- NEWS.md | 4 ++-- mkosi/__init__.py | 5 +++-- mkosi/resources/mkosi.md | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3f24d2045..e3ad909a3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -59,8 +59,8 @@ `KernelModulesInitrdIncludeHost=` to only include modules loaded on the host system in the image/initrd respectively. - Implemented `RemovePackages=` for Arch Linux. -- Added `useradd` script to configure `useradd` to operate on the image - during builds instead on the host. +- Added `useradd` and `groupadd` scripts to configure these binaries to + operate on the image during builds instead on the host. - Added microcode support. If installed into the image, an early microcode initrd will automatically be built and prepended to the initrd. diff --git a/mkosi/__init__.py b/mkosi/__init__.py index ba200f2fe..22a0a59a2 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -396,8 +396,9 @@ def finalize_host_scripts( scripts: dict[str, Sequence[PathString]] = {} if find_binary("git"): scripts["git"] = ("git", "-c", "safe.directory=*") - if find_binary("useradd"): - scripts["useradd"] = ("useradd", "--root", context.root) + for binary in ("useradd", "groupadd"): + if find_binary(binary): + scripts[binary] = (binary, "--root", context.root) return finalize_scripts(scripts | helpers | package_manager_scripts(context)) diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index 66a6f541d..2fd346f59 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -1914,8 +1914,8 @@ available via `$PATH` to simplify common usecases. * `git` is automatically invoked with `safe.directory=*` to avoid permissions errors when running as the root user in a user namespace. -* `useradd` is automatically invoked with `--root=$BUILDROOT` when - executed outside of the image. +* `useradd` and `groupadd` are automatically invoked with + `--root=$BUILDROOT` when executed outside of the image. When scripts are executed, any directories that are still writable are also made read-only (`/home`, `/var`, `/root`, ...) and only the minimal -- 2.47.2