forked from pool/sysuser-tools
Accepting request 788085 from home:favogt:nobash
- Fix bug introduced by simplification of check for useradd -g - Refactor use of sed away OBS-URL: https://build.opensuse.org/request/show/788085 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=25
This commit is contained in:
parent
1111c839cc
commit
d7b80fccdd
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 25 07:53:55 UTC 2020 - Fabian Vogt <fvogt@suse.com>
|
||||
|
||||
- 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 <fvogt@suse.com>
|
||||
|
||||
|
@ -41,26 +41,27 @@ do
|
||||
if [ -n "${2-}" ] && [ "$2" != "-" ]; then
|
||||
ARGUMENTS="-u $2 $ARGUMENTS"
|
||||
fi
|
||||
if [ -n "${4-}" ] && [ "$4" != "-" ]; then
|
||||
ARGUMENTS="-d $4 $ARGUMENTS"
|
||||
else
|
||||
ARGUMENTS="-d / $ARGUMENTS"
|
||||
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
|
||||
ARGUMENTS="-g $1 $ARGUMENTS"
|
||||
/usr/bin/getent group "$1" >> /dev/null || ARGUMENTS="-U $ARGUMENTS"
|
||||
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" $ARGUMENTS
|
||||
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
|
||||
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
|
||||
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
|
||||
echo "ERROR: neither useradd nor busybox found!"
|
||||
|
Loading…
Reference in New Issue
Block a user