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>
|
Fri Mar 20 10:08:43 UTC 2020 - Fabian Vogt <fvogt@suse.com>
|
||||||
|
|
||||||
|
@ -11,16 +11,20 @@ run() {
|
|||||||
busybox=
|
busybox=
|
||||||
for i in /bin/busybox /usr/bin/busybox; do [ -x "$i" ] && busybox=$i; done
|
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
|
do
|
||||||
case "$arg0" in
|
eval set -- $LINE
|
||||||
|
case "${1-}" in
|
||||||
|
\#*|"")
|
||||||
|
;;
|
||||||
g)
|
g)
|
||||||
ARGUMENTS="${arg1}"
|
shift
|
||||||
if [ -n "${arg2}" -a "${arg2}" != "-" ]; then
|
ARGUMENTS="$1"
|
||||||
ARGUMENTS="-g ${arg2} $ARGUMENTS"
|
if [ -n "${2-}" ] && [ "$2" != "-" ]; then
|
||||||
|
ARGUMENTS="-g $2 $ARGUMENTS"
|
||||||
fi
|
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
|
if [ -x "/usr/sbin/groupadd" ]; then
|
||||||
run /usr/sbin/groupadd -r $ARGUMENTS
|
run /usr/sbin/groupadd -r $ARGUMENTS
|
||||||
elif [ -x "$busybox" ]; then
|
elif [ -x "$busybox" ]; then
|
||||||
@ -32,30 +36,31 @@ do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
u)
|
u)
|
||||||
ARGUMENTS="${arg1}"
|
shift
|
||||||
if [ -n "${arg2}" ] && [ "${arg2}" != "-" ]; then
|
ARGUMENTS="$1"
|
||||||
ARGUMENTS="-u ${arg2} $ARGUMENTS"
|
if [ -n "${2-}" ] && [ "$2" != "-" ]; then
|
||||||
|
ARGUMENTS="-u $2 $ARGUMENTS"
|
||||||
fi
|
fi
|
||||||
if [ -n "${arg4}" ] && [ "${arg4}" != "-" ]; then
|
if [ -n "${4-}" ] && [ "$4" != "-" ]; then
|
||||||
ARGUMENTS="-d ${arg4} $ARGUMENTS"
|
ARGUMENTS="-d $4 $ARGUMENTS"
|
||||||
else
|
else
|
||||||
ARGUMENTS="-d / $ARGUMENTS"
|
ARGUMENTS="-d / $ARGUMENTS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -x /usr/sbin/useradd ]; then
|
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
|
# this is useradd/shadow specific
|
||||||
ARGUMENTS="-g ${arg1} $ARGUMENTS"
|
ARGUMENTS="-g $1 $ARGUMENTS"
|
||||||
/usr/bin/getent group "${arg1}" >> /dev/null || ARGUMENTS="-U $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
|
fi
|
||||||
elif [ -x "$busybox" ]; then
|
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
|
if ! /usr/bin/getent passwd $1 >> /dev/null; then
|
||||||
ARGUMENTS="$(echo -G ${arg1} $ARGUMENTS | sed -e 's|-d|-h|g' -e 's|-g|-G|g')"
|
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 "${arg3}" $ARGUMENTS
|
run $busybox adduser -S -H -s /sbin/nologin -g "$3" $ARGUMENTS
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "ERROR: neither useradd nor busybox found!"
|
echo "ERROR: neither useradd nor busybox found!"
|
||||||
@ -63,20 +68,21 @@ do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
m)
|
m)
|
||||||
|
shift
|
||||||
if [ -x /usr/sbin/usermod ] ; then
|
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
|
elif [ -x "$busybox" ]; then
|
||||||
run $busybox addgroup ${arg1} ${arg2}
|
run $busybox addgroup $1 $2
|
||||||
else
|
else
|
||||||
echo "ERROR: neither usermod nor busybox found!"
|
echo "ERROR: neither usermod nor busybox found!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
r)
|
r)
|
||||||
echo "range option ignored: \"$arg0 $arg1 $arg2 $arg3\""
|
echo "range option ignored: \"$LINE\""
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Syntax Error: \"$arg0\""
|
echo "Syntax Error: \"$LINE\""
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user