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
This commit is contained in:
Jacek Migacz 2023-04-25 18:38:09 +02:00
parent 96f92a96d3
commit 36f2f948cd

View File

@ -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