From 93406fd379d3ba184eec2eb664729edef1bca995 Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Sat, 11 Jul 2020 17:08:00 +0300 Subject: [PATCH 1/2] rpm: avoid odd symbols in EOF indicator The last line in this macros was actually "SYSTEMD_INLINE_EOF " with a space at the end, but the shell was instructed to look for a line without space. Macros %sysusers_create_inline and %tmpfiles_create_inline did not have this mistake. An example: [root@rosa-2019 bind-server]# cat /etc/passwd | grep named [root@rosa-2019 bind-server]# cat /tmp/bs systemd-sysusers --replace=/usr/lib/sysusers.d/named.conf - </dev/null 2>&1 || : u named - "BIND DNS Server" /var/lib/named g named - - m named named SYSTEMD_INLINE_EOF [root@rosa-2019 bind-server]# sh /tmp/bs /tmp/bs: line 5: warning: here-document at line 1 delimited by end-of-file (wanted `SYSTEMD_INLINE_EOF') [root@rosa-2019 bind-server]# bash /tmp/bs /tmp/bs: line 5: warning: here-document at line 1 delimited by end-of-file (wanted `SYSTEMD_INLINE_EOF') [root@rosa-2019 bind-server]# bash --version GNU bash, version 5.0.17(1)-release (x86_64-openmandriva-linux-gnu) The user and group named were NOT created! Now I remove the trailing space after "SYSTEMD_INLINE_EOF" and rerun: [root@rosa-2019 bind-server]# sh /tmp/bs [root@rosa-2019 bind-server]# tail -n 1 /etc/group named:x:485:named [root@rosa-2019 bind-server]# The user and group have been created correctly. Signed-off-by: Mikhail Novosyolov --- src/core/macros.systemd.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in index 9b310c48465..e5c41f68e4d 100644 --- a/src/core/macros.systemd.in +++ b/src/core/macros.systemd.in @@ -104,7 +104,7 @@ fi \ %sysusers_create_inline() \ [ -x @bindir@/systemd-sysusers ] && @bindir@/systemd-sysusers - </dev/null 2>&1 || : \ %(cat %2) \ -SYSTEMD_INLINE_EOF \ +SYSTEMD_INLINE_EOF\ %{nil} # This may be used by package installation scripts to create files according to @@ -144,7 +144,7 @@ SYSTEMD_INLINE_EOF \ %{expand:%%{?!__systemd_twoargs_%#:%%{error:This macro requires two arguments}}} \ systemd-tmpfiles --replace=%_tmpfilesdir/%1.conf --create - </dev/null 2>&1 || : \ %(cat %2) \ -SYSTEMD_INLINE_EOF \ +SYSTEMD_INLINE_EOF\ %{nil} %sysctl_apply() \ From 3e6e0856cd98dd091137c4565bd5ccefd16ab832 Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Sat, 11 Jul 2020 17:13:54 +0300 Subject: [PATCH 2/2] rpm: avoid hiding errors and output in *_create_package macros Commit b0ca726585 "rpm: avoid hiding errors from systemd commands" remove hiding errors and output for other macros, but did not do that for %sysusers_create_package and %tmpfiles_create_package. This change syncs their behaviour with %sysusers_create and %tmpfiles_create Signed-off-by: Mikhail Novosyolov --- src/core/macros.systemd.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in index e5c41f68e4d..80827b6ea48 100644 --- a/src/core/macros.systemd.in +++ b/src/core/macros.systemd.in @@ -122,7 +122,7 @@ SYSTEMD_INLINE_EOF\ # %{_sysusersdir}/%{name}.conf %sysusers_create_package() \ %{expand:%%{?!__systemd_twoargs_%#:%%{error:This macro requires two arguments}}} \ -systemd-sysusers --replace=%_sysusersdir/%1.conf - </dev/null 2>&1 || : \ +systemd-sysusers --replace=%_sysusersdir/%1.conf - </dev/null 2>&1 || : \ +systemd-tmpfiles --replace=%_tmpfilesdir/%1.conf --create - <