]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: Create testuser at runtime
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 13 Mar 2025 14:27:03 +0000 (15:27 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 18 Mar 2025 21:46:10 +0000 (22:46 +0100)
Now that we have userdb credentials, let's ship testuser as a userdb
credential instead of including it in the image.

mkosi.credentials/userdb.group.testuser [new file with mode: 0644]
mkosi.credentials/userdb.user.testuser [new file with mode: 0644]
mkosi.extra/usr/lib/tmpfiles.d/testuser.conf [deleted file]
mkosi.postinst.chroot

diff --git a/mkosi.credentials/userdb.group.testuser b/mkosi.credentials/userdb.group.testuser
new file mode 100644 (file)
index 0000000..39e441f
--- /dev/null
@@ -0,0 +1,5 @@
+{
+    "groupName": "testuser",
+    "gid": 4711,
+    "disposition": "regular"
+}
diff --git a/mkosi.credentials/userdb.user.testuser b/mkosi.credentials/userdb.user.testuser
new file mode 100644 (file)
index 0000000..6a2ce88
--- /dev/null
@@ -0,0 +1,14 @@
+{
+    "userName": "testuser",
+    "uid": 4711,
+    "disposition": "regular",
+    "enforcePasswordPolicy": false,
+    "memberOf": [
+        "wheel",
+        "systemd-journal"
+    ],
+    "shell": "/bin/bash",
+    "privileged": {
+        "hashedPassword": ["$1$kqp7NF1f$tNnQcshPX53CSfRKTQD0R1"]
+    }
+}
diff --git a/mkosi.extra/usr/lib/tmpfiles.d/testuser.conf b/mkosi.extra/usr/lib/tmpfiles.d/testuser.conf
deleted file mode 100644 (file)
index 7113177..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-z! /home/testuser 700 testuser testuser
index 693514b3130590d38e28823c07cfd4149e104170..914502a473605c788293a59d754514f8dea0d981 100755 (executable)
@@ -5,14 +5,6 @@ set -o nounset
 
 find "$BUILDDIR" \( -name "*.rpm" -o -name "*.deb" -o -name "*.pkg.tar" -o -name systemd.raw \) -exec cp -t "$OUTPUTDIR" {} \;
 
-useradd \
-    --uid 4711 \
-    --user-group \
-    --create-home \
-    --password "$(openssl passwd -1 testuser)" \
-    --shell /bin/bash \
-    testuser
-
 if command -v authselect >/dev/null; then
     # authselect 1.5.0 renamed the minimal profile to the local profile without keeping backwards compat so
     # let's use the new name if it exists.