From bd7e65097cfd4fb09d7d2fcd2ce41ef2e3775254 Mon Sep 17 00:00:00 2001 From: zhaoxiaohu Date: Thu, 29 Aug 2024 15:22:57 +0800 Subject: [PATCH] sysusers: insist that root group is 0 Signed-off-by: zhaoxiaohu --- ...sysusers-insist-that-root-group-is-0.patch | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 backport-sysusers-insist-that-root-group-is-0.patch diff --git a/backport-sysusers-insist-that-root-group-is-0.patch b/backport-sysusers-insist-that-root-group-is-0.patch new file mode 100644 index 0000000..859acd1 --- /dev/null +++ b/backport-sysusers-insist-that-root-group-is-0.patch @@ -0,0 +1,57 @@ +From 5f9fdbbeeb15fda7b69e3dfd027f556178431202 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 31 Jan 2023 17:04:10 +0100 +Subject: [PATCH] sysusers: insist that root group is 0 + +In https://bugzilla.redhat.com/show_bug.cgi?id=2156900 sysusers was reporting a +conflict between the following lines: + u root 0:0 "Super User" /root /bin/bash + u root 0 "Super User" /root + +The problem is that those configurations are indeed not equivalent. If group 0 +exists with a different name, the first line would just create the user, but the +second line would create a 'root' group with a different GID. The second +behaviour seems definitely wrong. (Or at least more confusing in practice than +the first one. The system is in a strange shape, but the second approach takes +an additional step than is worse than doing nothing.) + +When this line was initially added, we didn't have the uid:gid functionality for +'u', so we didn't think about this too much. But now we do, so we should use it. + +$ build/systemd-sysusers --root=/var/tmp/inst7 --inline 'g foobar 0' +Creating group 'foobar' with GID 0. + +$ build/systemd-sysusers --root=/var/tmp/inst7 --inline 'u root 0 "Zuper zuper"' +src/sysusers/sysusers.c:1365: Creating group 'root' with GID 999. +src/sysusers/sysusers.c:1115: Suggested user ID 0 for root already used. +src/sysusers/sysusers.c:1183: Creating user 'root' (Zuper zuper) with UID 999 and GID 999. + +vs. + +$ build/systemd-sysusers --root=/var/tmp/inst7 --inline 'u root 0:0 "Zuper zuper"' +src/sysusers/sysusers.c:1183: Creating user 'root' (Zuper zuper) with UID 0 and GID 0. + +https://github.com/systemd/systemd/pull/26270/commits/a5cca2983e5bbbe3b0582412f4b3962c585b59a1 + +Signed-off-by: zhaoxiaohu +Signed-off-by: yuwang +--- + sysusers.d/basic.conf.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysusers.d/basic.conf.in b/sysusers.d/basic.conf.in +index 8cc1a7c..bf274b6 100644 +--- a/sysusers.d/basic.conf.in ++++ b/sysusers.d/basic.conf.in +@@ -6,7 +6,7 @@ + # (at your option) any later version. + + # The superuser +-u root 0 "Super User" /root ++u root 0:0 "Super User" /root + + # The nobody user for NFS file systems + u {{NOBODY_USER_NAME}} 65534 "Nobody" - +-- +2.33.0 +