From 73b672ea935a9a1960c8780e382fbfe32c1e6a3c5a85669e62b1db0b32a0f97e Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Fri, 9 Jun 2017 10:02:06 +0000 Subject: [PATCH] Accepting request 502534 from home:kukuk:sysusers - Add utmp to system-group-hardware.conf like systemd has - Create new system-user-root sub-package creating passwd, group and shadow files with root user. OBS-URL: https://build.opensuse.org/request/show/502534 OBS-URL: https://build.opensuse.org/package/show/Base:System/system-users?expand=0&rev=20 --- system-group-hardware.conf | 1 + system-user-root.conf | 11 ++++++++ system-users.changes | 7 ++++++ system-users.spec | 51 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 system-user-root.conf diff --git a/system-group-hardware.conf b/system-group-hardware.conf index 38fab59..ab85b2a 100644 --- a/system-group-hardware.conf +++ b/system-group-hardware.conf @@ -3,6 +3,7 @@ g kmem - - - g lock - - - g tty 5 - - +g utmp - - - # Hardware access groups g audio - - - g cdrom - - - diff --git a/system-user-root.conf b/system-user-root.conf new file mode 100644 index 0000000..19e5705 --- /dev/null +++ b/system-user-root.conf @@ -0,0 +1,11 @@ +# Type Name ID GECOS [HOME] + +# The superuser +g root 0 - - +u root 0 root /root + +# Group owner of /etc/shadow +g shadow 15 - - + +# Default group for normal users +g users 100 - - diff --git a/system-users.changes b/system-users.changes index 9df7325..c8e8a98 100644 --- a/system-users.changes +++ b/system-users.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Jun 9 11:56:50 CEST 2017 - kukuk@suse.de + +- Add utmp to system-group-hardware.conf like systemd has +- Create new system-user-root sub-package creating passwd, group + and shadow files with root user. + ------------------------------------------------------------------- Tue Jun 6 14:52:27 UTC 2017 - dimstar@opensuse.org diff --git a/system-users.spec b/system-users.spec index 7ed25be..0d8e6b3 100644 --- a/system-users.spec +++ b/system-users.spec @@ -38,6 +38,7 @@ Source13: system-user-ftp.conf Source14: system-user-lp.conf Source15: system-user-nobody.conf Source16: system-user-upsd.conf +Source17: system-user-root.conf BuildRequires: sysuser-tools BuildRequires: pkgconfig(systemd) BuildArch: noarch @@ -186,6 +187,25 @@ Requires(pre): group(daemon) This package provides the system account 'upsd'. +# +# system user root is special, since we need user root, +# group root, shadow and users right from the beginning +# before systemd is installable. +# + +%package -n system-user-root +Summary: System user root +Group: System/Fhs +Provides: group(root) +Provides: group(shadow) +Provides: group(users) +Provides: user(root) + +%description -n system-user-root +This package provides the root account including the groups root, +shadow and users. + + %prep %setup -q -c -T @@ -234,6 +254,7 @@ install -m 644 %{SOURCE13} %{buildroot}%{_sysusersdir}/system-user-ftp.conf install -m 644 %{SOURCE14} %{buildroot}%{_sysusersdir}/system-user-lp.conf install -m 644 %{SOURCE15} %{buildroot}%{_sysusersdir}/system-user-nobody.conf install -m 644 %{SOURCE16} %{buildroot}%{_sysusersdir}/system-user-upsd.conf +install -m 644 %{SOURCE17} %{buildroot}%{_sysusersdir}/system-user-root.conf %pre -n system-user-uucp -f uucp.pre %pre -n system-user-games -f games.pre @@ -254,6 +275,36 @@ install -m 644 %{SOURCE16} %{buildroot}%{_sysusersdir}/system-user-upsd.conf %pre -n system-user-upsd -f upsd.pre +%pre -n system-user-root -p +if not posix.access("/etc", "f") then + posix.mkdir("/etc") +end +if not posix.access("/etc/passwd", "f") then + file = io.open("/etc/passwd", "a+") + file:write("root:x:0:0:root:/root:/bin/bash\n") + file:close() + posix.chmod("/etc/passwd", 0644) +end +if not posix.access("/etc/group", "f") then + file = io.open("/etc/group", "a+") + file:write("root:x:0:\nshadow:x:15:\nusers:x:100:\n") + file:close() + posix.chmod("/etc/group", 0644) +end +if not posix.access("/etc/shadow", "f") then + file = io.open("/etc/shadow", "a+") + local date = os.time() + date = math.floor(date / 86400) + file:write("root::", date, "::::::\n") + file:close() + posix.chown("/etc/shadow", 0, 15) + posix.chmod("/etc/shadow", 0640) +end + +%files -n system-user-root +%defattr(-,root,root) +%{_sysusersdir}/system-user-root.conf + %files -n system-user-uucp %defattr(-,root,root) %dir %attr(0750,uucp,uucp) %{_sysconfdir}/uucp