5
# find the names of services that are configured to use LDAP
6
# Note: this function is in libnss-ldapd.config and libnss-ldapd.postrm
10
's/^[[:space:]]*\([a-z]*\)[[:space:]]*:.*[[:space:]]ldap\([[:space:]].*\)\?/\1/p' \
14
# check whether the name is configure to do lookups through
16
# Note: this function is in libnss-ldapd.postinst, libnss-ldapd.postrm
17
# and libpam-ldapd.postinst
21
grep -q '^[[:space:]]*'$name'[[:space:]]*:.*ldap.*' /etc/nsswitch.conf
5
24
# remove NSS lookups though LDAP for the specified service
6
# Note: this function is in both libnss-ldapd.postinst and libnss-ldapd.postrm
25
# Note: this function is in libnss-ldapd.postinst and libnss-ldapd.postrm
10
29
# these functions also remove the lookup result handling part
11
30
# of the ldap entry (see nsswitch.conf(5))
12
if grep -q '^'$name':.*ldap.*' /etc/nsswitch.conf
31
if nss_is_enabled "$name"
14
33
echo "/etc/nsswitch.conf: disable LDAP lookups for $name" >&2
15
if [ -n "`sed -n '/^'$name':[[:space:]]*ldap[[:space:]]*\(\[[^]]*\]\)*[[:space:]]*$/p' /etc/nsswitch.conf`" ]
34
if [ -n "`sed -n '/^[[:space:]]*'$name'[[:space:]]*:[[:space:]]*ldap[[:space:]]*\(\[[^]]*\]\)*[[:space:]]*$/p' /etc/nsswitch.conf`" ]
17
36
# the name service only maps to ldap, remove the whole line
18
sed -i '/^'$name':[[:space:]]*ldap[[:space:]]*\(\[[^]]*\]\)*[[:space:]]*$/d' /etc/nsswitch.conf
37
sed -i '/^[[:space:]]*'$name'[[:space:]]*:[[:space:]]*ldap[[:space:]]*\(\[[^]]*\]\)*[[:space:]]*$/d' /etc/nsswitch.conf
20
39
# remove ldap part from existing line, keeping other methods intact
21
40
# TODO: remove trailing space
22
sed -i 's/^\('$name':.*\)ldap[[:space:]]*\(\[[^]]*\]\)*[[:space:]]*\(.*\)$/\1\3/' /etc/nsswitch.conf
41
sed -i 's/^\([[:space:]]*'$name'[[:space:]]*:.*\)ldap[[:space:]]*\(\[[^]]*\]\)*[[:space:]]*\(.*\)$/\1\3/' /etc/nsswitch.conf
43
# invalidate nscd cache
44
nscd -i "$name" > /dev/null 2>&1 || true
30
51
if ( [ "$1" = "remove" ] || [ "$1" = "purge" ] )
32
53
# check which naming services are configured
33
configured=`sed -n 's/^\([a-z]*\):.*[[:space:]]ldap\([[:space:]].*\)\?/\1/p' /etc/nsswitch.conf`
54
configured=`nss_list_configured`
34
55
if [ -n "$configured" ]
36
57
# if we have debconf, use debconf to ask, otherwise just shout
56
77
# re-check which services are left enabled
57
configured=`sed -n 's/^\([a-z]*\):.*[[:space:]]ldap\([[:space:]].*\)\?/\1/p' /etc/nsswitch.conf`
78
configured=`nss_list_configured`
59
80
# check if ldap is still configured
60
81
if [ -n "$configured" ]