From ac43675b413c3281ad46aee972d6439fdb89f909894769fd34166361fd4cbd66 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sat, 7 Oct 2017 10:06:56 +0000 Subject: [PATCH] Accepting request 528932 from home:dimstar:Factory Any thoughts about this change? currently we simply hide all errors deep into zypp's log files and somehow hope the system would be working in the end OBS-URL: https://build.opensuse.org/request/show/528932 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=11 --- sysuser-tools.changes | 9 +++++++++ sysusers-generate-pre | 2 +- sysusers2shadow.sh | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sysuser-tools.changes b/sysuser-tools.changes index 569db8d..a77dcb5 100644 --- a/sysuser-tools.changes +++ b/sysuser-tools.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Wed Sep 27 11:06:52 UTC 2017 - dimstar@opensuse.org + +- sysusers2shadow.sh: Exit if one of the useradd/groupadd/usermod + call fails: the resulting system is quite undefined if this + should happen. +- sysusers-generate-pre: exit the pre script with the exit code + of sysusers2shadow.sh. + ------------------------------------------------------------------- Mon Jun 19 14:07:51 CEST 2017 - kukuk@suse.de diff --git a/sysusers-generate-pre b/sysusers-generate-pre index 4ac7c81..d10d4f6 100644 --- a/sysusers-generate-pre +++ b/sysusers-generate-pre @@ -19,6 +19,6 @@ lines=`wc -l < "$tmpfile"` echo '#!/bin/bash' echo "tail -n $lines \$0 | /usr/sbin/sysusers2shadow" -echo "exit 0" +echo "exit $?" echo '######## data below ########' cat "$tmpfile" diff --git a/sysusers2shadow.sh b/sysusers2shadow.sh index 618efb5..61d28f0 100644 --- a/sysusers2shadow.sh +++ b/sysusers2shadow.sh @@ -12,7 +12,7 @@ do ARGUMENTS="-g ${arr[2]} $ARGUMENTS" fi echo "groupadd -r $ARGUMENTS" - /usr/bin/getent group "${arr[1]}" >> /dev/null || /usr/sbin/groupadd -r $ARGUMENTS + /usr/bin/getent group "${arr[1]}" >> /dev/null || /usr/sbin/groupadd -r $ARGUMENTS || exit $? ;; u*) eval arr=( $LINE ) @@ -30,12 +30,12 @@ do 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 + /usr/bin/getent passwd ${arr[1]} >> /dev/null || /usr/sbin/useradd -r -s /sbin/nologin -c "${arr[3]}" $ARGUMENTS || exit $? ;; m*) eval arr=( $LINE ) echo "usermod -a -G ${arr[2]} ${arr[1]}" - /usr/sbin/usermod -a -G ${arr[2]} ${arr[1]} + /usr/sbin/usermod -a -G ${arr[2]} ${arr[1]} || exit $? ;; r*) echo "range option ignored: \"$LINE\""