3
0
forked from pool/sysuser-tools
Ana Guerrero 2023-07-27 14:50:33 +00:00 committed by Git OBS Bridge
commit fdfe70f3e4
5 changed files with 139 additions and 87 deletions

View File

@ -0,0 +1,24 @@
# Disable usage of systemd-sysusers for SLE15 to stay compatible
--- sysusers2shadow.sh.old 2021-09-08 15:06:18.000000000 +0200
+++ sysusers2shadow.sh 2021-11-26 10:37:20.911541368 +0100
@@ -7,14 +7,6 @@
"$@"
}
-if [ -x /usr/bin/systemd-sysusers ] && [ -e /proc/version ]; then
-
- if [ -n "$1" ] && [ "$1" != "%3" ]; then
- REPLACE_ARG="--replace=/usr/lib/sysusers.d/$1" ||:
- fi
- # Use systemd-sysusers and let it read the input directly from stdin
- run /usr/bin/systemd-sysusers $REPLACE_ARG -
-else
# Absolute path to busybox, if found
busybox=
@@ -115,4 +115,3 @@
;;
esac
done
-fi

View File

@ -18,7 +18,7 @@
# #
### ###
%sysusers_requires Requires(pre): sysuser-shadow >= 3.1 %sysusers_requires Requires(pre): sysuser-shadow >= 3.2
%sysusers_generate_pre() \ %sysusers_generate_pre() \
%{_prefix}/lib/rpm/sysusers-generate-pre "%1" "%3" >> "%2".pre %{_prefix}/lib/rpm/sysusers-generate-pre "%1" "%3" >> "%2".pre

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Tue Jul 18 18:18:18 UTC 2023 - olaf@aepfle.de
- Version 3.2
- update sysusers_requires to request sysuser-shadow 3.2
- Use TAB consistently for indention in sysusers2shadow.sh
- This pkg needs to follow behavior which is described in sysusers.d(5).
Always create a system group of the same name as the system user,
even if the user already exists. (bsc#1205161, bsc#1207778, bsc#1213240)
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Jul 17 17:17:17 UTC 2023 - olaf@aepfle.de Mon Jul 17 17:17:17 UTC 2023 - olaf@aepfle.de
@ -15,6 +25,12 @@ Tue Feb 1 12:58:30 UTC 2022 - Dirk Müller <dmueller@suse.com>
- invoke bash for bash scripts (bsc#1195391) - invoke bash for bash scripts (bsc#1195391)
-------------------------------------------------------------------
Fri Nov 26 09:43:02 UTC 2021 - Thorsten Kukuk <kukuk@suse.com>
- Disable systemd-sysuser on SLE15 to stay compatible
(disable-systemd-sysusers.patch)
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Sep 8 09:12:05 UTC 2021 - Thorsten Kukuk <kukuk@suse.com> Wed Sep 8 09:12:05 UTC 2021 - Thorsten Kukuk <kukuk@suse.com>

View File

@ -17,7 +17,7 @@
Name: sysuser-tools Name: sysuser-tools
Version: 3.1 Version: 3.2
Release: 0 Release: 0
Summary: Auto provides for system users Summary: Auto provides for system users
License: MIT License: MIT
@ -27,6 +27,7 @@ Source1: sysusers.attr
Source2: sysusers-generate-pre Source2: sysusers-generate-pre
Source3: macros.sysusers Source3: macros.sysusers
Source4: sysusers2shadow.sh Source4: sysusers2shadow.sh
Patch: disable-systemd-sysusers.patch
BuildArch: noarch BuildArch: noarch
Requires: sysuser-shadow Requires: sysuser-shadow
#!BuildIgnore: sysuser-shadow #!BuildIgnore: sysuser-shadow
@ -56,6 +57,9 @@ and groups from it like systemd-sysusers would do.
%prep %prep
%setup -qcT %setup -qcT
%if 0%{?suse_version} <= 1500
patch < %_sourcedir/disable-systemd-sysusers.patch %_sourcedir/sysusers2shadow.sh
%endif
%build %build

View File

@ -9,100 +9,108 @@ run() {
if [ -x /usr/bin/systemd-sysusers ] && [ -e /proc/version ]; then if [ -x /usr/bin/systemd-sysusers ] && [ -e /proc/version ]; then
if [ -n "$1" ] && [ "$1" != "%3" ]; then if [ -n "$1" ] && [ "$1" != "%3" ]; then
REPLACE_ARG="--replace=/usr/lib/sysusers.d/$1" ||: REPLACE_ARG="--replace=/usr/lib/sysusers.d/$1" ||:
fi fi
# Use systemd-sysusers and let it read the input directly from stdin # Use systemd-sysusers and let it read the input directly from stdin
run /usr/bin/systemd-sysusers $REPLACE_ARG - run /usr/bin/systemd-sysusers $REPLACE_ARG -
else else
# Absolute path to busybox, if found # Absolute path to busybox, if found
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 LINE while read LINE
do do
# "eval set" to do proper splitting while respecting quotes # "eval set" to do proper splitting while respecting quotes
eval set -- $LINE eval set -- $LINE
case "${1-}" in case "${1-}" in
\#*|"") \#*|"")
;;
g)
shift
ARGUMENTS="$1"
if [ -n "${2-}" ] && [ "$2" != "-" ]; then
ARGUMENTS="-g $2 $ARGUMENTS"
fi
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
run $busybox addgroup -S $ARGUMENTS
else
echo "ERROR: neither groupadd nor busybox found!"
exit 1
fi
fi
;; ;;
u) g)
shift shift
ARGUMENTS="$1" ARGUMENTS="$1"
if [ -n "${2-}" ] && [ "$2" != "-" ]; then if [ -n "${2-}" ] && [ "$2" != "-" ]; then
ARGUMENTS="-u $2 $ARGUMENTS" ARGUMENTS="-g $2 $ARGUMENTS"
fi
homedir="/" # If null, empty or '-'
if [ "${4:--}" != "-" ]; then
homedir="$4"
fi
# Set shell only if not null, empty nor '-'
if [ "${5:--}" != "-" ]; then
ARGUMENTS="$ARGUMENTS -s $5"
else
ARGUMENTS="$ARGUMENTS -s /usr/sbin/nologin"
fi
if [ -x /usr/sbin/useradd ]; then
if ! /usr/bin/getent passwd "$1" >> /dev/null; then
# this is useradd/shadow specific
if /usr/bin/getent group "$1" >> /dev/null; then
ARGUMENTS="-g $1 $ARGUMENTS"
else
ARGUMENTS="-U $ARGUMENTS"
fi fi
run /usr/sbin/useradd -r -c "$3" -d "${homedir}" $ARGUMENTS if ! /usr/bin/getent group "$1" >> /dev/null; then
fi if [ -x "/usr/sbin/groupadd" ]; then
elif [ -x "$busybox" ]; then run /usr/sbin/groupadd -r $ARGUMENTS
/usr/bin/getent group "$1" >> /dev/null || $busybox addgroup -S "$1" elif [ -x "$busybox" ]; then
run $busybox addgroup -S $ARGUMENTS
else
echo "ERROR: neither groupadd nor busybox found!"
exit 1
fi
fi
;;
u)
shift
ARGUMENTS="$1"
if [ -n "${2-}" ] && [ "$2" != "-" ]; then
ARGUMENTS="-u $2 $ARGUMENTS"
fi
homedir="/" # If null, empty or '-'
if [ "${4:--}" != "-" ]; then
homedir="$4"
fi
if ! /usr/bin/getent passwd "$1" >> /dev/null; then # Set shell only if not null, empty nor '-'
run $busybox adduser -S -H -g "$3" -G "$1" -h "${homedir}" $ARGUMENTS if [ "${5:--}" != "-" ]; then
fi ARGUMENTS="$ARGUMENTS -s $5"
else else
echo "ERROR: neither useradd nor busybox found!" ARGUMENTS="$ARGUMENTS -s /usr/sbin/nologin"
exit 1 fi
fi
if [ -x /usr/sbin/useradd ]; then
if ! /usr/bin/getent passwd "$1" >> /dev/null; then
# this is useradd/shadow specific
if /usr/bin/getent group "$1" >> /dev/null; then
ARGUMENTS="-g $1 $ARGUMENTS"
else
ARGUMENTS="-U $ARGUMENTS"
fi
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
/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
fi
else
echo "ERROR: neither useradd nor busybox found!"
exit 1
fi
;; ;;
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
fi fi
;; ;;
r) r)
echo "range option ignored: \"$LINE\"" echo "range option ignored: \"$LINE\""
;; ;;
*) *)
echo "Syntax Error: \"$LINE\"" echo "Syntax Error: \"$LINE\""
exit 1 exit 1
;; ;;
esac esac
done done
fi fi