From 36f2f948cdffe224ae5b40dd9d27c2db082736f3 Mon Sep 17 00:00:00 2001 From: Jacek Migacz Date: Tue, 25 Apr 2023 18:38:09 +0200 Subject: [PATCH] spec: Append 'systemd' to nsswitch.conf only during install Without that patch, on every package upgrade, a 'systemd' is forcibly appended to passwd and group in nsswitch.conf which is not desirable for some customers. It is required until authselect change introduction in RHEL. RHEL-only Resolves: #2176337 --- systemd.spec | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/systemd.spec b/systemd.spec index bf0d095..c82e0d7 100644 --- a/systemd.spec +++ b/systemd.spec @@ -983,24 +983,24 @@ fi %{?ldconfig} function mod_nss() { - if [ -f "$1" ] ; then - # Add nss-systemd to passwd and group - grep -E -q '^(passwd|group):.* systemd' "$1" || + if [ $1 -eq 1 ] && [ -f "$2" ]; then + # Add nss-systemd to passwd (only once, on install) + grep -E -q '^(passwd|group):.* systemd' "$2" || sed -i.bak -r -e ' s/^(passwd|group):(.*)/\1:\2 systemd/ - ' "$1" &>/dev/null || : + ' "$2" &>/dev/null || : fi } FILE="$(readlink /etc/nsswitch.conf || echo /etc/nsswitch.conf)" if [ "$FILE" = "/etc/authselect/nsswitch.conf" ] && authselect check &>/dev/null; then - mod_nss "/etc/authselect/user-nsswitch.conf" + mod_nss $1 "/etc/authselect/user-nsswitch.conf" authselect apply-changes &> /dev/null || : else - mod_nss "$FILE" + mod_nss $1 "$FILE" # also apply the same changes to user-nsswitch.conf to affect # possible future authselect configuration - mod_nss "/etc/authselect/user-nsswitch.conf" + mod_nss $1 "/etc/authselect/user-nsswitch.conf" fi # check if nobody or nfsnobody is defined