From a19c93759765c0d33bcb30f85eaf0ed9ae4779474862a26bdd97d3c51df1b4b7 Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Sun, 29 Dec 2019 21:30:37 +0000 Subject: [PATCH] Accepting request 759948 from home:kukuk:ei-demo - Look for /bin/busybox, too - Add special handling for busybox and groups OBS-URL: https://build.opensuse.org/request/show/759948 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=20 --- sysuser-tools.changes | 6 ++++++ sysuser-tools.spec | 2 +- sysusers2shadow.sh | 33 +++++++++++++++++++++++++++------ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/sysuser-tools.changes b/sysuser-tools.changes index 23918db..1c3f2ad 100644 --- a/sysuser-tools.changes +++ b/sysuser-tools.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Sun Dec 29 19:16:13 UTC 2019 - kukuk@suse.de + +- Look for /bin/busybox, too +- Add special handling for busybox and groups + ------------------------------------------------------------------- Fri Jul 26 13:28:27 CEST 2019 - kukuk@suse.de diff --git a/sysuser-tools.spec b/sysuser-tools.spec index 8ae0cdb..e687589 100644 --- a/sysuser-tools.spec +++ b/sysuser-tools.spec @@ -1,7 +1,7 @@ # # spec file for package sysuser-tools # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed diff --git a/sysusers2shadow.sh b/sysusers2shadow.sh index 2ebda19..f51297e 100644 --- a/sysusers2shadow.sh +++ b/sysusers2shadow.sh @@ -17,6 +17,9 @@ do elif [ -x /usr/bin/busybox ]; then echo "addgroup -S $ARGUMENTS" /usr/bin/getent group "${arr[1]}" >> /dev/null || /usr/bin/busybox addgroup -S $ARGUMENTS || exit $? + elif [ -x /bin/busybox ]; then + echo "addgroup -S $ARGUMENTS" + /usr/bin/getent group "${arr[1]}" >> /dev/null || /bin/busybox addgroup -S $ARGUMENTS || exit $? else echo "ERROR: neither groupadd nor busybox found!" exit 1 @@ -33,19 +36,34 @@ do else ARGUMENTS="-d / $ARGUMENTS" fi - /usr/bin/getent group ${arr[1]} >> /dev/null - if [ $? -eq 0 ]; then - ARGUMENTS="-g ${arr[1]} $ARGUMENTS" - else - ARGUMENTS="-U $ARGUMENTS" - fi if [ -x /usr/sbin/useradd ]; then + # this is useradd/shadow specific + /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 || exit $? elif [ -x /usr/bin/busybox ]; then + /usr/bin/getent group ${arr[1]} >> /dev/null + if [ $? -ne 0 ]; then + /usr/bin/busybox addgroup ${arr[1]} + fi + ARGUMENTS="-G ${arr[1]} $ARGUMENTS" ARGUMENTS=`echo $ARGUMENTS | sed -e 's|-d|-h|g' -e 's|-g|-G|g'` echo "adduser -S -s /sbin/nologin -g \"${arr[3]}\" $ARGUMENTS" /usr/bin/getent passwd ${arr[1]} >> /dev/null || /usr/bin/busybox adduser -S -s /sbin/nologin -g "${arr[3]}" $ARGUMENTS || exit $? + elif [ -x /bin/busybox ]; then + /usr/bin/getent group ${arr[1]} >> /dev/null + if [ $? -ne 0 ]; then + /bin/busybox addgroup ${arr[1]} + fi + ARGUMENTS="-G ${arr[1]} $ARGUMENTS" + ARGUMENTS=`echo $ARGUMENTS | sed -e 's|-d|-h|g' -e 's|-g|-G|g'` + echo "adduser -S -s /sbin/nologin -g \"${arr[3]}\" $ARGUMENTS" + /usr/bin/getent passwd ${arr[1]} >> /dev/null || /bin/busybox adduser -S -s /sbin/nologin -g "${arr[3]}" $ARGUMENTS || exit $? else echo "ERROR: neither useradd nor busybox found!" exit 1 @@ -59,6 +77,9 @@ do elif [ -x /usr/bin/busybox ]; then echo "addgroup ${arr[1]} ${arr[2]}" /usr/bin/busybox addgroup ${arr[1]} ${arr[2]} || exit $? + elif [ -x /bin/busybox ]; then + echo "addgroup ${arr[1]} ${arr[2]}" + /bin/busybox addgroup ${arr[1]} ${arr[2]} || exit $? else echo "ERROR: neither usermod nor busybox found!" exit 1