diff --git a/nss-mdns.spec b/nss-mdns.spec index 9f9640b..1c4cf60 100644 --- a/nss-mdns.spec +++ b/nss-mdns.spec @@ -39,22 +39,49 @@ rm -rf $RPM_BUILD_ROOT %post %{?ldconfig} -# sed-fu to add mdns4_minimal to the hosts line of /etc/nsswitch.conf -if [ -f /etc/nsswitch.conf ] ; then - sed -i.bak ' - /^hosts:/ !b - /\/ b - s/\([[:blank:]]\+\)dns\>/\1mdns4_minimal [NOTFOUND=return] dns/g - ' /etc/nsswitch.conf + +function mod_nss() { + if [ -f "$1" ] ; then + # sed-fu to add mdns4_minimal to the hosts line of /etc/nsswitch.conf + sed -i.bak ' + /^hosts:/ !b + /\/ 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 %preun -# sed-fu to remove mdns4_minimal from the hosts line of /etc/nsswitch.conf -if [ "$1" -eq 0 -a -f /etc/nsswitch.conf ] ; then - sed -i.bak ' - /^hosts:/ !b - s/[[:blank:]]\+mdns\(4\|6\)\?\(_minimal\( \[NOTFOUND=return\]\)\?\)\?//g - ' /etc/nsswitch.conf +function mod_nss() { + if [ -f "$1" ] ; then + # sed-fu to remove mdns4_minimal from the hosts line of /etc/nsswitch.conf + sed -i.bak ' + /^hosts:/ !b + 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 %ldconfig_postun