This file is indexed.

postrm is in libnss-ldapd 0.8.13-3.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#!/bin/sh

set -e

# find the names of services that are configured to use LDAP
# Note: this function is in libnss-ldapd.config and libnss-ldapd.postrm
nss_list_configured()
{
  sed -n \
      's/^[[:space:]]*\([a-z]*\)[[:space:]]*:.*[[:space:]]ldap\([[:space:]].*\)\?/\1/p' \
      /etc/nsswitch.conf \
    | xargs
}

# check whether the name is configure to do lookups through
# LDAP
# Note: this function is in libnss-ldapd.postinst and libnss-ldapd.postrm
nss_is_enabled()
{
  name="$1"
  grep -q '^[[:space:]]*'$name'[[:space:]]*:.*ldap.*' /etc/nsswitch.conf
}

# remove NSS lookups though LDAP for the specified service
# Note: this function is in libnss-ldapd.postinst and libnss-ldapd.postrm
nss_disable()
{
  name="$1"
  # these functions also remove the lookup result handling part
  # of the ldap entry (see nsswitch.conf(5))
  if nss_is_enabled "$name"
  then
    echo "/etc/nsswitch.conf: disable LDAP lookups for $name" >&2
    if [ -n "`sed -n '/^[[:space:]]*'$name'[[:space:]]*:[[:space:]]*ldap[[:space:]]*\(\[[^]]*\]\)*[[:space:]]*$/p' /etc/nsswitch.conf`" ]
    then
      # the name service only maps to ldap, remove the whole line
      sed -i '/^[[:space:]]*'$name'[[:space:]]*:[[:space:]]*ldap[[:space:]]*\(\[[^]]*\]\)*[[:space:]]*$/d' /etc/nsswitch.conf
    else
      # remove ldap part from existing line, keeping other methods intact
      # TODO: remove trailing space
      sed -i 's/^\([[:space:]]*'$name'[[:space:]]*:.*\)ldap[[:space:]]*\(\[[^]]*\]\)*[[:space:]]*\(.*\)$/\1\3/' /etc/nsswitch.conf
    fi
    # invalidate nscd cache
    nscd -i "$name" > /dev/null 2>&1 || true
  fi
  # we're done
  return 0
}

# offer to remove ldap from nsswitch.conf
if ( [ "$1" = "remove" ] || [ "$1" = "purge" ] )
then
  # check which naming services are configured
  configured=`nss_list_configured`
  if [ -n "$configured" ]
  then
    # if we have debconf, use debconf to ask, otherwise just shout
    if [ -e /usr/share/debconf/confmodule ]
    then
      # ask with debconf
      . /usr/share/debconf/confmodule
      db_title "Removing libnss-ldapd"
      db_subst libnss-ldapd/clean_nsswitch services "`echo $configured | sed 's/[[:space:]][[:space:]]*/, /g'`"
      db_fset libnss-ldapd/clean_nsswitch seen false
      if db_input high libnss-ldapd/clean_nsswitch
      then
        db_go
        db_get libnss-ldapd/clean_nsswitch
        if [ "$RET" = "true" ]
        then
          for n in $configured
          do
            nss_disable $n
          done
        fi
      fi
      # re-check which services are left enabled
      configured=`nss_list_configured`
    fi
    # check if ldap is still configured
    if [ -n "$configured" ]
    then
      echo "WARNING: LDAP is still configured in /etc/nsswitch.conf" >&2
    fi
  fi
fi

# call ldconfig to signal the removal of our NSS library
if [ "$1" = "remove" ]
then
  ldconfig
fi

# Automatically added by dh_makeshlibs
if [ "$1" = "remove" ]; then
	ldconfig
fi
# End automatically added section
# Automatically added by dh_installdebconf
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
	. /usr/share/debconf/confmodule
	db_purge
fi
# End automatically added section