use authselect to change nsswitch.conf if available

epel8
Pavel Březina 5 years ago committed by Adam Goode
parent 47734c92fd
commit 923eb4834c

@ -39,22 +39,49 @@ rm -rf $RPM_BUILD_ROOT
%post %post
%{?ldconfig} %{?ldconfig}
# sed-fu to add mdns4_minimal to the hosts line of /etc/nsswitch.conf
if [ -f /etc/nsswitch.conf ] ; then function mod_nss() {
sed -i.bak ' if [ -f "$1" ] ; then
/^hosts:/ !b # sed-fu to add mdns4_minimal to the hosts line of /etc/nsswitch.conf
/\<mdns\(4\|6\)\?\(_minimal\)\?\>/ b sed -i.bak '
s/\([[:blank:]]\+\)dns\>/\1mdns4_minimal [NOTFOUND=return] dns/g /^hosts:/ !b
' /etc/nsswitch.conf /\<mdns\(4\|6\)\?\(_minimal\)\?\>/ b
s/\([[:blank:]]\+\)dns\>/\1mdns4_minimal [NOTFOUND=return] dns/g
' "$1"
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"
authselect apply-changes &> /dev/null || :
else
mod_nss "$FILE"
# also apply the same changes to user-nsswitch.conf to affect
# possible future authselect configuration
mod_nss "/etc/authselect/user-nsswitch.conf"
fi fi
%preun %preun
# sed-fu to remove mdns4_minimal from the hosts line of /etc/nsswitch.conf function mod_nss() {
if [ "$1" -eq 0 -a -f /etc/nsswitch.conf ] ; then if [ -f "$1" ] ; then
sed -i.bak ' # sed-fu to remove mdns4_minimal from the hosts line of /etc/nsswitch.conf
/^hosts:/ !b sed -i.bak '
s/[[:blank:]]\+mdns\(4\|6\)\?\(_minimal\( \[NOTFOUND=return\]\)\?\)\?//g /^hosts:/ !b
' /etc/nsswitch.conf s/[[:blank:]]\+mdns\(4\|6\)\?\(_minimal\( \[NOTFOUND=return\]\)\?\)\?//g
' "$1"
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"
authselect apply-changes &> /dev/null || :
else
mod_nss "$FILE"
# also apply the same changes to user-nsswitch.conf to affect
# possible future authselect configuration
mod_nss "/etc/authselect/user-nsswitch.conf"
fi fi
%ldconfig_postun %ldconfig_postun

Loading…
Cancel
Save