diff --git a/sysuser-tools.changes b/sysuser-tools.changes index 2c28104..cc54f6d 100644 --- a/sysuser-tools.changes +++ b/sysuser-tools.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Thu Jul 15 06:45:15 UTC 2021 - Thorsten Kukuk + +- Use /bin/bash for sysusers-generate-pre + +------------------------------------------------------------------- +Tue Jun 29 13:08:44 UTC 2021 - Dan Čermák + +- Remove usage of grep from sysusers-generate-pre +- Add a simple test of sysusers-generate-pre to %check + ------------------------------------------------------------------- Mon Jun 21 09:56:17 UTC 2021 - Dominique Leuenberger diff --git a/sysuser-tools.spec b/sysuser-tools.spec index 0a1962b..7441409 100644 --- a/sysuser-tools.spec +++ b/sysuser-tools.spec @@ -31,6 +31,7 @@ BuildArch: noarch Requires: sysuser-shadow #!BuildIgnore: sysuser-shadow #!BuildIgnore: sysuser-tools +BuildRequires: diffutils %description Generate auto provides for system users. @@ -65,6 +66,30 @@ install -D -m 755 %{SOURCE2} %{buildroot}%{_prefix}/lib/rpm/sysusers-generate-pr install -D -m 644 %{SOURCE3} %{buildroot}%{_rpmmacrodir}/macros.sysusers install -D -m 755 %{SOURCE4} %{buildroot}%{_sbindir}/sysusers2shadow +%check +mkdir -p subdir +cat < subdir/me.conf +# Type Name ID GECOS [HOME] Shell + u me - "myself" /dev/null +m me nogroup +# foobar + g asdf + z welp invalid +EOF + +cat < expected-account-pre +/usr/sbin/sysusers2shadow me.conf <<"EOF" || [ -f /.buildenv ] +u me - "myself" /dev/null +m me nogroup +g asdf +EOF +EOFF + +# copy pasta from macros.sysusers because the script sysusers-generate-pre is not in /usr/lib/rpm yet +sh %{SOURCE2} $(pwd)/subdir/me.conf me.conf > account.pre + +diff account.pre expected-account-pre + %files %defattr(-,root,root) %{_rpmmacrodir}/macros.sysusers diff --git a/sysusers-generate-pre b/sysusers-generate-pre index d664bcb..824ba71 100644 --- a/sysusers-generate-pre +++ b/sysusers-generate-pre @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash # pass systemd sysusers config paths as argument to this script. echo "/usr/sbin/sysusers2shadow $2 <<\"EOF\" || [ -f /.buildenv ]" -grep -he '^[ugmr]' "$1" +(while read -r line; do if [[ $line =~ ^\s*[ugmr] ]]; then echo "$line"; fi; done) < "$1" echo 'EOF'