Dominique Leuenberger 2019-08-05 09:18:26 +00:00 committed by Git OBS Bridge
commit 405f6921ea
4 changed files with 47 additions and 10 deletions

View File

@ -14,7 +14,8 @@
###
# This is for useradd/usermod/groupadd
%sysusers_requires Requires(pre): shadow sysuser-shadow
%sysusers_requires Requires(pre): useradd_or_adduser_dep sysuser-shadow \
Suggests: shadow
%sysusers_generate_pre() \
%{_prefix}/lib/rpm/sysusers-generate-pre "%1" > "%2".pre

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Fri Jul 26 13:28:27 CEST 2019 - kukuk@suse.de
- Use suggests shadow to prefer that over busybox in normal systems
-------------------------------------------------------------------
Thu Jul 25 16:00:35 CEST 2019 - kukuk@suse.de
- Add support for busybox adduser/addgroup
- Change requirements from shadow to useradd_or_adduser_dep
-------------------------------------------------------------------
Thu May 9 13:23:56 CEST 2019 - kukuk@suse.de

View File

@ -17,7 +17,7 @@
Name: sysuser-tools
Version: 2.0
Version: 3.0
Release: 0
Summary: Auto provides for system users
License: MIT
@ -38,7 +38,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
Requires: useradd_or_adduser_dep
%description -n sysuser-shadow
This package contians a tool, which expects as input a sysusers.d

View File

@ -11,8 +11,16 @@ do
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 || exit $?
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 $?
else
echo "ERROR: neither groupadd nor busybox found!"
exit 1
fi
;;
u*)
eval arr=( $LINE )
@ -25,19 +33,36 @@ do
else
ARGUMENTS="-d / $ARGUMENTS"
fi
/usr/bin/getent group ${arr[1]} >> /dev/null
/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 $?
if [ -x /usr/sbin/useradd ]; then
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
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 $?
else
echo "ERROR: neither useradd nor busybox found!"
exit 1
fi
;;
m*)
eval arr=( $LINE )
echo "usermod -a -G ${arr[2]} ${arr[1]}"
/usr/sbin/usermod -a -G ${arr[2]} ${arr[1]} || exit $?
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 $?
else
echo "ERROR: neither usermod nor busybox found!"
exit 1
fi
;;
r*)
echo "range option ignored: \"$LINE\""