From c35174b874738beb0b9f11e4cbb642db6ca7dac78d5d4d67d4c8954253b80bbd Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Mon, 19 Jun 2017 06:26:55 +0000 Subject: [PATCH 1/3] Accepting request 504523 from home:kukuk:sysusers - Put helper script into own subpackage - Convert sysusers config file to shadow arguments and use shadow suite to create user and groups. Fixes [bsc#1041497] and serveral dependency loops. OBS-URL: https://build.opensuse.org/request/show/504523 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=7 --- macros.sysusers | 4 ++-- sysuser-tools.changes | 12 +++++++++++ sysuser-tools.spec | 17 ++++++++++++++- sysusers-generate-pre | 2 +- sysusers2shadow.sh | 48 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 sysusers2shadow.sh diff --git a/macros.sysusers b/macros.sysusers index eacbcf1..c539c06 100644 --- a/macros.sysusers +++ b/macros.sysusers @@ -13,8 +13,8 @@ # ### -# This is for systemctl -%sysusers_requires Requires(pre): systemd +# This is for useradd/usermod/groupadd +%sysusers_requires Requires(pre): shadow sysuser-shadow %sysusers_generate_pre() \ %{_prefix}/lib/rpm/sysusers-generate-pre "%1" > "%2".pre diff --git a/sysuser-tools.changes b/sysuser-tools.changes index e843705..812531b 100644 --- a/sysuser-tools.changes +++ b/sysuser-tools.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Sun Jun 18 18:07:24 CEST 2017 - kukuk@suse.de + +- Put helper script into own subpackage + +------------------------------------------------------------------- +Sat Jun 17 09:20:09 CEST 2017 - kukuk@suse.de + +- Convert sysusers config file to shadow arguments and use + shadow suite to create user and groups. Fixes [bsc#1041497] and + serveral dependency loops. + ------------------------------------------------------------------- Tue May 30 10:07:45 CEST 2017 - kukuk@suse.de diff --git a/sysuser-tools.spec b/sysuser-tools.spec index ab20bd8..09e928b 100644 --- a/sysuser-tools.spec +++ b/sysuser-tools.spec @@ -17,7 +17,7 @@ Name: sysuser-tools -Version: 1.1 +Version: 2.0 Release: 0 Summary: Auto provides for system users License: MIT @@ -26,11 +26,21 @@ Source: sysusers.prov Source1: sysusers.attr Source2: sysusers-generate-pre Source3: macros.sysusers +Source4: sysusers2shadow.sh BuildArch: noarch %description Generate auto provides for system users. +%package -n sysuser-shadow +Summary: Tool to execute sysusers.d with shadow utilities +Group: System/Packages + +%description -n sysuser-shadow +This package contians a tool, which expects as input a sysusers.d +configuration file and uses the shadow suite to create the users +and groups from it like systemd-sysusers would do. + %prep %setup -qcT @@ -41,6 +51,7 @@ install -D -m 755 %{SOURCE0} %{buildroot}%{_prefix}/lib/rpm/sysusers.prov install -D -m 644 %{SOURCE1} %{buildroot}%{_prefix}/lib/rpm/fileattrs/sysusers.attr install -D -m 755 %{SOURCE2} %{buildroot}%{_prefix}/lib/rpm/sysusers-generate-pre install -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/rpm/macros.sysusers +install -D -m 755 %{SOURCE4} %{buildroot}%{_sbindir}/sysusers2shadow %files %defattr(-,root,root) @@ -49,4 +60,8 @@ install -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/rpm/macros.sysusers %{_prefix}/lib/rpm/fileattrs/sysusers.attr %{_prefix}/lib/rpm/sysusers-generate-pre +%files -n sysuser-shadow +%defattr(-,root,root) +%{_sbindir}/sysusers2shadow + %changelog diff --git a/sysusers-generate-pre b/sysusers-generate-pre index 9cb554d..4ac7c81 100644 --- a/sysusers-generate-pre +++ b/sysusers-generate-pre @@ -18,7 +18,7 @@ done lines=`wc -l < "$tmpfile"` echo '#!/bin/bash' -echo "tail -n $lines \$0 | /usr/bin/systemd-sysusers -" +echo "tail -n $lines \$0 | /usr/sbin/sysusers2shadow" echo "exit 0" echo '######## data below ########' cat "$tmpfile" diff --git a/sysusers2shadow.sh b/sysusers2shadow.sh new file mode 100644 index 0000000..618efb5 --- /dev/null +++ b/sysusers2shadow.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +while read LINE +do + case "$LINE" in + \#*|"") + ;; + g*) + eval arr=( $LINE ) + ARGUMENTS="${arr[1]}" + if [ ! -z "${arr[2]}" -a "${arr[2]}" != "-" ]; then + ARGUMENTS="-g ${arr[2]} $ARGUMENTS" + fi + echo "groupadd -r $ARGUMENTS" + /usr/bin/getent group "${arr[1]}" >> /dev/null || /usr/sbin/groupadd -r $ARGUMENTS + ;; + u*) + eval arr=( $LINE ) + ARGUMENTS="${arr[1]}" + if [ ! -z "${arr[2]}" -a "${arr[2]}" != "-" ]; then + ARGUMENTS="-u ${arr[2]} $ARGUMENTS" + fi + if [ ! -z "${arr[4]}" -a "${arr[4]}" != "-" ]; then + ARGUMENTS="-d ${arr[4]} $ARGUMENTS" + fi + /usr/bin/getent group ${arr[1]} >> /dev/null + if [ $? -eq 0 ]; then + ARGUMENTS="-g ${arr[1]} $ARGUMENTS" + else + ARGUMENTS="-U $ARGUMENTS" + fi + echo "useradd -r -s /sbin/nologin -c \"${arr[3]}\" $ARGUMENTS" + /usr/bin/getent passwd ${arr[1]} >> /dev/null || /usr/sbin/useradd -r -s /sbin/nologin -c "${arr[3]}" $ARGUMENTS + ;; + m*) + eval arr=( $LINE ) + echo "usermod -a -G ${arr[2]} ${arr[1]}" + /usr/sbin/usermod -a -G ${arr[2]} ${arr[1]} + ;; + r*) + echo "range option ignored: \"$LINE\"" + ;; + *) + echo "Syntax Error: \"$LINE\"" + exit 1 + ;; + esac +done From 0b8c1d1d8987f25cfd822d0712f6f8ed0b14cc21e485e648dcc81470c2068f49 Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Mon, 19 Jun 2017 11:49:47 +0000 Subject: [PATCH 2/3] Accepting request 504648 from home:kukuk:sysusers - Add requires for shadow to sysuser-shadow OBS-URL: https://build.opensuse.org/request/show/504648 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=8 --- sysuser-tools.changes | 5 +++++ sysuser-tools.spec | 1 + 2 files changed, 6 insertions(+) diff --git a/sysuser-tools.changes b/sysuser-tools.changes index 812531b..a0b502f 100644 --- a/sysuser-tools.changes +++ b/sysuser-tools.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Jun 19 13:48:34 CEST 2017 - kukuk@suse.de + +- Add requires for shadow to sysuser-shadow + ------------------------------------------------------------------- Sun Jun 18 18:07:24 CEST 2017 - kukuk@suse.de diff --git a/sysuser-tools.spec b/sysuser-tools.spec index 09e928b..e6daacf 100644 --- a/sysuser-tools.spec +++ b/sysuser-tools.spec @@ -35,6 +35,7 @@ Generate auto provides for system users. %package -n sysuser-shadow Summary: Tool to execute sysusers.d with shadow utilities Group: System/Packages +Requires: shadow %description -n sysuser-shadow This package contians a tool, which expects as input a sysusers.d From 173b7640486173ebb8196ba59a4a43ab874ca988bbf0551f606bf66a1ac6175d Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Mon, 19 Jun 2017 12:08:42 +0000 Subject: [PATCH 3/3] Accepting request 504693 from home:kukuk:sysusers - sysuser-tools needs to require sysuser-shadow OBS-URL: https://build.opensuse.org/request/show/504693 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=9 --- sysuser-tools.changes | 5 +++++ sysuser-tools.spec | 3 +++ 2 files changed, 8 insertions(+) diff --git a/sysuser-tools.changes b/sysuser-tools.changes index a0b502f..569db8d 100644 --- a/sysuser-tools.changes +++ b/sysuser-tools.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Jun 19 14:07:51 CEST 2017 - kukuk@suse.de + +- sysuser-tools needs to require sysuser-shadow + ------------------------------------------------------------------- Mon Jun 19 13:48:34 CEST 2017 - kukuk@suse.de diff --git a/sysuser-tools.spec b/sysuser-tools.spec index e6daacf..ce8c44d 100644 --- a/sysuser-tools.spec +++ b/sysuser-tools.spec @@ -28,6 +28,9 @@ Source2: sysusers-generate-pre Source3: macros.sysusers Source4: sysusers2shadow.sh BuildArch: noarch +Requires: sysuser-shadow +#!BuildIgnore: sysuser-shadow +#!BuildIgnore: sysuser-tools %description Generate auto provides for system users.