diff --git a/disable-systemd-sysusers.patch b/disable-systemd-sysusers.patch index 1d73d4b..b20c46e 100644 --- a/disable-systemd-sysusers.patch +++ b/disable-systemd-sysusers.patch @@ -1,7 +1,5 @@ -# 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 +--- sysusers2shadow.sh.old 2024-07-04 14:24:01.013092683 +0200 ++++ sysusers2shadow.sh 2024-07-04 14:28:06.701540250 +0200 @@ -7,14 +7,6 @@ "$@" } @@ -14,10 +12,10 @@ - # 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 @@ + for i in /bin/busybox /usr/bin/busybox; do [ -x "$i" ] && busybox=$i; done +@@ -126,4 +118,3 @@ ;; esac done diff --git a/sysuser-tools.changes b/sysuser-tools.changes index 1bd8c99..2e143b6 100644 --- a/sysuser-tools.changes +++ b/sysuser-tools.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Jul 1 15:01:19 UTC 2024 - Johannes Weberhofer + +- Allow setting of UID:GID for as defined in sysusers.d + ------------------------------------------------------------------- Tue Nov 7 10:07:20 UTC 2023 - Dominique Leuenberger diff --git a/sysuser-tools.spec b/sysuser-tools.spec index 6463c79..2c87d22 100644 --- a/sysuser-tools.spec +++ b/sysuser-tools.spec @@ -1,7 +1,7 @@ # # spec file for package sysuser-tools # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: sysuser-tools -Version: 3.2 +Version: 3.3 Release: 0 Summary: Auto provides for system users License: MIT diff --git a/sysusers2shadow.sh b/sysusers2shadow.sh index 5007e44..52d8aa4 100644 --- a/sysusers2shadow.sh +++ b/sysusers2shadow.sh @@ -15,7 +15,6 @@ if [ -x /usr/bin/systemd-sysusers ] && [ -e /proc/version ]; then # 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= for i in /bin/busybox /usr/bin/busybox; do [ -x "$i" ] && busybox=$i; done @@ -48,9 +47,23 @@ else u) shift ARGUMENTS="$1" - if [ -n "${2-}" ] && [ "$2" != "-" ]; then - ARGUMENTS="-u $2 $ARGUMENTS" + + # Split user and Group id + userGrouArr=(${2//:/ }) + USER_ID=${userGrouArr[0]} + GROUP_ID=${userGrouArr[1]} + + if [ -n "$USER_ID" ] && [ "$USER_ID" != "-" ]; then + ARGUMENTS="-u $USER_ID $ARGUMENTS" 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 '-' if [ "${4:--}" != "-" ]; then homedir="$4" @@ -69,7 +82,7 @@ else if /usr/bin/getent group "$1" >> /dev/null; then ARGUMENTS="-g $1 $ARGUMENTS" else - ARGUMENTS="-U $ARGUMENTS" + ARGUMENTS="$ARGUMENTS" fi run /usr/sbin/useradd -r -c "$3" -d "${homedir}" $ARGUMENTS