From c81af58db038865f2ff6eaa21f9ac24d631cab909db9f5229e535ed065473882 Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Thu, 11 Feb 2021 12:54:07 +0000 Subject: [PATCH] Accepting request 871208 from home:kukuk:etc - Use systemd-sysusers only if /proc is mounted, don't require it - Set --replace option for systemd-sysusers OBS-URL: https://build.opensuse.org/request/show/871208 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=40 --- macros.sysusers | 9 +++++++-- sysuser-tools.changes | 10 ++++++++++ sysuser-tools.spec | 2 +- sysusers-generate-pre | 2 +- sysusers2shadow.sh | 7 ++++--- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/macros.sysusers b/macros.sysusers index d96156c..394c4af 100644 --- a/macros.sysusers +++ b/macros.sysusers @@ -7,7 +7,12 @@ # # add %sysusers_requires in the package section # -# add "%sysusers_generate_pre " to build section +# add "%sysusers_generate_pre []" to build section +# +## is the source file as defined in the spec file header +## is just a random name, th output file will be ".pre" +## is the name of the configuration file as stored in +## /usr/lib/sysusers.d/ # # add "%pre -f .pre" to spec file # @@ -16,4 +21,4 @@ %sysusers_requires Requires(pre): sysuser-shadow %sysusers_generate_pre() \ -%{_prefix}/lib/rpm/sysusers-generate-pre "%1" > "%2".pre +%{_prefix}/lib/rpm/sysusers-generate-pre "%1" "%3" > "%2".pre diff --git a/sysuser-tools.changes b/sysuser-tools.changes index 6ec3470..9bae581 100644 --- a/sysuser-tools.changes +++ b/sysuser-tools.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Fri Jan 29 13:36:08 UTC 2021 - Thorsten Kukuk + +- Use systemd-sysusers only if /proc is mounted, don't require it + +------------------------------------------------------------------- +Wed Jan 27 13:02:13 UTC 2021 - Thorsten Kukuk + +- Set --replace option for systemd-sysusers + ------------------------------------------------------------------- Wed Jan 20 15:06:51 UTC 2021 - Thorsten Kukuk diff --git a/sysuser-tools.spec b/sysuser-tools.spec index 0a9f429..a8505a0 100644 --- a/sysuser-tools.spec +++ b/sysuser-tools.spec @@ -38,7 +38,7 @@ Generate auto provides for system users. %package -n sysuser-shadow Summary: Tool to execute sysusers.d with shadow utilities Group: System/Packages -Requires(pre): (/usr/sbin/useradd or busybox or /usr/bin/systemd-sysusers) +Requires(pre): (/usr/sbin/useradd or busybox) # prefer original shadow over busybox by default Suggests: shadow diff --git a/sysusers-generate-pre b/sysusers-generate-pre index 4cc2620..9d6897e 100644 --- a/sysusers-generate-pre +++ b/sysusers-generate-pre @@ -1,6 +1,6 @@ #!/bin/sh # pass systemd sysusers config paths as argument to this script. -echo '/usr/sbin/sysusers2shadow <<"EOF" || [ -f /.buildenv ]' +echo "/usr/sbin/sysusers2shadow $3 <<\"EOF\" || [ -f /.buildenv ]" grep -he '^[ugmr]' "$@" echo 'EOF' diff --git a/sysusers2shadow.sh b/sysusers2shadow.sh index 08a7209..ebb9d50 100644 --- a/sysusers2shadow.sh +++ b/sysusers2shadow.sh @@ -7,10 +7,11 @@ run() { "$@" } -if [ -x /usr/bin/systemd-sysusers ]; then +if [ -x /usr/bin/systemd-sysusers ] && [ -e /proc/version ]; then + test -n "$1" && REPLACE_ARG="--replace=/usr/lib/sysusers.d/$1" ||: # Use systemd-sysusers and let it read the input directly from stdin - /usr/bin/systemd-sysusers - + /usr/bin/systemd-sysusers $REPLACE_ARG - # We need to clear the nscd cache, as systemd-sysusers could have # triggered a negative cache entry if [ -x /usr/sbin/nscd ]; then @@ -29,7 +30,7 @@ else eval set -- $LINE case "${1-}" in \#*|"") - ;; + ;; g) shift ARGUMENTS="$1"