forked from pool/sysuser-tools
Accepting request 1191331 from Base:System
- Disable UID:GID support for now - UID:GID: don't create group with GID if it does not exist (forwarded request 1191330 from kukuk) OBS-URL: https://build.opensuse.org/request/show/1191331 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/sysuser-tools?expand=0&rev=27
This commit is contained in:
commit
ebcfccaf54
@ -1,3 +1,18 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Aug 3 06:09:03 UTC 2024 - Thorsten Kukuk <kukuk@suse.com>
|
||||||
|
|
||||||
|
- Disable UID:GID support for now
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Aug 2 12:18:53 UTC 2024 - Thorsten Kukuk <kukuk@suse.com>
|
||||||
|
|
||||||
|
- UID:GID: don't create group with GID if it does not exist
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Aug 2 08:24:06 UTC 2024 - Thorsten Kukuk <kukuk@suse.com>
|
||||||
|
|
||||||
|
- Rewrite UID:GID support to work with busybox and fix it for useradd
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Jul 1 15:01:19 UTC 2024 - Johannes Weberhofer <jweberhofer@weberhofer.at>
|
Mon Jul 1 15:01:19 UTC 2024 - Johannes Weberhofer <jweberhofer@weberhofer.at>
|
||||||
|
|
||||||
|
@ -48,21 +48,20 @@ else
|
|||||||
shift
|
shift
|
||||||
ARGUMENTS="$1"
|
ARGUMENTS="$1"
|
||||||
|
|
||||||
|
if /usr/bin/getent passwd "$1" >> /dev/null; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# Split user and Group id
|
# Split user and Group id
|
||||||
userGrouArr=(${2//:/ })
|
#userGrouArr=(${2//:/ })
|
||||||
USER_ID=${userGrouArr[0]}
|
#USER_ID=${userGrouArr[0]}
|
||||||
GROUP_ID=${userGrouArr[1]}
|
#GROUP_ID=${userGrouArr[1]}
|
||||||
|
USER_ID=$2
|
||||||
|
GROUP_ID=""
|
||||||
|
|
||||||
if [ -n "$USER_ID" ] && [ "$USER_ID" != "-" ]; then
|
if [ -n "$USER_ID" ] && [ "$USER_ID" != "-" ]; then
|
||||||
ARGUMENTS="-u $USER_ID $ARGUMENTS"
|
ARGUMENTS="-u $USER_ID $ARGUMENTS"
|
||||||
fi
|
fi
|
||||||
if [ -n "$GROUP_ID" ] && [ "$GROUP_ID" != "-" ]; then
|
|
||||||
ARGUMENTS="-g $GROUP_ID $ARGUMENTS"
|
|
||||||
else
|
|
||||||
if [ "$USER_ID" == "-" ]; then
|
|
||||||
ARGUMENTS="-U $ARGUMENTS"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
homedir="/" # If null, empty or '-'
|
homedir="/" # If null, empty or '-'
|
||||||
if [ "${4:--}" != "-" ]; then
|
if [ "${4:--}" != "-" ]; then
|
||||||
@ -77,30 +76,22 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -x /usr/sbin/useradd ]; then
|
if [ -x /usr/sbin/useradd ]; then
|
||||||
if ! /usr/bin/getent passwd "$1" >> /dev/null; then
|
if [ -n "$GROUP_ID" ] && [ "$GROUP_ID" != "-" ]; then
|
||||||
# this is useradd/shadow specific
|
ARGUMENTS="-g $GROUP_ID $ARGUMENTS"
|
||||||
if /usr/bin/getent group "$1" >> /dev/null; then
|
else
|
||||||
ARGUMENTS="-g $1 $ARGUMENTS"
|
# this is useradd/shadow specific
|
||||||
else
|
if /usr/bin/getent group "$1" >> /dev/null; then
|
||||||
ARGUMENTS="$ARGUMENTS"
|
ARGUMENTS="-g $1 $ARGUMENTS"
|
||||||
fi
|
else
|
||||||
|
ARGUMENTS="-U $ARGUMENTS"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
run /usr/sbin/useradd -r -c "$3" -d "${homedir}" $ARGUMENTS
|
run /usr/sbin/useradd -r -c "$3" -d "${homedir}" $ARGUMENTS
|
||||||
fi
|
|
||||||
if ! /usr/bin/getent group "$1" >> /dev/null; then
|
|
||||||
if [ -x /usr/sbin/groupadd ]; then
|
|
||||||
run /usr/sbin/groupadd -r "$1"
|
|
||||||
else
|
|
||||||
echo "ERROR: groupadd not found!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
elif [ -x "$busybox" ]; then
|
elif [ -x "$busybox" ]; then
|
||||||
/usr/bin/getent group "$1" >> /dev/null || $busybox addgroup -S "$1"
|
/usr/bin/getent group "$1" >> /dev/null || $busybox addgroup -S "$1"
|
||||||
|
|
||||||
if ! /usr/bin/getent passwd "$1" >> /dev/null; then
|
run $busybox adduser -S -H -g "$3" -G "$1" -h "${homedir}" $ARGUMENTS
|
||||||
run $busybox adduser -S -H -g "$3" -G "$1" -h "${homedir}" $ARGUMENTS
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "ERROR: neither useradd nor busybox found!"
|
echo "ERROR: neither useradd nor busybox found!"
|
||||||
exit 1
|
exit 1
|
||||||
@ -109,9 +100,9 @@ else
|
|||||||
m)
|
m)
|
||||||
shift
|
shift
|
||||||
if [ -x /usr/sbin/usermod ] ; then
|
if [ -x /usr/sbin/usermod ] ; then
|
||||||
run /usr/sbin/usermod -a -G $2 $1
|
run /usr/sbin/usermod -a -G "$2" "$1"
|
||||||
elif [ -x "$busybox" ]; then
|
elif [ -x "$busybox" ]; then
|
||||||
run $busybox addgroup $1 $2
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user