|
|
@@ -1,6 +1,6 @@
|
|
|
#!/bin/sh
|
|
|
|
|
|
-source @datadir@/@package_name@/data/DSSharedLib
|
|
|
+. @datadir@/@package_name@/data/DSSharedLib
|
|
|
|
|
|
libpath_add "@ldapsdk_libdir@"
|
|
|
libpath_add "@libdir@"
|
|
|
@@ -40,14 +40,14 @@ do
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
-if [ "$input_file" == "" ]
|
|
|
+if [ -z "$input_file" ]
|
|
|
then
|
|
|
usage
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
initfile=$(get_init_file "@initconfigdir@" $servid)
|
|
|
-if [ $? == 1 ]
|
|
|
+if [ $? -eq 1 ]
|
|
|
then
|
|
|
usage
|
|
|
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
|
|
|
@@ -67,13 +67,13 @@ ldapi=$(grep -i 'nsslapd-ldapilisten' $file | awk '{print $2}' )
|
|
|
ldapiURL=$(grep -i 'nsslapd-ldapifilepath' $file | awk '{print $2}' )
|
|
|
certdir=$(grep -i 'nsslapd-certdir' $file | awk '{print $2}' )
|
|
|
autobind=$(grep -i 'nsslapd-ldapiautobind' $file | awk '{print $2}' )
|
|
|
-if [ "$rootdn" == "" ]; then
|
|
|
+if [ -z "$rootdn" ]; then
|
|
|
value=$(grep -i 'nsslapd-rootdn' $file)
|
|
|
rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'`
|
|
|
fi
|
|
|
rm $file
|
|
|
|
|
|
-if [ "$ldapiURL" != "" ]; then
|
|
|
+if [ -n "$ldapiURL" ]; then
|
|
|
ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'`
|
|
|
ldapiURL="ldapi://"$ldapiURL
|
|
|
fi
|
|
|
@@ -86,7 +86,7 @@ then
|
|
|
export LDAPTLS_CACERTDIR=$certdir
|
|
|
fi
|
|
|
|
|
|
-if [ -z $security ]; then
|
|
|
+if [ -z "$security" ]; then
|
|
|
security="off"
|
|
|
fi
|
|
|
revised_protocol=$(check_protocol $protocol $security $ldapi $openldap)
|
|
|
@@ -99,12 +99,12 @@ protocol=$revised_protocol
|
|
|
#
|
|
|
# STARTTLS
|
|
|
#
|
|
|
-if [ "$security" == "on" ]; then
|
|
|
- if [ "$protocol" == "STARTTLS" ] || [ "$protocol" == "" ]; then
|
|
|
- if [ "$error" == "yes" ]; then
|
|
|
+if [ "$security" = "on" ]; then
|
|
|
+ if [ "$protocol" = "STARTTLS" ] || [ -z "$protocol" ]; then
|
|
|
+ if [ "$error" = "yes" ]; then
|
|
|
echo "Using the next most secure protocol(STARTTLS)"
|
|
|
fi
|
|
|
- if [ "$openldap" == "yes" ]; then
|
|
|
+ if [ "$openldap" = "yes" ]; then
|
|
|
ldapmodify -x -ZZ -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
|
|
|
else
|
|
|
ldapmodify -ZZZ -P $certdir -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
|
|
|
@@ -116,12 +116,12 @@ fi
|
|
|
#
|
|
|
# LDAPS
|
|
|
#
|
|
|
-if [ "$security" == "on" ]; then
|
|
|
- if [ "$protocol" == "LDAPS" ] || [ "$protocol" == "" ]; then
|
|
|
- if [ "$error" == "yes" ]; then
|
|
|
+if [ "$security" = "on" ]; then
|
|
|
+ if [ "$protocol" = "LDAPS" ] || [ -z "$protocol" ]; then
|
|
|
+ if [ "$error" = "yes" ]; then
|
|
|
echo "Using the next most secure protocol(LDAPS)"
|
|
|
fi
|
|
|
- if [ "$openldap" == "yes" ]; then
|
|
|
+ if [ "$openldap" = "yes" ]; then
|
|
|
ldapmodify -x -H "ldaps://$host:$secure_port" -D $rootdn -w $passwd -a -f $input_file
|
|
|
else
|
|
|
ldapmodify -Z -P $certdir -p $secure_port -h $host -D $rootdn -w $passwd -a -f $input_file
|
|
|
@@ -133,21 +133,21 @@ fi
|
|
|
#
|
|
|
# LDAPI
|
|
|
#
|
|
|
-if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then
|
|
|
- if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then
|
|
|
- if [ "$(id -u)" == "0" ] && [ "$autobind" == "on" ]; then
|
|
|
- if [ "$error" == "yes" ]; then
|
|
|
+if [ "$ldapi" = "on" ] && [ "$openldap" = "yes" ]; then
|
|
|
+ if [ "$protocol" = "LDAPI" ] || [ -z "$protocol" ]; then
|
|
|
+ if [ $(id -u) -eq 0 ] && [ "$autobind" = "on" ]; then
|
|
|
+ if [ "$error" = "yes" ]; then
|
|
|
echo "Using the next most secure protocol(LDAPI/AUTOBIND)"
|
|
|
fi
|
|
|
ldapmodify -H $ldapiURL -Y EXTERNAL -a -f $input_file 2>/dev/null
|
|
|
else
|
|
|
- if [ "$error" == "yes" ]; then
|
|
|
+ if [ "$error" = "yes" ]; then
|
|
|
echo "Using the next most secure protocol(LDAPI)"
|
|
|
fi
|
|
|
ldapmodify -x -H $ldapiURL -D $rootdn -w $passwd -a -f $input_file
|
|
|
fi
|
|
|
rc=$?
|
|
|
- if [ $rc != 0 ]
|
|
|
+ if [ $rc -ne 0 ]
|
|
|
then
|
|
|
echo "Operation failed (error $rc)"
|
|
|
fi
|
|
|
@@ -158,11 +158,11 @@ fi
|
|
|
#
|
|
|
# LDAP
|
|
|
#
|
|
|
-if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then
|
|
|
- if [ "$error" == "yes" ]; then
|
|
|
+if [ "$protocol" = "LDAP" ] || [ -z "$protocol" ]; then
|
|
|
+ if [ "$error" = "yes" ]; then
|
|
|
echo "Using the next most secure protocol(LDAP)"
|
|
|
fi
|
|
|
- if [ "$openldap" == "yes" ]; then
|
|
|
+ if [ "$openldap" = "yes" ]; then
|
|
|
ldapmodify -x -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
|
|
|
else
|
|
|
ldapmodify -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
|