andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 6 months ago
Clone

Blame SOURCES/0050-Ticket-48254-Shell-CLI-fails-with-usage-errors-if-an.patch

a2f18f
From 94bde9f69f10e0811e261b5d53e5bebfcd891820 Mon Sep 17 00:00:00 2001
a2f18f
From: Noriko Hosoi <nhosoi@redhat.com>
a2f18f
Date: Tue, 25 Aug 2015 11:48:31 -0700
a2f18f
Subject: [PATCH 50/52] Ticket #48254 - Shell CLI fails with usage errors if an
a2f18f
 argument containing white spaces is given
a2f18f
a2f18f
Description: In addition to the patch:
a2f18f
  Ticket #48254 - CLI db2index fails with usage errors
a2f18f
  commit 3507c46c9f1156df11b6cf05eba695d81088b416
a2f18f
applying the similar changes to all the shell CLI which could be given
a2f18f
arguments that include white spaces.
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/48254
a2f18f
a2f18f
Reviewed by mreynolds@redhat.com (Thank you, Mark!!)
a2f18f
a2f18f
(cherry picked from commit 5fe28921810a53dcd31525ba1f675582b6aba0f7)
a2f18f
(cherry picked from commit 19b0d4af54e319e3479b16bf1366568271e3daa6)
a2f18f
---
a2f18f
 ldap/admin/src/scripts/bak2db.in          | 10 +++++-----
a2f18f
 ldap/admin/src/scripts/db2bak.in          |  8 ++++----
a2f18f
 ldap/admin/src/scripts/db2index.in        | 10 +++++-----
a2f18f
 ldap/admin/src/scripts/db2ldif.in         | 14 +++++++-------
a2f18f
 ldap/admin/src/scripts/dbverify.in        | 10 +++++-----
a2f18f
 ldap/admin/src/scripts/dn2rdn.in          |  8 ++++----
a2f18f
 ldap/admin/src/scripts/ldif2db.in         | 22 +++++++++++-----------
a2f18f
 ldap/admin/src/scripts/monitor.in         |  8 ++++----
a2f18f
 ldap/admin/src/scripts/suffix2instance.in |  4 ++--
a2f18f
 ldap/admin/src/scripts/upgradedb.in       |  8 ++++----
a2f18f
 ldap/admin/src/scripts/upgradednformat.in | 10 +++++-----
a2f18f
 ldap/admin/src/scripts/vlvindex.in        | 16 ++++++++--------
a2f18f
 12 files changed, 64 insertions(+), 64 deletions(-)
a2f18f
a2f18f
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
a2f18f
index a2e54cc..ab7c6b3 100755
a2f18f
--- a/ldap/admin/src/scripts/bak2db.in
a2f18f
+++ b/ldap/admin/src/scripts/bak2db.in
a2f18f
@@ -44,12 +44,12 @@ do
a2f18f
         h) usage
a2f18f
            exit 0;;
a2f18f
         Z) servid=$OPTARG;; 
a2f18f
-        n) args=$args" -n $OPTARG";;
a2f18f
+        n) args=$args" -n \"$OPTARG\"";;
a2f18f
         q) args=$args" -q";;
a2f18f
-        d) args=$args" -d $OPTARG";;
a2f18f
+        d) args=$args" -d \"$OPTARG\"";;
a2f18f
         v) args=$args" -v";;
a2f18f
-        D) args=$args" -D $OPTARG";;
a2f18f
-        i) args=$args" -i $OPTARG";;
a2f18f
+        D) args=$args" -D \"$OPTARG\"";;
a2f18f
+        i) args=$args" -i \"$OPTARG\"";;
a2f18f
         a) archivedir=$OPTARG;;
a2f18f
         S) args=$args" -S";;
a2f18f
         ?) usage
a2f18f
@@ -76,4 +76,4 @@ else
a2f18f
     archivedir=`pwd`/$archivedir
a2f18f
 fi
a2f18f
 
a2f18f
-@sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
a2f18f
+eval @sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
a2f18f
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
a2f18f
index 1896c19..adbe30b 100755
a2f18f
--- a/ldap/admin/src/scripts/db2bak.in
a2f18f
+++ b/ldap/admin/src/scripts/db2bak.in
a2f18f
@@ -43,10 +43,10 @@ do
a2f18f
         q) args=$args" -q";;
a2f18f
         v) args=$args" -v";;
a2f18f
         S) args=$args" -S";;
a2f18f
-        D) args=$args" -D $OPTARG";;
a2f18f
-        i) args=$args" -i $OPTARG";;
a2f18f
+        D) args=$args" -D \"$OPTARG\"";;
a2f18f
+        i) args=$args" -i \"$OPTARG\"";;
a2f18f
         a) $bakdir=$OPTARG;;
a2f18f
-        d) args=$args" -d $OPTARG";;
a2f18f
+        d) args=$args" -d \"$OPTARG\"";;
a2f18f
         Z) servid=$OPTARG;;
a2f18f
         ?) usage
a2f18f
            exit 1;;
a2f18f
@@ -72,4 +72,4 @@ then
a2f18f
 fi
a2f18f
 
a2f18f
 echo "Back up directory: $bak_dir"
a2f18f
-@sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
a2f18f
+eval @sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
a2f18f
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
a2f18f
index 6a0785e..c8e9075 100755
a2f18f
--- a/ldap/admin/src/scripts/db2index.in
a2f18f
+++ b/ldap/admin/src/scripts/db2index.in
a2f18f
@@ -35,15 +35,15 @@ do
a2f18f
         h) usage
a2f18f
            exit 0;;
a2f18f
         Z) servid=$OPTARG;; 
a2f18f
-        n) args=$args" -n $OPTARG"
a2f18f
+        n) args=$args" -n \"$OPTARG\""
a2f18f
            benameopt="set";;
a2f18f
-        s) args=$args" -s $OPTARG"
a2f18f
+        s) args=$args" -s \"$OPTARG\""
a2f18f
            includeSuffix="set";;
a2f18f
         t) args=$args" -t "\"$OPTARG\";;
a2f18f
         T) args=$args" -T "\"$OPTARG\";;
a2f18f
-        d) args=$args" -d $OPTARG";;
a2f18f
-        a) args=$args" -a $OPTARG";;
a2f18f
-        x) args=$args" -x $OPTARG";;
a2f18f
+        d) args=$args" -d \"$OPTARG\"";;
a2f18f
+        a) args=$args" -a \"$OPTARG\"";;
a2f18f
+        x) args=$args" -x \"$OPTARG\"";;
a2f18f
         v) args=$args" -v";;
a2f18f
         S) args=$args" -S";;
a2f18f
         D) args=$args" -D $OPTARG";;
a2f18f
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
a2f18f
index fcf73a0..e9f7f7e 100755
a2f18f
--- a/ldap/admin/src/scripts/db2ldif.in
a2f18f
+++ b/ldap/admin/src/scripts/db2ldif.in
a2f18f
@@ -106,12 +106,12 @@ do
a2f18f
         Z) servid=$OPTARG;; 
a2f18f
         n) benameopt="-n $OPTARG"
a2f18f
            required_param="yes";;
a2f18f
-        s) includeSuffix="-s $OPTARG"
a2f18f
+        s) includeSuffix="-s \"$OPTARG\""
a2f18f
            required_param="yes";;
a2f18f
-        x) excludeSuffix="-x $OPTARG";;
a2f18f
-        a) outputFile="-a $OPTARG";;
a2f18f
-        d) args=$args" -d $OPTARG";;
a2f18f
-        D) args=$args" -D $OPTARG";;
a2f18f
+        x) excludeSuffix="-x \"$OPTARG\"";;
a2f18f
+        a) outputFile="-a \"$OPTARG\"";;
a2f18f
+        d) args=$args" -d \"$OPTARG\"";;
a2f18f
+        D) args=$args" -D \"$OPTARG\"";;
a2f18f
         N) args=$args" -N";;
a2f18f
         E) args=$args" -E";;
a2f18f
         S) args=$args" -S";;
a2f18f
@@ -154,7 +154,7 @@ rn=$?
a2f18f
 echo "Exported ldif file: $ldif_file"
a2f18f
 if [ $rn -eq 1 ]
a2f18f
 then
a2f18f
-    @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
a2f18f
+    eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
a2f18f
 else
a2f18f
-    @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
a2f18f
+    eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
a2f18f
 fi
a2f18f
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
a2f18f
index bbacc17..b98e9b2 100755
a2f18f
--- a/ldap/admin/src/scripts/dbverify.in
a2f18f
+++ b/ldap/admin/src/scripts/dbverify.in
a2f18f
@@ -33,14 +33,14 @@ do
a2f18f
         h) usage
a2f18f
            exit 0;;
a2f18f
         Z) servid=$OPTARG;;
a2f18f
-        n) args=$args" -n $OPTARG";;
a2f18f
-        d) args=$args" -d $OPTARG";;
a2f18f
+        n) args=$args" -n \"$OPTARG\"";;
a2f18f
+        d) args=$args" -d \"$OPTARG\"";;
a2f18f
         V) args=$args" -V";;
a2f18f
         v) args=$args" -v"
a2f18f
            display_version="yes";;
a2f18f
         f) args=$args" -f";;
a2f18f
-        D) args=$args" -D $OPTARG";;
a2f18f
-        a) args=$args" -a $OPTARG";;
a2f18f
+        D) args=$args" -D \"$OPTARG\"";;
a2f18f
+        a) args=$args" -a \"$OPTARG\"";;
a2f18f
         ?) usage
a2f18f
            exit 1;;
a2f18f
     esac
a2f18f
@@ -57,7 +57,7 @@ fi
a2f18f
 
a2f18f
 . $initfile
a2f18f
 
a2f18f
-@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
a2f18f
+eval @sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
a2f18f
 if [ $display_version = "yes" ]; then
a2f18f
     exit 0
a2f18f
 fi
a2f18f
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
a2f18f
index 616969a..762e63a 100755
a2f18f
--- a/ldap/admin/src/scripts/dn2rdn.in
a2f18f
+++ b/ldap/admin/src/scripts/dn2rdn.in
a2f18f
@@ -27,12 +27,12 @@ do
a2f18f
         h) usage
a2f18f
            exit 0;;
a2f18f
         Z) servid=$OPTARG;;
a2f18f
-        d) arg=$arg" -d $OPTARG";;
a2f18f
-        a) arg=$arg" -a $OPTARG"
a2f18f
+        d) arg=$arg" -d \"$OPTARG\"";;
a2f18f
+        a) arg=$arg" -a \"$OPTARG\""
a2f18f
            archive="provided";;
a2f18f
         v) arg=$arg" -v";;
a2f18f
         f) arg=$arg" -f";;
a2f18f
-        D) arg=$arg" -D $OPTARG";;
a2f18f
+        D) arg=$arg" -D \"$OPTARG\"";;
a2f18f
         ?) usage
a2f18f
            exit 1;;
a2f18f
     esac
a2f18f
@@ -55,4 +55,4 @@ if [ "$archive" != "provided" ]; then
a2f18f
     args=$args"-a $bak_dir"
a2f18f
 fi
a2f18f
 
a2f18f
-@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
a2f18f
+eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
a2f18f
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
a2f18f
index a34241a..3aed469 100755
a2f18f
--- a/ldap/admin/src/scripts/ldif2db.in
a2f18f
+++ b/ldap/admin/src/scripts/ldif2db.in
a2f18f
@@ -59,16 +59,16 @@ do
a2f18f
         h) usage
a2f18f
            exit 0;;
a2f18f
         Z) servid=$OPTARG;;
a2f18f
-        n) args=$args" -n $OPTARG";;
a2f18f
-        i) args=$args" -i $OPTARG";;
a2f18f
-        s) args=$args" -s $OPTARG";;
a2f18f
-        x) args=$args" -x $OPTARG";;
a2f18f
-        c) args=$args" -c $OPTARG";;
a2f18f
-        d) args=$args" -d $OPTARG";;
a2f18f
-        g) args=$args" -g $OPTARG";;
a2f18f
-        G) args=$args" -G $OPTARG";;
a2f18f
-        t) args=$args" -t $OPTARG";;
a2f18f
-        D) args=$args" -D $OPTARG";;
a2f18f
+        n) args=$args" -n \"$OPTARG\"";;
a2f18f
+        i) args=$args" -i \"$OPTARG\"";;
a2f18f
+        s) args=$args" -s \"$OPTARG\"";;
a2f18f
+        x) args=$args" -x \"$OPTARG\"";;
a2f18f
+        c) args=$args" -c \"$OPTARG\"";;
a2f18f
+        d) args=$args" -d \"$OPTARG\"";;
a2f18f
+        g) args=$args" -g \"$OPTARG\"";;
a2f18f
+        G) args=$args" -G \"$OPTARG\"";;
a2f18f
+        t) args=$args" -t \"$OPTARG\"";;
a2f18f
+        D) args=$args" -D \"$OPTARG\"";;
a2f18f
         E) args=$args" -E";;
a2f18f
         v) args=$args" -v";;
a2f18f
         N) args=$args" -N";;
a2f18f
@@ -104,6 +104,6 @@ if [ $quiet -eq 0 ]; then
a2f18f
     echo importing data ...
a2f18f
 fi
a2f18f
 
a2f18f
-@sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
a2f18f
+eval @sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
a2f18f
 
a2f18f
 exit $?
a2f18f
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
a2f18f
index 36a2fc9..e9265a1 100755
a2f18f
--- a/ldap/admin/src/scripts/monitor.in
a2f18f
+++ b/ldap/admin/src/scripts/monitor.in
a2f18f
@@ -73,8 +73,8 @@ fi
a2f18f
 rm $file
a2f18f
 
a2f18f
 if [ -n "$passwd" ]; then
a2f18f
-    dn="-D $rootdn"
a2f18f
-    passwd="-w$passwd"
a2f18f
+    dn="-D \"$rootdn\""
a2f18f
+    passwd="-w \"$passwd\""
a2f18f
 fi
a2f18f
 if [ -n "$ldapiURL" ]
a2f18f
 then
a2f18f
@@ -109,9 +109,9 @@ if [ "$security" = "on" ]; then
a2f18f
             echo "Using the next most secure protocol(STARTTLS)"
a2f18f
         fi
a2f18f
         if [ "$openldap" = "yes" ]; then
a2f18f
-            ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
+            eval ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
         else
a2f18f
-            ldapsearch -ZZZ -P $certdir  -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
+            eval ldapsearch -ZZZ -P $certdir  -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
         fi
a2f18f
         exit $?
a2f18f
     fi
a2f18f
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
a2f18f
index 7774148..d7c6661 100755
a2f18f
--- a/ldap/admin/src/scripts/suffix2instance.in
a2f18f
+++ b/ldap/admin/src/scripts/suffix2instance.in
a2f18f
@@ -24,7 +24,7 @@ while getopts "Z:s:h" flag
a2f18f
 do
a2f18f
     case $flag in
a2f18f
         Z) servid=$OPTARG;;
a2f18f
-        s) args=$args" -s $OPTARG";;
a2f18f
+        s) args=$args" -s \"$OPTARG\"";;
a2f18f
         h) usage
a2f18f
            exit 0;;
a2f18f
         ?) usage
a2f18f
@@ -55,4 +55,4 @@ then
a2f18f
     exit 1
a2f18f
 fi
a2f18f
 
a2f18f
-@sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
a2f18f
+eval @sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
a2f18f
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
a2f18f
index bf600dd..2b7c79d 100755
a2f18f
--- a/ldap/admin/src/scripts/upgradedb.in
a2f18f
+++ b/ldap/admin/src/scripts/upgradedb.in
a2f18f
@@ -29,10 +29,10 @@ do
a2f18f
         v) args=$args" -v";;
a2f18f
         f) args=$args" -f";;
a2f18f
         r) args=$args" -r";;
a2f18f
-        d) args=$args" -d $OPTARG";;
a2f18f
-        a) args=$args" -a $OPTARG"
a2f18f
+        d) args=$args" -d \"$OPTARG\"";;
a2f18f
+        a) args=$args" -a \"$OPTARG\""
a2f18f
            archive_provided="yes";;
a2f18f
-        D) args=$args" -D $OPTARG";;
a2f18f
+        D) args=$args" -D \"$OPTARG\"";;
a2f18f
         h) usage
a2f18f
            exit 0;;
a2f18f
     esac
a2f18f
@@ -56,4 +56,4 @@ then
a2f18f
 fi
a2f18f
 
a2f18f
 echo upgrade index files ...
a2f18f
-@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
a2f18f
+eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
a2f18f
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
a2f18f
index 51585ae..9de60ea 100755
a2f18f
--- a/ldap/admin/src/scripts/upgradednformat.in
a2f18f
+++ b/ldap/admin/src/scripts/upgradednformat.in
a2f18f
@@ -36,14 +36,14 @@ do
a2f18f
         Z) servid=$OPTARG;;
a2f18f
         v) args=$args" -v";;
a2f18f
         N) args=$args" -N";;
a2f18f
-        d) args=$args" -d $OPTARG";;
a2f18f
-        a) args=$args" -a $OPTARG"
a2f18f
+        d) args=$args" -d \"$OPTARG\"";;
a2f18f
+        a) args=$args" -a \"$OPTARG\""
a2f18f
            dir="set";;
a2f18f
-        n) args=$args" -n $OPTARG"
a2f18f
+        n) args=$args" -n \"$OPTARG\""
a2f18f
            be="set";;
a2f18f
         h) usage
a2f18f
            exit 0;;
a2f18f
-        D) args=$args" -D $OPTARG";;
a2f18f
+        D) args=$args" -D \"$OPTARG\"";;
a2f18f
         ?) usage
a2f18f
            exit 1;;
a2f18f
     esac
a2f18f
@@ -65,7 +65,7 @@ fi
a2f18f
 
a2f18f
 . $initfile
a2f18f
 
a2f18f
-@sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
a2f18f
+eval @sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
a2f18f
 rc=$?
a2f18f
 
a2f18f
 exit $rc
a2f18f
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
a2f18f
index 365e32f..a1696bc 100755
a2f18f
--- a/ldap/admin/src/scripts/vlvindex.in
a2f18f
+++ b/ldap/admin/src/scripts/vlvindex.in
a2f18f
@@ -29,14 +29,14 @@ do
a2f18f
     case $flag in
a2f18f
         Z) servid=$OPTARG;;
a2f18f
         v) args=$args" -v";;
a2f18f
-        s) args=$args" -s $OPTARG";;
a2f18f
-        d) args=$args" -d $OPTARG";;
a2f18f
-        a) args=$args" -a $OPTARG";;
a2f18f
-        T) args=$args" -T $OPTARG";;
a2f18f
+        s) args=$args" -s \"$OPTARG\"";;
a2f18f
+        d) args=$args" -d \"$OPTARG\"";;
a2f18f
+        a) args=$args" -a \"$OPTARG\"";;
a2f18f
+        T) args=$args" -T \"$OPTARG\"";;
a2f18f
         S) args=$args" -S";;
a2f18f
-        n) args=$args" -n $OPTARG";;
a2f18f
-        x) args=$args" -x $OPTARG";;
a2f18f
-        D) args=$args" -D $OPTARG";;
a2f18f
+        n) args=$args" -n \"$OPTARG\"";;
a2f18f
+        x) args=$args" -x \"$OPTARG\"";;
a2f18f
+        D) args=$args" -D \"$OPTARG\"";;
a2f18f
         h) usage
a2f18f
            exit 0;;
a2f18f
         ?) usage
a2f18f
@@ -61,4 +61,4 @@ then
a2f18f
     exit 1
a2f18f
 fi
a2f18f
 
a2f18f
-@sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
a2f18f
+eval @sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
a2f18f
-- 
a2f18f
1.9.3
a2f18f