diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-24 20:58:57 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-24 20:58:57 +0200 |
commit | e8d68d4caeba97977691e20baf84469d5e85b8e5 (patch) | |
tree | e050b06214d96c992a9d166a2916a333264af1b0 /debian/libnss-ldapd.postinst | |
parent | e81e779ed3b97a0e8473d5b4dcb66457e5759e33 (diff) |
do something special for setting the uri parameter because it may be speicified multiple times
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@422 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'debian/libnss-ldapd.postinst')
-rw-r--r-- | debian/libnss-ldapd.postinst | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/debian/libnss-ldapd.postinst b/debian/libnss-ldapd.postinst index 52598a6..472c111 100644 --- a/debian/libnss-ldapd.postinst +++ b/debian/libnss-ldapd.postinst @@ -10,6 +10,7 @@ cfg_set() parameter="$1" value="$2" # make matching of spaces better in parameter + # this is complicated becase of the "base [map] dn" keyword param_re=`echo "$parameter" | sed -s 's#[[:space:]][[:space:]]*#[[:space:]][[:space:]]*#g'` # check if the parameter is defined replace=`sed -n 's/^\('"$param_re"'\)[[:space:]]*\([^[:space:]]*\|".*"\)[[:space:]]*$/\1/ip' "$CONFFILE" | head -n 1` @@ -46,6 +47,30 @@ cfg_disable() return 0 } +# set the list of uris +cfg_uris() +{ + uris="$1" + # escape all uri directives + sed -i 's/^uri /_uri_ /i' $CONFFILE + # set the uri options + echo "$uris" | sed 's/ */\n/g' | while read uri + do + if grep -qi '^_uri_ ' $CONFFILE + then + # escape uri for use in regexp replacement + uri=`echo "$uri" | sed -s 's#\\\#\\\\\\\#g;s#|#\\\|#g;s#&#\\\&#g'` + # replace the first occurrence of _uri_ + sed -i '1,/^_uri_ / s|^_uri_ .*$|uri '"$uri"'|i' "$CONFFILE" + else + # append new uri + echo "uri $uri" >> $CONFFILE + fi + done + # comment out the remaining escaped uris + sed -i 's/^_uri_ /#uri /' $CONFFILE +} + # editing nsswitch.conf seems to be ok # http://lists.debian.org/debian-devel/2007/02/msg00076.html @@ -140,7 +165,7 @@ then create_config # set server uri db_get libnss-ldapd/ldap-uris - cfg_set uri "$RET" + cfg_uris "$RET" # set search base db_get libnss-ldapd/ldap-base cfg_set base "$RET" |