]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add minimal /etc/group
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 18 Mar 2024 21:15:06 +0000 (22:15 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 19 Mar 2024 12:05:52 +0000 (13:05 +0100)
We already have a minimal /etc/passwd, let's add a minimal /etc/group
as well.

mkosi/__init__.py

index cd382603b713cc3397a8cfd2718f280b7aabe58f..c681d712ff485ae6db4a0db62968b8b623ab409e 100644 (file)
@@ -1505,6 +1505,12 @@ def install_package_manager_trees(context: Context) -> None:
             passwd.write(f"{name}:x:{INVOKING_USER.uid}:{INVOKING_USER.gid}:{name}:{home}:/bin/sh\n")
         os.fchown(passwd.fileno(), INVOKING_USER.uid, INVOKING_USER.gid)
 
+    with (context.pkgmngr / "etc/group").open("w") as group:
+        group.write("root:x:0:\n")
+        if INVOKING_USER.uid != 0:
+            group.write(f"{INVOKING_USER.name()}:x:{INVOKING_USER.gid}:\n")
+        os.fchown(group.fileno(), INVOKING_USER.uid, INVOKING_USER.gid)
+
     if (p := context.config.tools() / "etc/crypto-policies").exists():
         copy_tree(
             p, context.pkgmngr / "etc/crypto-policies",