Hello community,

here is the log from the commit of package sysuser-tools for openSUSE:Factory 
checked in at 2020-03-30 22:50:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/sysuser-tools (Old)
 and      /work/SRC/openSUSE:Factory/.sysuser-tools.new.3160 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "sysuser-tools"

Mon Mar 30 22:50:53 2020 rev:9 rq:788122 version:3.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/sysuser-tools/sysuser-tools.changes      
2020-01-20 22:47:14.775154283 +0100
+++ /work/SRC/openSUSE:Factory/.sysuser-tools.new.3160/sysuser-tools.changes    
2020-03-30 22:50:53.743756412 +0200
@@ -1,0 +2,24 @@
+Wed Mar 25 07:53:55 UTC 2020 - Fabian Vogt <[email protected]>
+
+- Fix bug introduced by simplification of check for useradd -g
+- Refactor use of sed away
+
+-------------------------------------------------------------------
+Tue Mar 24 10:01:39 UTC 2020 - Fabian Vogt <[email protected]>
+
+- Use eval set -- $LINE instead of read for parsing
+
+-------------------------------------------------------------------
+Fri Mar 20 10:08:43 UTC 2020 - Fabian Vogt <[email protected]>
+
+- Clean up sysusers2shadow and make it use only /bin/sh
+- Don't let busybox adduser create the home directory, it breaks
+  permissions of e.g. /sbin (home of daemon)
+- Use only /bin/sh in sysusers-generate-pre and the generated code
+
+-------------------------------------------------------------------
+Tue Mar 17 10:12:15 UTC 2020 - Fabian Vogt <[email protected]>
+
+- Drop use of tail from the generated %pre scriptlets
+
+-------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ sysuser-tools.spec ++++++
--- /var/tmp/diff_new_pack.tAfhvl/_old  2020-03-30 22:50:54.255756691 +0200
+++ /var/tmp/diff_new_pack.tAfhvl/_new  2020-03-30 22:50:54.255756691 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package sysuser-tools
 #
-# Copyright (c) 2019 SUSE LLC
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed

++++++ sysusers-generate-pre ++++++
--- /var/tmp/diff_new_pack.tAfhvl/_old  2020-03-30 22:50:54.303756718 +0200
+++ /var/tmp/diff_new_pack.tAfhvl/_new  2020-03-30 22:50:54.303756718 +0200
@@ -1,26 +1,8 @@
-#!/bin/bash
-# pass systemd sysusers config files a as argument to this script.
-# It will output a shell script that creates those users by
-# appending the data to itself.
+#!/bin/sh
+# pass systemd sysusers config paths as argument to this script.
 
-tmpfile=`mktemp -q -t sysusers.XXXXXX`
-cleanup()
-{
-       rm -f "$tmpfile"
-}
-
-trap cleanup EXIT
-
-for i in "$@"; do
-       grep -e '^[ugmr]' "$i" >> "$tmpfile"
-done
-
-lines=`wc -l < "$tmpfile"`
-
-echo '#!/bin/bash'
-echo "tail -n $lines \$0 | /usr/sbin/sysusers2shadow"
-echo 'RET=$?'
-echo 'test -f /.buildenv && exit 0'
-echo 'exit $RET'
-echo '######## data below ########'
-cat "$tmpfile"
+echo '#!/bin/sh'
+echo 'cat <<"EOF" |'
+grep -he '^[ugmr]' "$@"
+echo 'EOF'
+echo '/usr/sbin/sysusers2shadow || [ -f /.buildenv ]'

++++++ sysusers2shadow.sh ++++++
--- /var/tmp/diff_new_pack.tAfhvl/_old  2020-03-30 22:50:54.327756730 +0200
+++ /var/tmp/diff_new_pack.tAfhvl/_new  2020-03-30 22:50:54.327756730 +0200
@@ -1,96 +1,90 @@
-#!/bin/bash
+#!/bin/sh
+set -eu
+
+# Print the command and run it
+run() {
+       echo "$@"
+       "$@"
+}
+
+# Absolute path to busybox, if found
+busybox=
+for i in /bin/busybox /usr/bin/busybox; do [ -x "$i" ] && busybox=$i; done
 
 while read LINE
 do
-    case "$LINE" in
+       eval set -- $LINE
+       case "${1-}" in
        \#*|"")
-           ;;
-       g*)
-            eval arr=( $LINE )
-            ARGUMENTS="${arr[1]}"
-            if [ ! -z "${arr[2]}" -a "${arr[2]}" != "-" ]; then
-                ARGUMENTS="-g ${arr[2]} $ARGUMENTS"
-           fi
-           if [ -x /usr/sbin/groupadd ]; then
-               echo "groupadd -r $ARGUMENTS"
-               /usr/bin/getent group "${arr[1]}" >> /dev/null || 
/usr/sbin/groupadd -r $ARGUMENTS || exit $?
-           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
-           fi
-           ;;
-       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"
-           else
-               ARGUMENTS="-d / $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"
+               ;;
+       g)
+               shift
+               ARGUMENTS="$1"
+               if [ -n "${2-}" ] && [ "$2" != "-" ]; then
+                       ARGUMENTS="-g $2 $ARGUMENTS"
+               fi
+
+               if ! /usr/bin/getent group "$1" >> /dev/null; then
+                       if [ -x "/usr/sbin/groupadd" ]; then
+                               run /usr/sbin/groupadd -r $ARGUMENTS
+                       elif [ -x "$busybox" ]; then
+                               run $busybox addgroup -S $ARGUMENTS
+                       else
+                               echo "ERROR: neither groupadd nor busybox 
found!"
+                               exit 1
+                       fi
+               fi
+               ;;
+       u)
+               shift
+               ARGUMENTS="$1"
+               if [ -n "${2-}" ] && [ "$2" != "-" ]; then
+                       ARGUMENTS="-u $2 $ARGUMENTS"
+               fi
+               homedir="/" # If null, empty or '-'
+               if [ "${4:--}" != "-" ]; then
+                       homedir="$4"
+               fi
+
+               if [ -x /usr/sbin/useradd ]; then
+                       if ! /usr/bin/getent passwd "$1" >> /dev/null; then
+                               # this is useradd/shadow specific
+                               if /usr/bin/getent group "$1" >> /dev/null; then
+                                       ARGUMENTS="-g $1 $ARGUMENTS"
+                               else
+                                       ARGUMENTS="-U $ARGUMENTS"
+                               fi
+                       
+                               run /usr/sbin/useradd -r -s /sbin/nologin -c 
"$3" -d "${homedir}" $ARGUMENTS
+                       fi
+               elif [ -x "$busybox" ]; then
+                       /usr/bin/getent group "$1" >> /dev/null || $busybox 
addgroup "$1"
+
+                       if ! /usr/bin/getent passwd "$1" >> /dev/null; then
+                               run $busybox adduser -S -H -s /sbin/nologin -g 
"$3" -G "$1" -h "${homedir}" $ARGUMENTS
+                       fi
                else
-                   ARGUMENTS="-U $ARGUMENTS"
+                       echo "ERROR: neither useradd nor busybox found!"
+                       exit 1
                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
-           fi
            ;;
-       m*)
-            eval arr=( $LINE )
-           if [ -x /usr/sbin/usermod ] ; then
-               echo "usermod -a -G ${arr[2]} ${arr[1]}"
-               /usr/sbin/usermod -a -G ${arr[2]} ${arr[1]} || exit $?
-           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
-           fi
-           ;;
-       r*)
-           echo "range option ignored: \"$LINE\""
+       m)
+               shift
+               if [ -x /usr/sbin/usermod ] ; then
+                               run /usr/sbin/usermod -a -G $2 $1
+               elif [ -x "$busybox" ]; then
+                               run $busybox addgroup $1 $2
+               else
+                               echo "ERROR: neither usermod nor busybox found!"
+                               exit 1
+               fi
            ;;
+       r)
+               echo "range option ignored: \"$LINE\""
+               ;;
        *)
            echo "Syntax Error: \"$LINE\""
            exit 1
            ;;
-    esac
+       esac
 done


Reply via email to