From fc4d3185e41742984adc39a22f53ee1c96ff1e86 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 5 Jan 2009 16:49:01 +0100 Subject: [PATCH] ldap: Use quotes in more places. This is more robust and allows spaces in more places (in particular in backupd_dir and theoretically in vserver names). --- handlers/ldap.in | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/handlers/ldap.in b/handlers/ldap.in index 0868eac..d929252 100644 --- a/handlers/ldap.in +++ b/handlers/ldap.in @@ -45,7 +45,7 @@ fi status="ok" function make_backup() { - vsname=$1 + vsname="$1" if [ -z "$vsname" ]; then info "Running on host" vdir="" @@ -56,12 +56,12 @@ function make_backup() { vexec="$VSERVER $vsname exec" fi - dumpdir=`interpolate "$backupdir" "$vsname"` + dumpdir="`interpolate "$backupdir" "$vsname"`" info "Backing up to dir '$dumpdir'" - [ -f $vdir$conf ] || fatal "slapd config file ($conf) not found" - [ -d $dumpdir ] || mkdir -p $dumpdir - [ -d $dumpdir ] || fatal "Backup directory '$dumpdir'" + [ -f "$vdir$conf" ] || fatal "slapd config file ($conf) not found" + [ -d "$dumpdir" ] || mkdir -p "$dumpdir" + [ -d "$dumpdir" ] || fatal "Backup directory '$dumpdir'" dbsuffixes=(`@AWK@ 'BEGIN {OFS=":"} /[:space:]*^database[:space:]*\w*/ {db=$2}; /^[:space:]*suffix[:space:]*\w*/ {if (db=="bdb"||db=="hdb"||db="ldbm") print db,$2}' $vdir$conf|@SED@ -e 's/[" ]//g'`) @@ -69,7 +69,7 @@ function make_backup() { if [ "$ldif" == "yes" ]; then if [ "$databases" == 'all' ]; then - dbcount=`grep '^database' $vdir$conf | wc -l` + dbcount=`grep '^database' "$vdir$conf" | wc -l` let "dbcount = dbcount - 1" databases=`seq 0 $dbcount`; fi @@ -111,15 +111,15 @@ function make_backup() { if [ "$compress" == "yes" ]; then ext=".gz" fi - touch $dumpdir/$dbsuffix.ldif$ext - if [ ! -f $dumpdir/$dbsuffix.ldif$ext ]; then + touch "$dumpdir/$dbsuffix.ldif$ext" + if [ ! -f "$dumpdir/$dbsuffix.ldif$ext" ]; then fatal "Couldn't create ldif dump file: $dumpdir/$dbsuffix.ldif$ext" fi if [ "$compress" == "yes" ]; then - execstr="$execstr | $GZIP > $dumpdir/$dbsuffix.ldif.gz" + execstr="$execstr | $GZIP > \"$dumpdir/$dbsuffix.ldif.gz\"" else - execstr="$execstr > $dumpdir/$dbsuffix.ldif" + execstr="$execstr > \"$dumpdir/$dbsuffix.ldif\"" fi # Run inside the vserver if needed execstr="$vexec $execstr" @@ -145,7 +145,7 @@ function make_backup() { if [ $usevserver = yes ]; then for vserver in $vsnames; do - make_backup $vserver + make_backup "$vserver" done else make_backup "" -- 2.30.2