Accepting request 787733 from home:favogt:nobash
- Use eval set -- $LINE instead of read for parsing Fixes system-user-man. eval is evil though, so if there is a better idea, please tell OBS-URL: https://build.opensuse.org/request/show/787733 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=24
This commit is contained in:
parent
54305a4169
commit
1111c839cc
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 24 10:01:39 UTC 2020 - Fabian Vogt <fvogt@suse.com>
|
||||
|
||||
- Use eval set -- $LINE instead of read for parsing
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 20 10:08:43 UTC 2020 - Fabian Vogt <fvogt@suse.com>
|
||||
|
||||
|
@ -11,16 +11,20 @@ run() {
|
||||
busybox=
|
||||
for i in /bin/busybox /usr/bin/busybox; do [ -x "$i" ] && busybox=$i; done
|
||||
|
||||
while read arg0 arg1 arg2 arg3 arg4
|
||||
while read LINE
|
||||
do
|
||||
case "$arg0" in
|
||||
eval set -- $LINE
|
||||
case "${1-}" in
|
||||
\#*|"")
|
||||
;;
|
||||
g)
|
||||
ARGUMENTS="${arg1}"
|
||||
if [ -n "${arg2}" -a "${arg2}" != "-" ]; then
|
||||
ARGUMENTS="-g ${arg2} $ARGUMENTS"
|
||||
shift
|
||||
ARGUMENTS="$1"
|
||||
if [ -n "${2-}" ] && [ "$2" != "-" ]; then
|
||||
ARGUMENTS="-g $2 $ARGUMENTS"
|
||||
fi
|
||||
|
||||
if ! /usr/bin/getent group "${arg1}" >> /dev/null; then
|
||||
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
|
||||
@ -32,30 +36,31 @@ do
|
||||
fi
|
||||
;;
|
||||
u)
|
||||
ARGUMENTS="${arg1}"
|
||||
if [ -n "${arg2}" ] && [ "${arg2}" != "-" ]; then
|
||||
ARGUMENTS="-u ${arg2} $ARGUMENTS"
|
||||
shift
|
||||
ARGUMENTS="$1"
|
||||
if [ -n "${2-}" ] && [ "$2" != "-" ]; then
|
||||
ARGUMENTS="-u $2 $ARGUMENTS"
|
||||
fi
|
||||
if [ -n "${arg4}" ] && [ "${arg4}" != "-" ]; then
|
||||
ARGUMENTS="-d ${arg4} $ARGUMENTS"
|
||||
if [ -n "${4-}" ] && [ "$4" != "-" ]; then
|
||||
ARGUMENTS="-d $4 $ARGUMENTS"
|
||||
else
|
||||
ARGUMENTS="-d / $ARGUMENTS"
|
||||
fi
|
||||
|
||||
if [ -x /usr/sbin/useradd ]; then
|
||||
if ! /usr/bin/getent passwd "${arg1}" >> /dev/null; then
|
||||
if ! /usr/bin/getent passwd "$1" >> /dev/null; then
|
||||
# this is useradd/shadow specific
|
||||
ARGUMENTS="-g ${arg1} $ARGUMENTS"
|
||||
/usr/bin/getent group "${arg1}" >> /dev/null || ARGUMENTS="-U $ARGUMENTS"
|
||||
ARGUMENTS="-g $1 $ARGUMENTS"
|
||||
/usr/bin/getent group "$1" >> /dev/null || ARGUMENTS="-U $ARGUMENTS"
|
||||
|
||||
run /usr/sbin/useradd -r -s /sbin/nologin -c "${arg3}" $ARGUMENTS
|
||||
run /usr/sbin/useradd -r -s /sbin/nologin -c "$3" $ARGUMENTS
|
||||
fi
|
||||
elif [ -x "$busybox" ]; then
|
||||
/usr/bin/getent group "${arg1}" >> /dev/null || $busybox addgroup "${arg1}"
|
||||
/usr/bin/getent group "$1" >> /dev/null || $busybox addgroup "$1"
|
||||
|
||||
if ! /usr/bin/getent passwd ${arg1} >> /dev/null; then
|
||||
ARGUMENTS="$(echo -G ${arg1} $ARGUMENTS | sed -e 's|-d|-h|g' -e 's|-g|-G|g')"
|
||||
run $busybox adduser -S -H -s /sbin/nologin -g "${arg3}" $ARGUMENTS
|
||||
if ! /usr/bin/getent passwd $1 >> /dev/null; then
|
||||
ARGUMENTS="$(echo -G $1 $ARGUMENTS | sed -e 's|-d|-h|g' -e 's|-g|-G|g')"
|
||||
run $busybox adduser -S -H -s /sbin/nologin -g "$3" $ARGUMENTS
|
||||
fi
|
||||
else
|
||||
echo "ERROR: neither useradd nor busybox found!"
|
||||
@ -63,20 +68,21 @@ do
|
||||
fi
|
||||
;;
|
||||
m)
|
||||
shift
|
||||
if [ -x /usr/sbin/usermod ] ; then
|
||||
run /usr/sbin/usermod -a -G ${arg2} ${arg1}
|
||||
run /usr/sbin/usermod -a -G $2 $1
|
||||
elif [ -x "$busybox" ]; then
|
||||
run $busybox addgroup ${arg1} ${arg2}
|
||||
run $busybox addgroup $1 $2
|
||||
else
|
||||
echo "ERROR: neither usermod nor busybox found!"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
r)
|
||||
echo "range option ignored: \"$arg0 $arg1 $arg2 $arg3\""
|
||||
echo "range option ignored: \"$LINE\""
|
||||
;;
|
||||
*)
|
||||
echo "Syntax Error: \"$arg0\""
|
||||
echo "Syntax Error: \"$LINE\""
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user