POSTIN
/bin/sh
/bin/chmod 0440 /etc/sudoers || :
#
# rhbz#846631: fix permissions on nsswitch.conf
#
if [ "$(stat -c '%a' "/etc/nsswitch.conf")" = "600" ]; then
chmod 0644 "/etc/nsswitch.conf" || :
fi
#
# rhbz#841070: remove the old line, the new one won't be matched
# by the old regexp and won't be deleted on upgrade
#
if grep -q '^sudoers: files ldap$' "/etc/nsswitch.conf"; then
sed -c -i '/^sudoers: files ldap/ d' "/etc/nsswitch.conf"
restorecon "/etc/nsswitch.conf"
fi
if ! grep -q '^[[:space:]]*sudoers:' "/etc/nsswitch.conf"; then
# No "sudoers:" line in nsswitch.conf, add a default one
echo 'sudoers: files ldap' >> "/etc/nsswitch.conf"
restorecon "/etc/nsswitch.conf"
fi
POSTUN
/bin/sh
# Remove the "sudoers:" line from nsswitch.conf if it's not modified
# and only when we are erasing (not upgrading) the package!
if [ $1 = 0 ] && grep -q '^sudoers: files ldap$' "/etc/nsswitch.conf"; then
sed -c -i '/^sudoers: files ldap$/ d' "/etc/nsswitch.conf"
restorecon "/etc/nsswitch.conf"
fi