From 0aeef5d814af6228008d8df2a2da83faa1f7c037 Mon Sep 17 00:00:00 2001 From: Ivan Rako Date: Thu, 8 Dec 2011 14:43:59 +0100 Subject: [PATCH] fallback na /etc/ldap/slapd.conf --- carnet-tools.7 | 6 ++++-- debian/changelog | 9 ++++++++- functions.sh | 26 ++++++++++++++++---------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/carnet-tools.7 b/carnet-tools.7 index a590d7c..3a7ca2a 100644 --- a/carnet-tools.7 +++ b/carnet-tools.7 @@ -142,10 +142,12 @@ Funkcija je namijenjena koristenju na mjestu gdje se inace poziva predradnje, od \fB. /usr/share/debconf/confmodule\fR nadalje. .TP \fBcp_get_ldap_suffix\fR -Funkcija vraca LDAP suffix kojeg cita iz \fI/etc/ldap/slapd.d/\fR. +Funkcija vraca LDAP suffix kojeg cita iz \fI/etc/ldap/slapd.d/\fR +(ako ne postoji /etc/ldap/slapd.d/, onda cita iz \fI/etc/ldap/slapd.conf\fR). .TP \fBcp_get_ldap_realm\fR -Funkcija vraca LDAP realm kojeg cita iz \fI/etc/ldap/slapd.d/\fR. +Funkcija vraca LDAP suffix kojeg cita iz \fI/etc/ldap/slapd.d/\fR +(ako ne postoji /etc/ldap/slapd.d/, onda cita iz \fI/etc/ldap/slapd.conf\fR). .TP \fBcp_get_mx_domain\fR Funkcija vraca najopcenitiju domenu ciji MX zapis pokazuje diff --git a/debian/changelog b/debian/changelog index a6af08c..8d32522 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,14 @@ +carnet-tools-cn (3.0.2) stable; urgency=low + + * cp_get_ldap_suffix cita iz /etc/ldap/slapd.d, ako on ne postoji, cita + iz /etc/ldap/slapd.conf + + -- Ivan Rako Wed, 07 Dec 2011 13:23:11 +0100 + carnet-tools-cn (3.0.1) stable; urgency=low * Ispravke u cp_get_ldap_suffix (u squeezeu je konfiguracija u - /etc/ldap/slap.d) + /etc/ldap/slapd.d) * Izmijenjen manpage -- Ivan Rako Wed, 07 Dec 2011 13:23:11 +0100 diff --git a/functions.sh b/functions.sh index 96d132f..d63d500 100644 --- a/functions.sh +++ b/functions.sh @@ -448,25 +448,31 @@ cp_get_ldap_suffix() { # but preserving initial state so it could be used afterwards CP_ECHO_RETURN="" - if [ ! -d /etc/ldap/slapd.d/ ]; then - echo "cp_get_ldap_suffix: /etc/ldap/slapd.d/: No such directory" >&2 - return 2 + + if [ -d /etc/ldap/slapd.d/ ]; then + RET="`grep -r olcSuffix /etc/ldap/slapd.d/|awk '{print $2}'`" + elif [ -f /etc/ldap/slapd.conf ]; then + RET="`awk '/^suffix/ { exit } + END { gsub(/"/, "", $2); print $2 }' \ + < /etc/ldap/slapd.conf`" + else + if [ ! -d /etc/ldap/slapd.d/ ]; then + echo "cp_get_ldap_suffix: /etc/ldap/slapd.d/: No such directory" >&2 + return 2 + elif [ ! -f /etc/ldap/slapd.conf ]; then + echo "cp_get_ldap_suffix: /etc/ldap/slapd.conf: No such file" >&2 + return 2 + fi fi - - #RET="`awk '/^suffix/ { exit } - # END { gsub(/"/, "", $2); print $2 }' \ - # < /etc/ldap/slapd.conf`" - RET="`grep -r olcSuffix /etc/ldap/slapd.d/|awk '{print $2}'`" if [ "`echo $RET | sed 's/,/ /g' | wc -w`" -gt 2 ]; then RET="" echo "cp_get_ldap_suffix: Invalid LDAP suffix in /etc/ldap/slapd.d/" >&2 return 2 fi - - [ -z "$RET" ] && echo "cp_get_ldap_suffix: No LDAP suffix in /etc/ldap/slapd.d/" >&2 + [ -z "$RET" ] && echo "cp_get_ldap_suffix: No LDAP suffix in /etc/ldap/slapd.d/ or /etc/ldap/slapd.conf" >&2 [ -z "$echo_return" ] || echo $RET CP_ECHO_RETURN="$echo_return" } -- 1.7.10.4