From aed895b601c7a176bf1d97e35836dbe6b40e4932 Mon Sep 17 00:00:00 2001 From: Dave Olson Date: Fri, 23 Jun 2017 13:05:34 -0700 Subject: Fixed remove to clean up plugin entries in nsswitch.conf Ticket: CM-16909 Reviewed By: nobody Testing Done: installed, upgraded, removed We weren't removing the mapuser plugins in nsswitch.conf on package remove, now we do. Also cleaned up a bit and use \s instead of [ \t] for whitespace. --- debian/libnss-mapuser.postinst | 9 +++++---- debian/libnss-mapuser.prerm | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'debian') diff --git a/debian/libnss-mapuser.postinst b/debian/libnss-mapuser.postinst index b46e66d..2e9b04f 100644 --- a/debian/libnss-mapuser.postinst +++ b/debian/libnss-mapuser.postinst @@ -11,13 +11,14 @@ case "$1" in # for this package. uid must be first, and mapname must be last # so uids for mapped users return the mapped name, and on the name, # we only want to map if no other matches were found + # handle case where a comment follows the plugin list ( set +e; rgroup=radius_users if [ -e "/etc/nsswitch.conf" ]; then - sed -i -e '/ mapname/b' \ - -e '/^passwd/s/[ \t][ \t]*/&mapuid /' \ - -e '/^passwd.*#/s/#.*/ mapname &/' \ - -e '/^passwd[^#]*$/s/$/ mapname &/' \ + sed -i -e '/\smapname/b' \ + -e '/^passwd:/s/\s\s*/&mapuid /' \ + -e '/^passwd:.*#/s/#.*/ mapname &/' \ + -e '/^passwd:[^#]*$/s/$/ mapname &/' \ /etc/nsswitch.conf fi addgroup --quiet $rgroup 2>&1 | grep -v 'already exists' diff --git a/debian/libnss-mapuser.prerm b/debian/libnss-mapuser.prerm index c9bb6b1..af98f1b 100644 --- a/debian/libnss-mapuser.prerm +++ b/debian/libnss-mapuser.prerm @@ -4,6 +4,12 @@ set -e if [ "$1" = remove ]; then pam-auth-update --package --remove mapuser + # Undo the addition of the plugins + if [ -e "/etc/nsswitch.conf" ]; then + sed -i -e '/^passwd:.*mapuid[ \t]/s/mapuid[ \t]//' \ + -e '/^passwd:.*[ \t]mapname/s/[ \t]mapname//' \ + /etc/nsswitch.conf || true # don't prevent remove on error + fi fi #DEBHELPER# -- cgit v1.2.3