dirsrvtests/suites dirsrvtests/tickets
by Mark Reynolds
dirsrvtests/suites/memory_leaks/range_search_test.py | 45 ++-----
dirsrvtests/tickets/ticket48226_test.py | 108 ++++++++++---------
2 files changed, 73 insertions(+), 80 deletions(-)
New commits:
commit c2e350e6280ec53fb226fb981d55069aa0c626f8
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Sep 15 23:12:01 2015 -0400
Ticket 48273 - Update lib389 tests for new valgrind functions
Description: Update the existing tests that use valgrind, to use the
new process. Added finailizers so that we always disable
valgrind at the end of the test.
https://fedorahosted.org/389/ticket/48273
Reviewed by: nhosoi(Thanks!)
diff --git a/dirsrvtests/suites/memory_leaks/range_search_test.py b/dirsrvtests/suites/memory_leaks/range_search_test.py
index 21369b9..86852b4 100644
--- a/dirsrvtests/suites/memory_leaks/range_search_test.py
+++ b/dirsrvtests/suites/memory_leaks/range_search_test.py
@@ -54,6 +54,12 @@ def topology(request):
# Clear out the tmp dir
standalone.clearTmpDir(__file__)
+ def fin():
+ topology.standalone.delete()
+ sbin_dir = get_sbin_dir(prefix=topology.standalone.prefix)
+ valgrind_disable(sbin_dir)
+ request.addfinalizer(fin)
+
return TopologyStandalone(standalone)
@@ -89,8 +95,6 @@ def test_range_search(topology):
log.info('Running test_range_search...')
- sbin_dir = get_sbin_dir(prefix=topology.standalone.prefix)
-
success = True
# Add 100 test entries
@@ -113,41 +117,22 @@ def test_range_search(topology):
except ldap.LDAPError as e:
log.fatal('test_range_search: Failed to search retro changelog(%s), error: %s' %
(RETROCL_SUFFIX, e.message('desc')))
- test_range_search_final(topology) # With valgrind we always need to cleanup
success = False
if success:
- # Check valgrind(this stops the server)
- if valgrind_check_leak(topology.standalone, 'range_candidates'):
+ # Get the results file, stop the server, and check for the leak
+ results_file = valgrind_get_results_file(topology.standalone)
+ topology.standalone.stop(timeout=30)
+ if valgrind_check_file(results_file, VALGRIND_LEAK_STR, 'range_candidates'):
log.fatal('test_range_search: Memory leak is still present!')
- test_range_search_final(topology) # With valgrind we always need to cleanup
- success = False
+ assert False
- # Disable valgrind
- sbin_dir = get_sbin_dir(prefix=topology.standalone.prefix)
- valgrind_disable(sbin_dir)
-
- if success:
log.info('test_range_search: PASSED')
- else:
- log.fatal('test_range_search: FAILED')
-
-
-def test_range_search_final(topology):
- # Remove the instance
- topology.standalone.delete()
-
-
-def run_isolated():
- global installation1_prefix
- installation1_prefix = None
-
- topo = topology(True)
- test_range_search_init(topo)
- test_range_search(topo)
- test_range_search_final(topo)
if __name__ == '__main__':
- run_isolated()
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tickets/ticket48226_test.py b/dirsrvtests/tickets/ticket48226_test.py
index a7bafba..6e244af 100644
--- a/dirsrvtests/tickets/ticket48226_test.py
+++ b/dirsrvtests/tickets/ticket48226_test.py
@@ -3,7 +3,7 @@
# All rights reserved.
#
# License: GPL (version 3 or any later version).
-# See LICENSE for details.
+# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
#
import os
@@ -120,9 +120,17 @@ def topology(request):
# Clear out the tmp dir
master1.clearTmpDir(__file__)
+ def fin():
+ master1.delete()
+ master2.delete()
+ sbin_dir = get_sbin_dir(prefix=master2.prefix)
+ valgrind_disable(sbin_dir)
+ request.addfinalizer(fin)
+
return TopologyReplication(master1, master2)
-def test_ticket11111_set_purgedelay(topology):
+
+def test_ticket48226_set_purgedelay(topology):
args = {REPLICA_PURGE_DELAY: '5',
REPLICA_PURGE_INTERVAL: '5'}
try:
@@ -139,21 +147,20 @@ def test_ticket11111_set_purgedelay(topology):
topology.master2.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-auditlog-logging-enabled', 'on')])
topology.master1.restart(10)
topology.master2.restart(10)
-
-def test_ticket11111_1(topology):
+
+def test_ticket48226_1(topology):
name = 'test_entry'
dn = "cn=%s,%s" % (name, SUFFIX)
-
- topology.master1.add_s(Entry((dn , {
- 'objectclass': "top person".split(),
- 'sn': name,
- 'cn': name})))
-
+
+ topology.master1.add_s(Entry((dn, {'objectclass': "top person".split(),
+ 'sn': name,
+ 'cn': name})))
+
# First do an update that is replicated
mods = [(ldap.MOD_ADD, 'description', '5')]
topology.master1.modify_s(dn, mods)
-
+
nbtry = 0
while (nbtry <= 10):
try:
@@ -165,17 +172,17 @@ def test_ticket11111_1(topology):
nbtry = nbtry + 1
time.sleep(1)
assert nbtry <= 10
-
+
# Stop M2 so that it will not receive the next update
topology.master2.stop(10)
-
+
# ADD a new value that is not replicated
mods = [(ldap.MOD_DELETE, 'description', '5')]
topology.master1.modify_s(dn, mods)
-
+
# Stop M1 so that it will keep del '5' that is unknown from master2
topology.master1.stop(10)
-
+
# Get the sbin directory so we know where to replace 'ns-slapd'
sbin_dir = get_sbin_dir(prefix=topology.master2.prefix)
@@ -183,59 +190,60 @@ def test_ticket11111_1(topology):
valgrind_enable(sbin_dir)
# start M2 to do the next updates
- topology.master2.start(10)
-
- # ADD 'description' by '5'
+ topology.master2.start(60)
+
+ # ADD 'description' by '5'
mods = [(ldap.MOD_DELETE, 'description', '5')]
topology.master2.modify_s(dn, mods)
-
+
# DEL 'description' by '5'
mods = [(ldap.MOD_ADD, 'description', '5')]
topology.master2.modify_s(dn, mods)
-
+
# sleep of purgedelay so that the next update will purge the CSN_7
time.sleep(6)
-
- # ADD 'description' by '8' that purge the state info
+
+ # ADD 'description' by '6' that purge the state info
mods = [(ldap.MOD_ADD, 'description', '6')]
topology.master2.modify_s(dn, mods)
- if valgrind_check_leak(topology.master2, 'csnset_dup'):
- log.error('test_csnset_dup: Memory leak is present!')
- else:
- log.info('test_csnset_dup: No leak is present!')
-
- topology.master2.start(10)
+ # Restart master1
+ topology.master1.start(10)
- # Disnable valgrind
- valgrind_disable(sbin_dir)
+ # Get the results file
+ results_file = valgrind_get_results_file(topology.master2)
- topology.master1.start(10)
-
- if valgrind_check_leak(topology.master2, 'Invalid'):
+ # Stop master2
+ topology.master2.stop(10)
+
+ # Check for leak
+ if valgrind_check_file(results_file, VALGRIND_LEAK_STR, 'csnset_dup'):
+ log.info('Valgrind reported leak in csnset_dup!')
+ assert False
+ else:
+ log.info('Valgrind is happy!')
+
+ # Check for invalid read/write
+ if valgrind_check_file(results_file, VALGRIND_INVALID_STR, 'csnset_dup'):
log.info('Valgrind reported invalid!')
+ assert False
else:
log.info('Valgrind is happy!')
-
- #log.info("You can attach yourself")
- #time.sleep(60)
-
-
-def test_ticket11111_final(topology):
- topology.master1.delete()
- topology.master2.delete()
- log.info('Testcase PASSED')
+ # Check for invalid read/write
+ if valgrind_check_file(results_file, VALGRIND_INVALID_STR, 'csnset_free'):
+ log.info('Valgrind reported invalid!')
+ assert False
+ else:
+ log.info('Valgrind is happy!')
-def run_isolated():
- global installation1_prefix
- installation1_prefix = None
+ topology.master1.start(10)
+ log.info('Testcase PASSED')
- topo = topology(True)
- test_ticket11111_set_purgedelay(topo)
- test_ticket11111_1(topo)
-
if __name__ == '__main__':
- run_isolated()
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months
Branch '389-ds-base-1.3.4' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/resourcelimit.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
New commits:
commit 5f32582d043a5498791dda5af7091bf1a4a320f0
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Sep 14 12:01:08 2015 -0400
Ticket 48276 - initialize free_flags in reslimit_update_from_entry()
Description: In reslimit_update_from_entry() the free_flags was not initialized,
which could lead to it being seen as set, and cause an entry's
vattrs to be incorrectly/unexpectedly freed.
https://fedorahosted.org/389/ticket/48276
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 2311c71cec33c29863bdb1dabe1ed363679316d3)
diff --git a/ldap/servers/slapd/resourcelimit.c b/ldap/servers/slapd/resourcelimit.c
index 8c0a09c..7630f88 100644
--- a/ldap/servers/slapd/resourcelimit.c
+++ b/ldap/servers/slapd/resourcelimit.c
@@ -342,11 +342,14 @@ reslimit_update_from_dn( Slapi_Connection *conn, Slapi_DN *dn )
int
reslimit_update_from_entry( Slapi_Connection *conn, Slapi_Entry *e )
{
- char *fnname = "reslimit_update_from_entry()";
- char *actual_type_name, *get_ext_logname;
- int i, rc, type_name_disposition, free_flags;
- SLAPIResLimitConnData *rlcdp;
- Slapi_ValueSet *vs;
+ SLAPIResLimitConnData *rlcdp = NULL;
+ Slapi_ValueSet *vs = NULL;
+ char *fnname = "reslimit_update_from_entry()";
+ char *actual_type_name = NULL;
+ char *get_ext_logname = NULL;
+ int type_name_disposition = 0;
+ int free_flags = 0;
+ int rc, i;
LDAPDebug( SLAPI_RESLIMIT_TRACELEVEL, "=> %s conn=0x%x, entry=0x%x\n",
fnname, conn, e );
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months
ldap/servers
by Mark Reynolds
ldap/servers/slapd/resourcelimit.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
New commits:
commit 2311c71cec33c29863bdb1dabe1ed363679316d3
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Sep 14 12:01:08 2015 -0400
Ticket 48276 - initialize free_flags in reslimit_update_from_entry()
Description: In reslimit_update_from_entry() the free_flags was not initialized,
which could lead to it being seen as set, and cause an entry's
vattrs to be incorrectly/unexpectedly freed.
https://fedorahosted.org/389/ticket/48276
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/slapd/resourcelimit.c b/ldap/servers/slapd/resourcelimit.c
index 8c0a09c..7630f88 100644
--- a/ldap/servers/slapd/resourcelimit.c
+++ b/ldap/servers/slapd/resourcelimit.c
@@ -342,11 +342,14 @@ reslimit_update_from_dn( Slapi_Connection *conn, Slapi_DN *dn )
int
reslimit_update_from_entry( Slapi_Connection *conn, Slapi_Entry *e )
{
- char *fnname = "reslimit_update_from_entry()";
- char *actual_type_name, *get_ext_logname;
- int i, rc, type_name_disposition, free_flags;
- SLAPIResLimitConnData *rlcdp;
- Slapi_ValueSet *vs;
+ SLAPIResLimitConnData *rlcdp = NULL;
+ Slapi_ValueSet *vs = NULL;
+ char *fnname = "reslimit_update_from_entry()";
+ char *actual_type_name = NULL;
+ char *get_ext_logname = NULL;
+ int type_name_disposition = 0;
+ int free_flags = 0;
+ int rc, i;
LDAPDebug( SLAPI_RESLIMIT_TRACELEVEL, "=> %s conn=0x%x, entry=0x%x\n",
fnname, conn, e );
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months
Branch '389-ds-base-1.3.3' - dirsrvtests/tickets
by Mark Reynolds
dirsrvtests/tickets/ticket47553_test.py | 166 ++++++++++++++++++++++++++++++++
1 file changed, 166 insertions(+)
New commits:
commit 16bd6aff13c0042c0122fed9785761243afdcb00
Author: Simon Pichugin <spichugi(a)redhat.com>
Date: Mon Aug 31 17:22:34 2015 +0200
Ticket #47553 - Automated the verification procedure
Description: Test case checks, that MODRDN operation is allowed,
if user has ACI right '(all)' under superior entries,
but doesn't have '(modrdn)'.
https://fedorahosted.org/389/ticket/47553
Reviewed by: mreynolds(a)redhat.com (Thanks!)
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
(cherry picked from commit 81dcdd91c7c8c9735cbc87b8b4c421c4ac8ec3d8)
diff --git a/dirsrvtests/tickets/ticket47553_test.py b/dirsrvtests/tickets/ticket47553_test.py
new file mode 100644
index 0000000..84d462d
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47553_test.py
@@ -0,0 +1,166 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2015 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+CONTAINER_1_OU = 'test_ou_1'
+CONTAINER_2_OU = 'test_ou_2'
+CONTAINER_1 = 'ou=%s,dc=example,dc=com' % CONTAINER_1_OU
+CONTAINER_2 = 'ou=%s,dc=example,dc=com' % CONTAINER_2_OU
+USER_CN = 'test_user'
+USER_PWD = 'Secret123'
+USER = 'cn=%s,%s' % (USER_CN, CONTAINER_1)
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+(a)pytest.fixture(scope="module")
+def env_setup(topology):
+ """Adds two containers, one user and two ACI rules"""
+
+ try:
+ log.info("Add a container: %s" % CONTAINER_1)
+ topology.standalone.add_s(Entry((CONTAINER_1,
+ {'objectclass': 'top',
+ 'objectclass': 'organizationalunit',
+ 'ou': CONTAINER_1_OU,
+ })))
+
+ log.info("Add a container: %s" % CONTAINER_2)
+ topology.standalone.add_s(Entry((CONTAINER_2,
+ {'objectclass': 'top',
+ 'objectclass': 'organizationalunit',
+ 'ou': CONTAINER_2_OU,
+ })))
+
+ log.info("Add a user: %s" % USER)
+ topology.standalone.add_s(Entry((USER,
+ {'objectclass': 'top person'.split(),
+ 'cn': USER_CN,
+ 'sn': USER_CN,
+ 'userpassword': USER_PWD
+ })))
+ except ldap.LDAPError as e:
+ log.error('Failed to add object to database: %s' % e.message['desc'])
+ assert False
+
+ ACI_TARGET = '(targetattr="*")'
+ ACI_ALLOW = '(version 3.0; acl "All rights for %s"; allow (all) ' % USER
+ ACI_SUBJECT = 'userdn="ldap:///%s";)' % USER
+ ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
+ mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)]
+
+ try:
+ log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
+ CONTAINER_1))
+ topology.standalone.modify_s(CONTAINER_1, mod)
+
+ log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
+ CONTAINER_2))
+ topology.standalone.modify_s(CONTAINER_2, mod)
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add ACI: error (%s)' % (e.message['desc']))
+ assert False
+
+
+def test_ticket47553(topology, env_setup):
+ """Tests, that MODRDN operation is allowed,
+ if user has ACI right '(all)' under superior entries,
+ but doesn't have '(modrdn)'
+ """
+
+ log.info("Bind as %s" % USER)
+ try:
+ topology.standalone.simple_bind_s(USER, USER_PWD)
+ except ldap.LDAPError as e:
+ log.error('Bind failed for %s, error %s' % (USER, e.message['desc']))
+ assert False
+
+ log.info("User MODRDN operation from %s to %s" % (CONTAINER_1,
+ CONTAINER_2))
+ try:
+ topology.standalone.rename_s(USER, "cn=%s" % USER_CN,
+ newsuperior=CONTAINER_2, delold=1)
+ except ldap.LDAPError as e:
+ log.error('MODRDN failed for %s, error %s' % (USER, e.message['desc']))
+ assert False
+
+ try:
+ log.info("Check there is no user in %s" % CONTAINER_1)
+ entries = topology.standalone.search_s(CONTAINER_1,
+ ldap.SCOPE_ONELEVEL,
+ 'cn=%s' % USER_CN)
+ assert not entries
+
+ log.info("Check there is our user in %s" % CONTAINER_2)
+ entries = topology.standalone.search_s(CONTAINER_2,
+ ldap.SCOPE_ONELEVEL,
+ 'cn=%s' % USER_CN)
+ assert entries
+ except ldap.LDAPError as e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ assert False
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ # -v for additional verbose
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s -v %s" % CURRENT_FILE)
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months
Branch '389-ds-base-1.3.4' - dirsrvtests/tickets
by Mark Reynolds
dirsrvtests/tickets/ticket47553_test.py | 166 ++++++++++++++++++++++++++++++++
1 file changed, 166 insertions(+)
New commits:
commit 5babb681897f40c264f619e2654c48739088d347
Author: Simon Pichugin <spichugi(a)redhat.com>
Date: Mon Aug 31 17:22:34 2015 +0200
Ticket #47553 - Automated the verification procedure
Description: Test case checks, that MODRDN operation is allowed,
if user has ACI right '(all)' under superior entries,
but doesn't have '(modrdn)'.
https://fedorahosted.org/389/ticket/47553
Reviewed by: mreynolds(a)redhat.com (Thanks!)
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
(cherry picked from commit 81dcdd91c7c8c9735cbc87b8b4c421c4ac8ec3d8)
diff --git a/dirsrvtests/tickets/ticket47553_test.py b/dirsrvtests/tickets/ticket47553_test.py
new file mode 100644
index 0000000..84d462d
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47553_test.py
@@ -0,0 +1,166 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2015 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+CONTAINER_1_OU = 'test_ou_1'
+CONTAINER_2_OU = 'test_ou_2'
+CONTAINER_1 = 'ou=%s,dc=example,dc=com' % CONTAINER_1_OU
+CONTAINER_2 = 'ou=%s,dc=example,dc=com' % CONTAINER_2_OU
+USER_CN = 'test_user'
+USER_PWD = 'Secret123'
+USER = 'cn=%s,%s' % (USER_CN, CONTAINER_1)
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+(a)pytest.fixture(scope="module")
+def env_setup(topology):
+ """Adds two containers, one user and two ACI rules"""
+
+ try:
+ log.info("Add a container: %s" % CONTAINER_1)
+ topology.standalone.add_s(Entry((CONTAINER_1,
+ {'objectclass': 'top',
+ 'objectclass': 'organizationalunit',
+ 'ou': CONTAINER_1_OU,
+ })))
+
+ log.info("Add a container: %s" % CONTAINER_2)
+ topology.standalone.add_s(Entry((CONTAINER_2,
+ {'objectclass': 'top',
+ 'objectclass': 'organizationalunit',
+ 'ou': CONTAINER_2_OU,
+ })))
+
+ log.info("Add a user: %s" % USER)
+ topology.standalone.add_s(Entry((USER,
+ {'objectclass': 'top person'.split(),
+ 'cn': USER_CN,
+ 'sn': USER_CN,
+ 'userpassword': USER_PWD
+ })))
+ except ldap.LDAPError as e:
+ log.error('Failed to add object to database: %s' % e.message['desc'])
+ assert False
+
+ ACI_TARGET = '(targetattr="*")'
+ ACI_ALLOW = '(version 3.0; acl "All rights for %s"; allow (all) ' % USER
+ ACI_SUBJECT = 'userdn="ldap:///%s";)' % USER
+ ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
+ mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)]
+
+ try:
+ log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
+ CONTAINER_1))
+ topology.standalone.modify_s(CONTAINER_1, mod)
+
+ log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
+ CONTAINER_2))
+ topology.standalone.modify_s(CONTAINER_2, mod)
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add ACI: error (%s)' % (e.message['desc']))
+ assert False
+
+
+def test_ticket47553(topology, env_setup):
+ """Tests, that MODRDN operation is allowed,
+ if user has ACI right '(all)' under superior entries,
+ but doesn't have '(modrdn)'
+ """
+
+ log.info("Bind as %s" % USER)
+ try:
+ topology.standalone.simple_bind_s(USER, USER_PWD)
+ except ldap.LDAPError as e:
+ log.error('Bind failed for %s, error %s' % (USER, e.message['desc']))
+ assert False
+
+ log.info("User MODRDN operation from %s to %s" % (CONTAINER_1,
+ CONTAINER_2))
+ try:
+ topology.standalone.rename_s(USER, "cn=%s" % USER_CN,
+ newsuperior=CONTAINER_2, delold=1)
+ except ldap.LDAPError as e:
+ log.error('MODRDN failed for %s, error %s' % (USER, e.message['desc']))
+ assert False
+
+ try:
+ log.info("Check there is no user in %s" % CONTAINER_1)
+ entries = topology.standalone.search_s(CONTAINER_1,
+ ldap.SCOPE_ONELEVEL,
+ 'cn=%s' % USER_CN)
+ assert not entries
+
+ log.info("Check there is our user in %s" % CONTAINER_2)
+ entries = topology.standalone.search_s(CONTAINER_2,
+ ldap.SCOPE_ONELEVEL,
+ 'cn=%s' % USER_CN)
+ assert entries
+ except ldap.LDAPError as e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ assert False
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ # -v for additional verbose
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s -v %s" % CURRENT_FILE)
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months
dirsrvtests/tickets
by Mark Reynolds
dirsrvtests/tickets/ticket47553_test.py | 166 ++++++++++++++++++++++++++++++++
1 file changed, 166 insertions(+)
New commits:
commit 81dcdd91c7c8c9735cbc87b8b4c421c4ac8ec3d8
Author: Simon Pichugin <spichugi(a)redhat.com>
Date: Mon Aug 31 17:22:34 2015 +0200
Ticket #47553 - Automated the verification procedure
Description: Test case checks, that MODRDN operation is allowed,
if user has ACI right '(all)' under superior entries,
but doesn't have '(modrdn)'.
https://fedorahosted.org/389/ticket/47553
Reviewed by: mreynolds(a)redhat.com (Thanks!)
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
diff --git a/dirsrvtests/tickets/ticket47553_test.py b/dirsrvtests/tickets/ticket47553_test.py
new file mode 100644
index 0000000..84d462d
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47553_test.py
@@ -0,0 +1,166 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2015 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+CONTAINER_1_OU = 'test_ou_1'
+CONTAINER_2_OU = 'test_ou_2'
+CONTAINER_1 = 'ou=%s,dc=example,dc=com' % CONTAINER_1_OU
+CONTAINER_2 = 'ou=%s,dc=example,dc=com' % CONTAINER_2_OU
+USER_CN = 'test_user'
+USER_PWD = 'Secret123'
+USER = 'cn=%s,%s' % (USER_CN, CONTAINER_1)
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+(a)pytest.fixture(scope="module")
+def env_setup(topology):
+ """Adds two containers, one user and two ACI rules"""
+
+ try:
+ log.info("Add a container: %s" % CONTAINER_1)
+ topology.standalone.add_s(Entry((CONTAINER_1,
+ {'objectclass': 'top',
+ 'objectclass': 'organizationalunit',
+ 'ou': CONTAINER_1_OU,
+ })))
+
+ log.info("Add a container: %s" % CONTAINER_2)
+ topology.standalone.add_s(Entry((CONTAINER_2,
+ {'objectclass': 'top',
+ 'objectclass': 'organizationalunit',
+ 'ou': CONTAINER_2_OU,
+ })))
+
+ log.info("Add a user: %s" % USER)
+ topology.standalone.add_s(Entry((USER,
+ {'objectclass': 'top person'.split(),
+ 'cn': USER_CN,
+ 'sn': USER_CN,
+ 'userpassword': USER_PWD
+ })))
+ except ldap.LDAPError as e:
+ log.error('Failed to add object to database: %s' % e.message['desc'])
+ assert False
+
+ ACI_TARGET = '(targetattr="*")'
+ ACI_ALLOW = '(version 3.0; acl "All rights for %s"; allow (all) ' % USER
+ ACI_SUBJECT = 'userdn="ldap:///%s";)' % USER
+ ACI_BODY = ACI_TARGET + ACI_ALLOW + ACI_SUBJECT
+ mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)]
+
+ try:
+ log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
+ CONTAINER_1))
+ topology.standalone.modify_s(CONTAINER_1, mod)
+
+ log.info("Add an ACI 'allow (all)' by %s to the %s" % (USER,
+ CONTAINER_2))
+ topology.standalone.modify_s(CONTAINER_2, mod)
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add ACI: error (%s)' % (e.message['desc']))
+ assert False
+
+
+def test_ticket47553(topology, env_setup):
+ """Tests, that MODRDN operation is allowed,
+ if user has ACI right '(all)' under superior entries,
+ but doesn't have '(modrdn)'
+ """
+
+ log.info("Bind as %s" % USER)
+ try:
+ topology.standalone.simple_bind_s(USER, USER_PWD)
+ except ldap.LDAPError as e:
+ log.error('Bind failed for %s, error %s' % (USER, e.message['desc']))
+ assert False
+
+ log.info("User MODRDN operation from %s to %s" % (CONTAINER_1,
+ CONTAINER_2))
+ try:
+ topology.standalone.rename_s(USER, "cn=%s" % USER_CN,
+ newsuperior=CONTAINER_2, delold=1)
+ except ldap.LDAPError as e:
+ log.error('MODRDN failed for %s, error %s' % (USER, e.message['desc']))
+ assert False
+
+ try:
+ log.info("Check there is no user in %s" % CONTAINER_1)
+ entries = topology.standalone.search_s(CONTAINER_1,
+ ldap.SCOPE_ONELEVEL,
+ 'cn=%s' % USER_CN)
+ assert not entries
+
+ log.info("Check there is our user in %s" % CONTAINER_2)
+ entries = topology.standalone.search_s(CONTAINER_2,
+ ldap.SCOPE_ONELEVEL,
+ 'cn=%s' % USER_CN)
+ assert entries
+ except ldap.LDAPError as e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ assert False
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ # -v for additional verbose
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s -v %s" % CURRENT_FILE)
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months
Branch '389-ds-base-1.3.4' - dirsrvtests/suites
by Mark Reynolds
dirsrvtests/suites/basic/basic_test.py | 72 +++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
New commits:
commit 973d1d95a25439f094b1702e56f0d2a7fb7abca5
Author: Simon Pichugin <spichugi(a)redhat.com>
Date: Mon Aug 31 10:54:21 2015 +0200
Ticket 47761 - Added a few testcases to the basic testsuite
Description: New testcases test the feature that adds a posibility
to change the behavior of rootDSE searches. Namely,
the default list of returned operational attributes.
https://fedorahosted.org/389/ticket/47761
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
(cherry picked from commit cb950de1414e6b04bd09587bee7090a00ada15fe)
diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py
index c6ac74b..9aec8ef 100644
--- a/dirsrvtests/suites/basic/basic_test.py
+++ b/dirsrvtests/suites/basic/basic_test.py
@@ -31,6 +31,13 @@ USER1_DN = 'uid=user1,' + DEFAULT_SUFFIX
USER2_DN = 'uid=user2,' + DEFAULT_SUFFIX
USER3_DN = 'uid=user3,' + DEFAULT_SUFFIX
+ROOTDSE_DEF_ATTR_LIST = ('namingContexts',
+ 'supportedLDAPVersion',
+ 'supportedControl',
+ 'supportedExtension',
+ 'supportedSASLMechanisms',
+ 'vendorName',
+ 'vendorVersion')
class TopologyStandalone(object):
def __init__(self, standalone):
@@ -97,6 +104,38 @@ def import_example_ldif(topology):
assert False
+(a)pytest.fixture(params=ROOTDSE_DEF_ATTR_LIST)
+def rootdse_attr(topology, request):
+ """Adds an attr from the list
+ as the default attr to the rootDSE
+ """
+
+ RETURN_DEFAULT_OPATTR = "nsslapd-return-default-opattr"
+ rootdse_attr_name = request.param
+
+ log.info(" Add the %s: %s to rootdse" % (RETURN_DEFAULT_OPATTR,
+ rootdse_attr_name))
+ mod = [(ldap.MOD_ADD, RETURN_DEFAULT_OPATTR, rootdse_attr_name)]
+ try:
+ topology.standalone.modify_s("", mod)
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add attr: error (%s)' % (e.message['desc']))
+ assert False
+
+ def fin():
+ log.info(" Delete the %s: %s from rootdse" % (RETURN_DEFAULT_OPATTR,
+ rootdse_attr_name))
+ mod = [(ldap.MOD_DELETE, RETURN_DEFAULT_OPATTR, rootdse_attr_name)]
+ try:
+ topology.standalone.modify_s("", mod)
+ except ldap.LDAPError as e:
+ log.fatal('Failed to delete attr: error (%s)' % (e.message['desc']))
+ assert False
+ request.addfinalizer(fin)
+
+ return rootdse_attr_name
+
+
def test_basic_ops(topology, import_example_ldif):
"""Test doing adds, mods, modrdns, and deletes"""
@@ -695,6 +734,39 @@ def test_basic_dse(topology, import_example_ldif):
log.info('test_basic_dse: PASSED')
+(a)pytest.mark.parametrize("rootdse_attr_name", ROOTDSE_DEF_ATTR_LIST)
+def test_def_rootdse_attr(topology, import_example_ldif, rootdse_attr_name):
+ """Tests that operational attributes
+ are not returned by default in rootDSE searches
+ """
+
+ log.info(" Assert rootdse search hasn't %s attr" % rootdse_attr_name)
+ try:
+ entries = topology.standalone.search_s("", ldap.SCOPE_BASE)
+ entry = str(entries[0])
+ assert rootdse_attr_name not in entry
+
+ except ldap.LDAPError as e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ assert False
+
+
+def test_mod_def_rootdse_attr(topology, import_example_ldif, rootdse_attr):
+ """Tests that operational attributes are returned
+ by default in rootDSE searches after config modification
+ """
+
+ log.info(" Assert rootdse search has %s attr" % rootdse_attr)
+ try:
+ entries = topology.standalone.search_s("", ldap.SCOPE_BASE)
+ entry = str(entries[0])
+ assert rootdse_attr in entry
+
+ except ldap.LDAPError as e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ assert False
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months
dirsrvtests/suites
by Mark Reynolds
dirsrvtests/suites/basic/basic_test.py | 72 +++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
New commits:
commit cb950de1414e6b04bd09587bee7090a00ada15fe
Author: Simon Pichugin <spichugi(a)redhat.com>
Date: Mon Aug 31 10:54:21 2015 +0200
Ticket 47761 - Added a few testcases to the basic testsuite
Description: New testcases test the feature that adds a posibility
to change the behavior of rootDSE searches. Namely,
the default list of returned operational attributes.
https://fedorahosted.org/389/ticket/47761
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py
index c6ac74b..9aec8ef 100644
--- a/dirsrvtests/suites/basic/basic_test.py
+++ b/dirsrvtests/suites/basic/basic_test.py
@@ -31,6 +31,13 @@ USER1_DN = 'uid=user1,' + DEFAULT_SUFFIX
USER2_DN = 'uid=user2,' + DEFAULT_SUFFIX
USER3_DN = 'uid=user3,' + DEFAULT_SUFFIX
+ROOTDSE_DEF_ATTR_LIST = ('namingContexts',
+ 'supportedLDAPVersion',
+ 'supportedControl',
+ 'supportedExtension',
+ 'supportedSASLMechanisms',
+ 'vendorName',
+ 'vendorVersion')
class TopologyStandalone(object):
def __init__(self, standalone):
@@ -97,6 +104,38 @@ def import_example_ldif(topology):
assert False
+(a)pytest.fixture(params=ROOTDSE_DEF_ATTR_LIST)
+def rootdse_attr(topology, request):
+ """Adds an attr from the list
+ as the default attr to the rootDSE
+ """
+
+ RETURN_DEFAULT_OPATTR = "nsslapd-return-default-opattr"
+ rootdse_attr_name = request.param
+
+ log.info(" Add the %s: %s to rootdse" % (RETURN_DEFAULT_OPATTR,
+ rootdse_attr_name))
+ mod = [(ldap.MOD_ADD, RETURN_DEFAULT_OPATTR, rootdse_attr_name)]
+ try:
+ topology.standalone.modify_s("", mod)
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add attr: error (%s)' % (e.message['desc']))
+ assert False
+
+ def fin():
+ log.info(" Delete the %s: %s from rootdse" % (RETURN_DEFAULT_OPATTR,
+ rootdse_attr_name))
+ mod = [(ldap.MOD_DELETE, RETURN_DEFAULT_OPATTR, rootdse_attr_name)]
+ try:
+ topology.standalone.modify_s("", mod)
+ except ldap.LDAPError as e:
+ log.fatal('Failed to delete attr: error (%s)' % (e.message['desc']))
+ assert False
+ request.addfinalizer(fin)
+
+ return rootdse_attr_name
+
+
def test_basic_ops(topology, import_example_ldif):
"""Test doing adds, mods, modrdns, and deletes"""
@@ -695,6 +734,39 @@ def test_basic_dse(topology, import_example_ldif):
log.info('test_basic_dse: PASSED')
+(a)pytest.mark.parametrize("rootdse_attr_name", ROOTDSE_DEF_ATTR_LIST)
+def test_def_rootdse_attr(topology, import_example_ldif, rootdse_attr_name):
+ """Tests that operational attributes
+ are not returned by default in rootDSE searches
+ """
+
+ log.info(" Assert rootdse search hasn't %s attr" % rootdse_attr_name)
+ try:
+ entries = topology.standalone.search_s("", ldap.SCOPE_BASE)
+ entry = str(entries[0])
+ assert rootdse_attr_name not in entry
+
+ except ldap.LDAPError as e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ assert False
+
+
+def test_mod_def_rootdse_attr(topology, import_example_ldif, rootdse_attr):
+ """Tests that operational attributes are returned
+ by default in rootDSE searches after config modification
+ """
+
+ log.info(" Assert rootdse search has %s attr" % rootdse_attr)
+ try:
+ entries = topology.standalone.search_s("", ldap.SCOPE_BASE)
+ entry = str(entries[0])
+ assert rootdse_attr in entry
+
+ except ldap.LDAPError as e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ assert False
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months
Branch '389-ds-base-1.3.4' - 4 commits -
by Noriko Hosoi
0 files changed
New commits:
commit 7638651f7480f06857ce4a4c756a974c39d11e32
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Aug 25 11:48:31 2015 -0700
Ticket #48254 - Shell CLI fails with usage errors if an argument containing white spaces is given
Description: In addition to the patch:
Ticket #48254 - CLI db2index fails with usage errors
commit 3507c46c9f1156df11b6cf05eba695d81088b416
applying the similar changes to all the shell CLI which could be given
arguments that include white spaces.
https://fedorahosted.org/389/ticket/48254
Reviewed by mreynolds(a)redhat.com (Thank you, Mark!!)
(cherry picked from commit 5fe28921810a53dcd31525ba1f675582b6aba0f7)
(cherry picked from commit 0584156ba21823c138f91a68b9a0715fd81f82f7)
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index a2e54cc..ab7c6b3 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -44,12 +44,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
q) args=$args" -q";;
- d) args=$args" -d $OPTARG";;
+ d) args=$args" -d \"$OPTARG\"";;
v) args=$args" -v";;
- D) args=$args" -D $OPTARG";;
- i) args=$args" -i $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
+ i) args=$args" -i \"$OPTARG\"";;
a) archivedir=$OPTARG;;
S) args=$args" -S";;
?) usage
@@ -76,4 +76,4 @@ else
archivedir=`pwd`/$archivedir
fi
-@sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
+eval @sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index 1896c19..adbe30b 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -43,10 +43,10 @@ do
q) args=$args" -q";;
v) args=$args" -v";;
S) args=$args" -S";;
- D) args=$args" -D $OPTARG";;
- i) args=$args" -i $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
+ i) args=$args" -i \"$OPTARG\"";;
a) $bakdir=$OPTARG;;
- d) args=$args" -d $OPTARG";;
+ d) args=$args" -d \"$OPTARG\"";;
Z) servid=$OPTARG;;
?) usage
exit 1;;
@@ -72,4 +72,4 @@ then
fi
echo "Back up directory: $bak_dir"
-@sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
+eval @sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index 6a0785e..c8e9075 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -35,15 +35,15 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG"
+ n) args=$args" -n \"$OPTARG\""
benameopt="set";;
- s) args=$args" -s $OPTARG"
+ s) args=$args" -s \"$OPTARG\""
includeSuffix="set";;
t) args=$args" -t "\"$OPTARG\";;
T) args=$args" -T "\"$OPTARG\";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG";;
- x) args=$args" -x $OPTARG";;
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\"";;
+ x) args=$args" -x \"$OPTARG\"";;
v) args=$args" -v";;
S) args=$args" -S";;
D) args=$args" -D $OPTARG";;
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index fcf73a0..e9f7f7e 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -106,12 +106,12 @@ do
Z) servid=$OPTARG;;
n) benameopt="-n $OPTARG"
required_param="yes";;
- s) includeSuffix="-s $OPTARG"
+ s) includeSuffix="-s \"$OPTARG\""
required_param="yes";;
- x) excludeSuffix="-x $OPTARG";;
- a) outputFile="-a $OPTARG";;
- d) args=$args" -d $OPTARG";;
- D) args=$args" -D $OPTARG";;
+ x) excludeSuffix="-x \"$OPTARG\"";;
+ a) outputFile="-a \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
+ D) args=$args" -D \"$OPTARG\"";;
N) args=$args" -N";;
E) args=$args" -E";;
S) args=$args" -S";;
@@ -154,7 +154,7 @@ rn=$?
echo "Exported ldif file: $ldif_file"
if [ $rn -eq 1 ]
then
- @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
+ eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
else
- @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
+ eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
fi
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index bbacc17..b98e9b2 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -33,14 +33,14 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG";;
- d) args=$args" -d $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
V) args=$args" -V";;
v) args=$args" -v"
display_version="yes";;
f) args=$args" -f";;
- D) args=$args" -D $OPTARG";;
- a) args=$args" -a $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\"";;
?) usage
exit 1;;
esac
@@ -57,7 +57,7 @@ fi
. $initfile
-@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
if [ $display_version = "yes" ]; then
exit 0
fi
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 616969a..762e63a 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -27,12 +27,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- d) arg=$arg" -d $OPTARG";;
- a) arg=$arg" -a $OPTARG"
+ d) arg=$arg" -d \"$OPTARG\"";;
+ a) arg=$arg" -a \"$OPTARG\""
archive="provided";;
v) arg=$arg" -v";;
f) arg=$arg" -f";;
- D) arg=$arg" -D $OPTARG";;
+ D) arg=$arg" -D \"$OPTARG\"";;
?) usage
exit 1;;
esac
@@ -55,4 +55,4 @@ if [ "$archive" != "provided" ]; then
args=$args"-a $bak_dir"
fi
-@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
+eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index a34241a..3aed469 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -59,16 +59,16 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG";;
- i) args=$args" -i $OPTARG";;
- s) args=$args" -s $OPTARG";;
- x) args=$args" -x $OPTARG";;
- c) args=$args" -c $OPTARG";;
- d) args=$args" -d $OPTARG";;
- g) args=$args" -g $OPTARG";;
- G) args=$args" -G $OPTARG";;
- t) args=$args" -t $OPTARG";;
- D) args=$args" -D $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
+ i) args=$args" -i \"$OPTARG\"";;
+ s) args=$args" -s \"$OPTARG\"";;
+ x) args=$args" -x \"$OPTARG\"";;
+ c) args=$args" -c \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
+ g) args=$args" -g \"$OPTARG\"";;
+ G) args=$args" -G \"$OPTARG\"";;
+ t) args=$args" -t \"$OPTARG\"";;
+ D) args=$args" -D \"$OPTARG\"";;
E) args=$args" -E";;
v) args=$args" -v";;
N) args=$args" -N";;
@@ -104,6 +104,6 @@ if [ $quiet -eq 0 ]; then
echo importing data ...
fi
-@sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
+eval @sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
exit $?
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index 36a2fc9..e9265a1 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -73,8 +73,8 @@ fi
rm $file
if [ -n "$passwd" ]; then
- dn="-D $rootdn"
- passwd="-w$passwd"
+ dn="-D \"$rootdn\""
+ passwd="-w \"$passwd\""
fi
if [ -n "$ldapiURL" ]
then
@@ -109,9 +109,9 @@ if [ "$security" = "on" ]; then
echo "Using the next most secure protocol(STARTTLS)"
fi
if [ "$openldap" = "yes" ]; then
- ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ eval ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
- ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ eval ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
fi
exit $?
fi
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index 7774148..d7c6661 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -24,7 +24,7 @@ while getopts "Z:s:h" flag
do
case $flag in
Z) servid=$OPTARG;;
- s) args=$args" -s $OPTARG";;
+ s) args=$args" -s \"$OPTARG\"";;
h) usage
exit 0;;
?) usage
@@ -55,4 +55,4 @@ then
exit 1
fi
-@sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
+eval @sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index bf600dd..2b7c79d 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -29,10 +29,10 @@ do
v) args=$args" -v";;
f) args=$args" -f";;
r) args=$args" -r";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG"
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\""
archive_provided="yes";;
- D) args=$args" -D $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
h) usage
exit 0;;
esac
@@ -56,4 +56,4 @@ then
fi
echo upgrade index files ...
-@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index 51585ae..9de60ea 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -36,14 +36,14 @@ do
Z) servid=$OPTARG;;
v) args=$args" -v";;
N) args=$args" -N";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG"
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\""
dir="set";;
- n) args=$args" -n $OPTARG"
+ n) args=$args" -n \"$OPTARG\""
be="set";;
h) usage
exit 0;;
- D) args=$args" -D $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
?) usage
exit 1;;
esac
@@ -65,7 +65,7 @@ fi
. $initfile
-@sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
rc=$?
exit $rc
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index 365e32f..a1696bc 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -29,14 +29,14 @@ do
case $flag in
Z) servid=$OPTARG;;
v) args=$args" -v";;
- s) args=$args" -s $OPTARG";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG";;
- T) args=$args" -T $OPTARG";;
+ s) args=$args" -s \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\"";;
+ T) args=$args" -T \"$OPTARG\"";;
S) args=$args" -S";;
- n) args=$args" -n $OPTARG";;
- x) args=$args" -x $OPTARG";;
- D) args=$args" -D $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
+ x) args=$args" -x \"$OPTARG\"";;
+ D) args=$args" -D \"$OPTARG\"";;
h) usage
exit 0;;
?) usage
@@ -61,4 +61,4 @@ then
exit 1
fi
-@sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
commit 06839791662c0e2847407d36b30fa0794e6522c3
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Aug 10 17:04:25 2015 -0700
Ticket #47511 - bashisms in 389-ds-base admin scripts
Description by mvocu (Thank you):
The shell scripts in 389-ds-base/ldap/admin/src/scripts use 'source'
to source common scripts; the 'source' keyword is bash-specific (or
c-shell, if memory serves). The interpreter is set to /bin/sh, which
is not guaranteed to be bash (and at least on Debian 7.1 it is dash).
The 'source' keyword can be replaced by '.', which should work.
Thanks to Rowan Thorpe (rowan(a)rowanthorpe.com) for providing us the
patch.
Note: The comment of commit 2ce7a7334bcb89e47c0f5c544144aec37010a5b9
had an incorrect credit, which is fixed by this commit.
https://fedorahosted.org/389/ticket/47511
Reviewed and tested by nhosoi(a)redhat.com.
(cherry picked from commit 2ce7a7334bcb89e47c0f5c544144aec37010a5b9)
(cherry picked from commit b35286b78abffc3ce93db838a0a1c8310b10ff2f)
diff --git a/ldap/admin/src/initconfig.in b/ldap/admin/src/initconfig.in
index 134e82c..7afa315 100644
--- a/ldap/admin/src/initconfig.in
+++ b/ldap/admin/src/initconfig.in
@@ -2,11 +2,11 @@
OS=`uname -s`
# use the new mt slab memory allocator on Solaris
# this requires Solaris 9 update 3 or later
-if [ "$OS" = "SunOS" -a -f /usr/lib/libumem.so ] ; then
+if [ "$OS" = "SunOS" ] && [ -f /usr/lib/libumem.so ] ; then
LD_PRELOAD=/usr/lib/libumem.so
export LD_PRELOAD
fi
-if [ "$OS" = "SunOS" -a -f /usr/lib/64/libumem.so ] ; then
+if [ "$OS" = "SunOS" ] && [ -f /usr/lib/64/libumem.so ] ; then
LD_PRELOAD_64=/usr/lib/64/libumem.so
export LD_PRELOAD_64
fi
diff --git a/ldap/admin/src/scripts/DSSharedLib.in b/ldap/admin/src/scripts/DSSharedLib.in
index 3683696..8317c58 100644
--- a/ldap/admin/src/scripts/DSSharedLib.in
+++ b/ldap/admin/src/scripts/DSSharedLib.in
@@ -98,13 +98,13 @@ get_init_file()
do
inst_count=`expr $inst_count + 1`
id=`normalize_server_id $configfile`
- if [ -n "$servid" -a "$id" = "$servid" ]
+ if [ -n "$servid" ] && [ "$id" = "$servid" ]
then
# found it
echo $configfile
exit 0
fi
- if [ $first == "yes" ]
+ if [ $first = "yes" ]
then
instances=$id
first="no"
@@ -114,7 +114,7 @@ get_init_file()
done
# server id not provided, check if there is only one instance
- if [ -z "$servid" -a $inst_count -eq 1 ]
+ if [ -z "$servid" ] && [ $inst_count -eq 1 ]
then
# return the file
echo $configfile
@@ -135,48 +135,44 @@ process_dse ()
configdir=$1
pid=$2
file="$configdir/dse.ldif"
- shopt -s nocasematch
- OLD_IFC=$IFC
+ OLD_IFS=$IFS
IFS=""
while read -r LINE
do
- if [[ $LINE != \ * ]] && [ "$output" != "" ]
+ case $LINE in
+ ' '*)
+ ;;
+ *)
+ if [ -n "$output" ]
+ then
+ echo "$output" >> /tmp/DSSharedLib.$pid
+ output=""
+ fi
+ ;;
+ esac
+ if [ -n "$output" ]
then
- echo "$output" >> /tmp/DSSharedLib.$pid
- output=""
- fi
- if [ "$output" != "" ] && [[ $LINE == \ * ]]
- then
- # continuation line, strip the space and append it
- LINE=`echo "$LINE" | sed -e 's/^ //'`
- output=$output$LINE
- elif [[ $LINE == nsslapd-port* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-localhost* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-securePort* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-security* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-ldapilisten* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-ldapifilepath* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-rootdn* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-ldapiautobind* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-certdir* ]]
- then
- output=$LINE;
+ case $LINE in
+ ' '*)
+ # continuation line, strip the space and append it
+ LINE=`echo "$LINE" | sed -e 's/^ //'`
+ output=$output$LINE
+ ;;
+ esac
+ else
+ case $LINE in
+ nsslapd-certdir*|\
+ nsslapd-ldapiautobind*|\
+ nsslapd-ldapilisten*|\
+ nsslapd-ldapifilepath*|\
+ nsslapd-localhost*|\
+ nsslapd-port*|\
+ nsslapd-rootdn*|\
+ nsslapd-securePort*|\
+ nsslapd-security*)
+ output=$LINE
+ ;;
+ esac
fi
done < $file
@@ -194,19 +190,19 @@ check_protocol ()
ldapi=$3
openldap=$4
- if [ "$protocol" == "LDAPI" ] && [ "$openldap" != "yes" ]; then
+ if [ "$protocol" = "LDAPI" ] && [ "$openldap" != "yes" ]; then
echo ""
exit
- elif [ "$protocol" == "LDAPI" ] && [ "$ldapi" == "off" ]; then
+ elif [ "$protocol" = "LDAPI" ] && [ "$ldapi" = "off" ]; then
echo ""
exit
- elif [ "$protocol" == "STARTTLS" ]; then
- if [ "$security" == "" ] || [ "$security" == "off" ]; then
+ elif [ "$protocol" = "STARTTLS" ]; then
+ if [ -z "$security" ] || [ "$security" = "off" ]; then
echo ""
exit
fi
- elif [ "$protocol" == "LDAPS" ]; then
- if [ "$security" == "" ] || [ "$security" == "off" ]; then
+ elif [ "$protocol" = "LDAPS" ]; then
+ if [ -z "$security" ] || [ "$security" = "off" ]; then
echo ""
exit
fi
@@ -224,4 +220,4 @@ check_protocol ()
fi
echo "$protocol"
-}
\ No newline at end of file
+}
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index f0cede4..a2e54cc 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -26,15 +26,18 @@ if [ $# -lt 1 ] || [ $# -gt 7 ]
then
usage
exit 1
-elif [[ $1 == -* ]]
-then
- usage
- exit 1
-else
- archivedir=$1
- shift
fi
-
+case $1 in
+ -*)
+ usage
+ exit 1
+ ;;
+ *)
+ archivedir=$1
+ shift
+ ;;
+esac
+
while getopts "hn:Z:qd:vi:a:SD:" flag
do
case $flag in
@@ -55,7 +58,7 @@ do
done
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"
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index dacd7b0..1896c19 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -26,7 +26,6 @@ then
usage
exit 1
fi
-
if [ "$#" -gt 0 ]
then
if [[ $1 != -* ]]
@@ -56,7 +55,7 @@ done
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,7 +66,7 @@ fi
servid=`normalize_server_id $initfile`
. $initfile
-if [ -z $bak_dir ]
+if [ -z "$bak_dir" ]
then
bak_dir=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H_%M_%S`
fi
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index 9af8fc8..6a0785e 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -59,7 +59,7 @@ then
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"
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index d7e0ff0..fcf73a0 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -39,7 +39,7 @@ make_ldiffile()
be=""
while [ "$1" != "" ]
do
- if [ "$1" = "-a" ]; then
+ if [ "x$1" = "x-a" ]; then
shift
if [ `expr "$1" : "/.*"` -gt 0 ]; then
if [ `expr "$1" : "/.*"` -gt 0 ]; then
@@ -56,17 +56,17 @@ make_ldiffile()
shift
return 0
fi
- elif [ "$1" = "-n" ]; then
+ elif [ "x$1" = "x-n" ]; then
shift
- if [ "$be" = "" ]; then
+ if [ -z "$be" ]; then
be="$1"
else
tmpbe="$be"
be="${tmpbe}-$1"
fi
- elif [ "$1" = "-s" ]; then
+ elif [ "x$1" = "x-s" ]; then
shift
- if [ "$1" != "" ]; then
+ if [ -n "$1" ]; then
rdn=`echo $1 | awk -F, '{print $1}'`
rdnval=`echo $rdn | awk -F= '{print $2}'`
if [ "$be" = "" ]; then
@@ -76,15 +76,15 @@ make_ldiffile()
be="${tmpbe}-$rdnval"
fi
fi
- elif [ "$1" = "-M" ]; then
+ elif [ "x$1" = "x-M" ]; then
be=""
fi
- if [ "$1" != "" ]; then
+ if [ -n "$1" ]; then
shift
fi
done
- if [ "$be" = "" ]; then
+ if [ -z "$be" ]; then
echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
else
echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-${be}-`date +%Y_%m_%d_%H%M%S`.ldif
@@ -92,7 +92,7 @@ make_ldiffile()
return 0
}
-if [ "$#" -lt 2 ];
+if [ $# -lt 2 ];
then
usage
exit 1
@@ -137,7 +137,7 @@ then
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"
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index 461cc16..bbacc17 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -47,7 +47,7 @@ do
done
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"
@@ -58,7 +58,7 @@ fi
. $initfile
@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
-if [ $display_version == "yes" ]; then
+if [ $display_version = "yes" ]; then
exit 0
fi
if [ $? -eq 0 ]; then
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 32a70c8..616969a 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -39,7 +39,7 @@ do
done
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"
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index ce15349..a34241a 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -82,7 +82,7 @@ do
done
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"
diff --git a/ldap/admin/src/scripts/ldif2ldap.in b/ldap/admin/src/scripts/ldif2ldap.in
index 874b1bb..1e871be 100755
--- a/ldap/admin/src/scripts/ldif2ldap.in
+++ b/ldap/admin/src/scripts/ldif2ldap.in
@@ -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
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index 7b2058b..36a2fc9 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@ldapsdk_libdir@"
@@ -41,7 +41,7 @@ do
done
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"
@@ -66,17 +66,17 @@ 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 [ "$passwd" != "" ]; then
+if [ -n "$passwd" ]; then
dn="-D $rootdn"
passwd="-w$passwd"
fi
-if [ "$ldapiURL" != "" ]
+if [ -n "$ldapiURL" ]
then
ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'`
ldapiURL="ldapi://"$ldapiURL
@@ -103,12 +103,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
ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -120,12 +120,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
ldapsearch -x -LLL -H "ldaps://$host:$secure_port" -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -Z -P $certdir -p $secure_port -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -137,15 +137,15 @@ 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
ldapsearch -LLL -H "$ldapiURL" -b "$MDN" -s base -Y EXTERNAL "objectClass=*" 2>/dev/null
else
- if [ "$error" == "yes" ]; then
+ if [ "$error" = "yes" ]; then
echo "Using the next most secure protocol(LDAPI)"
fi
ldapsearch -x -LLL -H "$ldapiURL" -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -157,14 +157,14 @@ fi
#
# LDAP
#
-if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then
- if [ "$error" == "yes" ]; then
+if [ "$protocol" = "LDAP" ] || [ "$protocol" = "" ]; then
+ if [ "$error" = "yes" ]; then
echo "Using the next most secure protocol(LDAP)"
fi
- if [ "$openldap" == "yes" ]; then
+ if [ "$openldap" = "yes" ]; then
ldapsearch -x -LLL -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
- fi
+ fi
exit $?
fi
diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in
index 130e06e..e86a24c 100644
--- a/ldap/admin/src/scripts/restart-dirsrv.in
+++ b/ldap/admin/src/scripts/restart-dirsrv.in
@@ -7,7 +7,7 @@
# 2: Server started successfully (was not running)
# 3: Server could not be stopped
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
restart_instance() {
SERV_ID=$1
diff --git a/ldap/admin/src/scripts/restoreconfig.in b/ldap/admin/src/scripts/restoreconfig.in
index 9bb1acf..56c9e43 100755
--- a/ldap/admin/src/scripts/restoreconfig.in
+++ b/ldap/admin/src/scripts/restoreconfig.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -31,7 +31,7 @@ do
done
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"
diff --git a/ldap/admin/src/scripts/saveconfig.in b/ldap/admin/src/scripts/saveconfig.in
index 65d80f3..16e3efc 100755
--- a/ldap/admin/src/scripts/saveconfig.in
+++ b/ldap/admin/src/scripts/saveconfig.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -31,7 +31,7 @@ do
done
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"
@@ -45,7 +45,7 @@ servid=`normalize_server_id $initfile`
echo saving configuration...
conf_ldif=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
@sbindir@/ns-slapd db2ldif -N -D $CONFIG_DIR -s "o=NetscapeRoot" -a $conf_ldif -n NetscapeRoot 2>&1
-if [ "$?" -ge 1 ]
+if [ $? -ge 1 ]
then
echo Error occurred while saving configuration
exit 1
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
index 481797d..458f0e8 100755
--- a/ldap/admin/src/scripts/start-dirsrv.in
+++ b/ldap/admin/src/scripts/start-dirsrv.in
@@ -6,7 +6,7 @@
# 1: Server could not be started
# 2: Server already running
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
# Starts a single instance
start_instance() {
@@ -44,7 +44,7 @@ start_instance() {
STARTPIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.startpid
if test -f $STARTPIDFILE ; then
PID=`cat $STARTPIDFILE`
- if kill -0 $PID > /dev/null 2>&1 ; then
+ if kill -s 0 $PID > /dev/null 2>&1 ; then
echo There is an ns-slapd process already running: $PID
return 2;
else
@@ -53,7 +53,7 @@ start_instance() {
fi
if test -f $PIDFILE ; then
PID=`cat $PIDFILE`
- if kill -0 $PID > /dev/null 2>&1 ; then
+ if kill -s 0 $PID > /dev/null 2>&1 ; then
echo There is an ns-slapd running: $PID
return 2;
else
@@ -64,7 +64,7 @@ start_instance() {
# Use systemctl if available and running as root,
# otherwise start the instance the old way.
#
- if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
+ if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
@bindir@/systemctl start @package_name@(a)$SERV_ID.service
if [ $? -ne 0 ]; then
return 1
@@ -96,7 +96,7 @@ start_instance() {
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $PIDFILE ; then
- if kill -0 $PID > /dev/null 2>&1 ; then
+ if kill -s 0 $PID > /dev/null 2>&1 ; then
sleep 1
else
echo Server failed to start !!! Please check errors log for problems
@@ -123,12 +123,12 @@ do
done
shift $(($OPTIND-1))
-if [ "$initconfig_dir" = "" ]; then
+if [ -z "$initconfig_dir" ]; then
initconfig_dir=@initconfigdir@
fi
found=0
-if [ "$#" -eq 0 ]; then
+if [ $# -eq 0 ]; then
# We're starting all instances.
ret=0
initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
@@ -137,7 +137,7 @@ if [ "$#" -eq 0 ]; then
echo Starting instance \"$inst\"
start_instance $inst
rv=$?
- if [ "$rv" -ne 0 ]; then
+ if [ $rv -ne 0 ]; then
ret=$rv
fi
done
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
index 3f02e78..72e2b85 100755
--- a/ldap/admin/src/scripts/stop-dirsrv.in
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
@@ -6,7 +6,7 @@
# 1: Server could not be stopped
# 2: Server was not running
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
stop_instance() {
SERV_ID=$1
@@ -28,7 +28,7 @@ stop_instance() {
fi
PID=`cat $PIDFILE`
# see if the server is already stopped
- kill -0 $PID > /dev/null 2>&1 || {
+ kill -s 0 $PID > /dev/null 2>&1 || {
echo Server not running
if test -f $PIDFILE ; then
rm -f $PIDFILE
@@ -39,7 +39,7 @@ stop_instance() {
#
# use systemctl if running as root
#
- if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
+ if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
#
# Now, check if systemctl is aware of this running instance
#
@@ -65,7 +65,7 @@ stop_instance() {
max_count=600
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -0 $PID > /dev/null 2>&1 ; then
+ if kill -s 0 $PID > /dev/null 2>&1 ; then
sleep 1;
else
if test -f $PIDFILE ; then
@@ -88,11 +88,11 @@ do
done
shift $(($OPTIND-1))
-if [ "$initconfig_dir" = "" ]; then
+if [ -z "$initconfig_dir" ]; then
initconfig_dir=@initconfigdir@
fi
-if [ "$#" -eq 0 ]; then
+if [ $# -eq 0 ]; then
# We're stopping all instances.
ret=0
initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
@@ -105,7 +105,7 @@ if [ "$#" -eq 0 ]; then
echo Stopping instance \"$inst\"
stop_instance $inst
rv=$?
- if [ "$rv" -ne 0 ]; then
+ if [ $rv -ne 0 ]; then
ret=$rv
fi
done
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index e2f73c3..7774148 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -32,14 +32,14 @@ do
esac
done
-if [ "$args" == "" ]
+if [ -z "$args" ]
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"
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index 211bdce..bf600dd 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -39,7 +39,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? == 1 ]
+if [ $? -eq 1 ]
then
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
echo "Available instances: $initfile"
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index e9d8cab..51585ae 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
# upgradednformat -- upgrade DN format to the new style (RFC 4514)
# Usgae: upgradednformat [-N] -n backend_instance -a db_instance_directory
@@ -49,13 +49,13 @@ do
esac
done
-if [ "$be" = "" ] || [ "$dir" = "" ]; then
+if [ -z "$be" ] || [ -z "$dir" ]; 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"
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index 0b46b27..365e32f 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -45,7 +45,7 @@ do
done
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"
diff --git a/rpm/389-ds-base-git.sh b/rpm/389-ds-base-git.sh
index e5aaa8a..1a38da1 100644
--- a/rpm/389-ds-base-git.sh
+++ b/rpm/389-ds-base-git.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
DATE=`date +%Y%m%d`
# use a real tag name here
diff --git a/rpm/add_patches.sh b/rpm/add_patches.sh
index 690d0b2..31823d5 100755
--- a/rpm/add_patches.sh
+++ b/rpm/add_patches.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-function usage()
+usage()
{
echo "Adds patches to a specfile"
echo ""
@@ -51,5 +51,5 @@ for p in $patches; do
sed -i -e "/${prefix}/a Patch${i}: ${p}" -e "/$prepprefix/a %patch${i} -p1" $specfile
prefix="Patch${i}:"
prepprefix="%patch${i}"
- i=$(($i+1))
+ i=`expr $i + 1`
done
diff --git a/rpm/rpmverrel.sh b/rpm/rpmverrel.sh
index 86b808e..06e97c7 100755
--- a/rpm/rpmverrel.sh
+++ b/rpm/rpmverrel.sh
@@ -6,7 +6,7 @@ srcdir=`pwd`
# Source VERSION.sh to set the version
# and release environment variables.
-source ./VERSION.sh
+. ./VERSION.sh
if [ "$1" = "version" ]; then
echo $RPM_VERSION
diff --git a/wrappers/initscript.in b/wrappers/initscript.in
index ad4ea2b..fa79dbd 100644
--- a/wrappers/initscript.in
+++ b/wrappers/initscript.in
@@ -32,28 +32,20 @@ then
fi
fi
-# figure out which echo we're using
-ECHO_N=`echo -n`
-
-# some shells echo cannot use -n - linux echo by default cannot use \c
echo_n()
{
- if [ "$ECHO_N" = '-n' ] ; then
- echo "$*\c"
- else
- echo -n "$*"
- fi
+ printf '%s' "$*"
}
# failure and success are not defined on some platforms
-type failure > /dev/null 2>&1 || {
+which failure > /dev/null 2>&1 || {
failure()
{
echo_n " FAILED"
}
}
-type success > /dev/null 2>&1 || {
+which success > /dev/null 2>&1 || {
success()
{
echo_n " SUCCESS"
@@ -178,7 +170,7 @@ start() {
pid=`cat $pidfile`
instlockfile="@localstatedir@/lock/@package_name@/slapd-$instance/server/$pid"
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -0 $pid && [ $name = "ns-slapd" ]; then
+ if kill -s 0 $pid && [ $name = "ns-slapd" ]; then
echo_n " already running"
success; echo
successes=`expr $successes + 1`
@@ -239,7 +231,7 @@ start() {
while test $loop_counter -le $max_count ; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $pidfile ; then
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
sleep 1
else
break
@@ -249,7 +241,7 @@ start() {
break
fi
done
- if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
+ if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
success; echo
successes=`expr $successes + 1`
else
@@ -278,7 +270,7 @@ stop() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
server_stopped=0
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
server_stopped=1
@@ -297,7 +289,7 @@ stop() {
max_count=600
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
sleep 1
else
if test -f $pidfile ; then
@@ -339,7 +331,7 @@ status() {
for instance in $INSTANCES; do
if [ -f $piddir/slapd-$instance.pid ]; then
pid=`cat $piddir/slapd-$instance.pid`
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
echo "$prog $instance (pid $pid) is running..."
else
echo "$prog $instance dead but pid file exists"
diff --git a/wrappers/ldap-agent-initscript.in b/wrappers/ldap-agent-initscript.in
index dd8ee97..b7aa4fe 100644
--- a/wrappers/ldap-agent-initscript.in
+++ b/wrappers/ldap-agent-initscript.in
@@ -31,28 +31,20 @@ then
fi
fi
-# figure out which echo we're using
-ECHO_N=`echo -n`
-
-# some shells echo cannot use -n - linux echo by default cannot use \c
echo_n()
{
- if [ "$ECHO_N" = '-n' ] ; then
- echo "$*\c"
- else
- echo -n "$*"
- fi
+ printf '%s' "$*"
}
# failure and success are not defined on some platforms
-type failure > /dev/null 2>&1 || {
+which failure > /dev/null 2>&1 || {
failure()
{
echo_n " FAILED"
}
}
-type success > /dev/null 2>&1 || {
+which success > /dev/null 2>&1 || {
success()
{
echo_n " SUCCESS"
@@ -92,7 +84,7 @@ start() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -0 $pid && [ $name = "$processname" ]; then
+ if kill -s 0 $pid && [ $name = "$processname" ]; then
echo_n " already running"
success; echo
subagent_running=1
@@ -121,7 +113,7 @@ start() {
while test $loop_counter -le $max_count ; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $pidfile ; then
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
sleep 1
else
break
@@ -131,7 +123,7 @@ start() {
break
fi
done
- if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
+ if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
success; echo
else
failure; echo
@@ -147,7 +139,7 @@ stop() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
subagent_stopped=0
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
subagent_stopped=1
@@ -164,7 +156,7 @@ stop() {
max_count=10
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
sleep 1
else
if test -f $pidfile ; then
@@ -200,7 +192,7 @@ condrestart() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -0 $pid && [ $name = "$processname" ]; then
+ if kill -s 0 $pid && [ $name = "$processname" ]; then
restart
fi
fi
@@ -210,7 +202,7 @@ status() {
ret=0
if [ -f $pidfile ]; then
pid=`cat $pidfile`
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
echo "$prog (pid $pid) is running..."
else
echo "$prog dead but pid file exists"
commit 5429ef3230b050bfe0cbeca0d00d705f829f9d17
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Sep 14 11:21:42 2015 -0700
Revert "Ticket #47511 - bashisms in 389-ds-base admin scripts"
This reverts commit 49245911410cdd04bc53b00d8973c26defa5a37b.
diff --git a/ldap/admin/src/initconfig.in b/ldap/admin/src/initconfig.in
index 7afa315..134e82c 100644
--- a/ldap/admin/src/initconfig.in
+++ b/ldap/admin/src/initconfig.in
@@ -2,11 +2,11 @@
OS=`uname -s`
# use the new mt slab memory allocator on Solaris
# this requires Solaris 9 update 3 or later
-if [ "$OS" = "SunOS" ] && [ -f /usr/lib/libumem.so ] ; then
+if [ "$OS" = "SunOS" -a -f /usr/lib/libumem.so ] ; then
LD_PRELOAD=/usr/lib/libumem.so
export LD_PRELOAD
fi
-if [ "$OS" = "SunOS" ] && [ -f /usr/lib/64/libumem.so ] ; then
+if [ "$OS" = "SunOS" -a -f /usr/lib/64/libumem.so ] ; then
LD_PRELOAD_64=/usr/lib/64/libumem.so
export LD_PRELOAD_64
fi
diff --git a/ldap/admin/src/scripts/DSSharedLib.in b/ldap/admin/src/scripts/DSSharedLib.in
index 8317c58..3683696 100644
--- a/ldap/admin/src/scripts/DSSharedLib.in
+++ b/ldap/admin/src/scripts/DSSharedLib.in
@@ -98,13 +98,13 @@ get_init_file()
do
inst_count=`expr $inst_count + 1`
id=`normalize_server_id $configfile`
- if [ -n "$servid" ] && [ "$id" = "$servid" ]
+ if [ -n "$servid" -a "$id" = "$servid" ]
then
# found it
echo $configfile
exit 0
fi
- if [ $first = "yes" ]
+ if [ $first == "yes" ]
then
instances=$id
first="no"
@@ -114,7 +114,7 @@ get_init_file()
done
# server id not provided, check if there is only one instance
- if [ -z "$servid" ] && [ $inst_count -eq 1 ]
+ if [ -z "$servid" -a $inst_count -eq 1 ]
then
# return the file
echo $configfile
@@ -135,44 +135,48 @@ process_dse ()
configdir=$1
pid=$2
file="$configdir/dse.ldif"
- OLD_IFS=$IFS
+ shopt -s nocasematch
+ OLD_IFC=$IFC
IFS=""
while read -r LINE
do
- case $LINE in
- ' '*)
- ;;
- *)
- if [ -n "$output" ]
- then
- echo "$output" >> /tmp/DSSharedLib.$pid
- output=""
- fi
- ;;
- esac
- if [ -n "$output" ]
+ if [[ $LINE != \ * ]] && [ "$output" != "" ]
then
- case $LINE in
- ' '*)
- # continuation line, strip the space and append it
- LINE=`echo "$LINE" | sed -e 's/^ //'`
- output=$output$LINE
- ;;
- esac
- else
- case $LINE in
- nsslapd-certdir*|\
- nsslapd-ldapiautobind*|\
- nsslapd-ldapilisten*|\
- nsslapd-ldapifilepath*|\
- nsslapd-localhost*|\
- nsslapd-port*|\
- nsslapd-rootdn*|\
- nsslapd-securePort*|\
- nsslapd-security*)
- output=$LINE
- ;;
- esac
+ echo "$output" >> /tmp/DSSharedLib.$pid
+ output=""
+ fi
+ if [ "$output" != "" ] && [[ $LINE == \ * ]]
+ then
+ # continuation line, strip the space and append it
+ LINE=`echo "$LINE" | sed -e 's/^ //'`
+ output=$output$LINE
+ elif [[ $LINE == nsslapd-port* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-localhost* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-securePort* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-security* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-ldapilisten* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-ldapifilepath* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-rootdn* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-ldapiautobind* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-certdir* ]]
+ then
+ output=$LINE;
fi
done < $file
@@ -190,19 +194,19 @@ check_protocol ()
ldapi=$3
openldap=$4
- if [ "$protocol" = "LDAPI" ] && [ "$openldap" != "yes" ]; then
+ if [ "$protocol" == "LDAPI" ] && [ "$openldap" != "yes" ]; then
echo ""
exit
- elif [ "$protocol" = "LDAPI" ] && [ "$ldapi" = "off" ]; then
+ elif [ "$protocol" == "LDAPI" ] && [ "$ldapi" == "off" ]; then
echo ""
exit
- elif [ "$protocol" = "STARTTLS" ]; then
- if [ -z "$security" ] || [ "$security" = "off" ]; then
+ elif [ "$protocol" == "STARTTLS" ]; then
+ if [ "$security" == "" ] || [ "$security" == "off" ]; then
echo ""
exit
fi
- elif [ "$protocol" = "LDAPS" ]; then
- if [ -z "$security" ] || [ "$security" = "off" ]; then
+ elif [ "$protocol" == "LDAPS" ]; then
+ if [ "$security" == "" ] || [ "$security" == "off" ]; then
echo ""
exit
fi
@@ -220,4 +224,4 @@ check_protocol ()
fi
echo "$protocol"
-}
+}
\ No newline at end of file
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index a2e54cc..f0cede4 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -26,18 +26,15 @@ if [ $# -lt 1 ] || [ $# -gt 7 ]
then
usage
exit 1
+elif [[ $1 == -* ]]
+then
+ usage
+ exit 1
+else
+ archivedir=$1
+ shift
fi
-case $1 in
- -*)
- usage
- exit 1
- ;;
- *)
- archivedir=$1
- shift
- ;;
-esac
-
+
while getopts "hn:Z:qd:vi:a:SD:" flag
do
case $flag in
@@ -58,7 +55,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index 1896c19..dacd7b0 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -26,6 +26,7 @@ then
usage
exit 1
fi
+
if [ "$#" -gt 0 ]
then
if [[ $1 != -* ]]
@@ -55,7 +56,7 @@ done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
@@ -66,7 +67,7 @@ fi
servid=`normalize_server_id $initfile`
. $initfile
-if [ -z "$bak_dir" ]
+if [ -z $bak_dir ]
then
bak_dir=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H_%M_%S`
fi
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index 6a0785e..9af8fc8 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -59,7 +59,7 @@ then
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index fcf73a0..d7e0ff0 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -39,7 +39,7 @@ make_ldiffile()
be=""
while [ "$1" != "" ]
do
- if [ "x$1" = "x-a" ]; then
+ if [ "$1" = "-a" ]; then
shift
if [ `expr "$1" : "/.*"` -gt 0 ]; then
if [ `expr "$1" : "/.*"` -gt 0 ]; then
@@ -56,17 +56,17 @@ make_ldiffile()
shift
return 0
fi
- elif [ "x$1" = "x-n" ]; then
+ elif [ "$1" = "-n" ]; then
shift
- if [ -z "$be" ]; then
+ if [ "$be" = "" ]; then
be="$1"
else
tmpbe="$be"
be="${tmpbe}-$1"
fi
- elif [ "x$1" = "x-s" ]; then
+ elif [ "$1" = "-s" ]; then
shift
- if [ -n "$1" ]; then
+ if [ "$1" != "" ]; then
rdn=`echo $1 | awk -F, '{print $1}'`
rdnval=`echo $rdn | awk -F= '{print $2}'`
if [ "$be" = "" ]; then
@@ -76,15 +76,15 @@ make_ldiffile()
be="${tmpbe}-$rdnval"
fi
fi
- elif [ "x$1" = "x-M" ]; then
+ elif [ "$1" = "-M" ]; then
be=""
fi
- if [ -n "$1" ]; then
+ if [ "$1" != "" ]; then
shift
fi
done
- if [ -z "$be" ]; then
+ if [ "$be" = "" ]; then
echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
else
echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-${be}-`date +%Y_%m_%d_%H%M%S`.ldif
@@ -92,7 +92,7 @@ make_ldiffile()
return 0
}
-if [ $# -lt 2 ];
+if [ "$#" -lt 2 ];
then
usage
exit 1
@@ -137,7 +137,7 @@ then
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index bbacc17..461cc16 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -47,7 +47,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
@@ -58,7 +58,7 @@ fi
. $initfile
@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
-if [ $display_version = "yes" ]; then
+if [ $display_version == "yes" ]; then
exit 0
fi
if [ $? -eq 0 ]; then
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 616969a..32a70c8 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -39,7 +39,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index a34241a..ce15349 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -82,7 +82,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/ldif2ldap.in b/ldap/admin/src/scripts/ldif2ldap.in
index 1e871be..874b1bb 100755
--- a/ldap/admin/src/scripts/ldif2ldap.in
+++ b/ldap/admin/src/scripts/ldif2ldap.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@ldapsdk_libdir@"
libpath_add "@libdir@"
@@ -40,14 +40,14 @@ do
esac
done
-if [ -z "$input_file" ]
+if [ "$input_file" == "" ]
then
usage
exit 1
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 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 [ -z "$rootdn" ]; then
+if [ "$rootdn" == "" ]; then
value=$(grep -i 'nsslapd-rootdn' $file)
rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'`
fi
rm $file
-if [ -n "$ldapiURL" ]; then
+if [ "$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" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$security" == "on" ]; then
+ if [ "$protocol" == "STARTTLS" ] || [ "$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" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$security" == "on" ]; then
+ if [ "$protocol" == "LDAPS" ] || [ "$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" ] || [ -z "$protocol" ]; then
- if [ $(id -u) -eq 0 ] && [ "$autobind" = "on" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then
+ if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then
+ if [ "$(id -u)" == "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 -ne 0 ]
+ if [ $rc != 0 ]
then
echo "Operation failed (error $rc)"
fi
@@ -158,11 +158,11 @@ fi
#
# LDAP
#
-if [ "$protocol" = "LDAP" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$protocol" == "LDAP" ] || [ "$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
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index 36a2fc9..7b2058b 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@ldapsdk_libdir@"
@@ -41,7 +41,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
@@ -66,17 +66,17 @@ 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 [ -z "$rootdn" ]; then
+if [ "$rootdn" == "" ]; then
value=$(grep -i 'nsslapd-rootdn' $file)
rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'`
fi
rm $file
-if [ -n "$passwd" ]; then
+if [ "$passwd" != "" ]; then
dn="-D $rootdn"
passwd="-w$passwd"
fi
-if [ -n "$ldapiURL" ]
+if [ "$ldapiURL" != "" ]
then
ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'`
ldapiURL="ldapi://"$ldapiURL
@@ -103,12 +103,12 @@ protocol=$revised_protocol
#
# STARTTLS
#
-if [ "$security" = "on" ]; then
- if [ "$protocol" = "STARTTLS" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$security" == "on" ]; then
+ if [ "$protocol" == "STARTTLS" ] || [ "$protocol" == "" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(STARTTLS)"
fi
- if [ "$openldap" = "yes" ]; then
+ if [ "$openldap" == "yes" ]; then
ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -120,12 +120,12 @@ fi
#
# LDAPS
#
-if [ "$security" = "on" ]; then
- if [ "$protocol" = "LDAPS" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$security" == "on" ]; then
+ if [ "$protocol" == "LDAPS" ] || [ "$protocol" == "" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(LDAPS)"
fi
- if [ "$openldap" = "yes" ]; then
+ if [ "$openldap" == "yes" ]; then
ldapsearch -x -LLL -H "ldaps://$host:$secure_port" -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -Z -P $certdir -p $secure_port -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -137,15 +137,15 @@ fi
#
# LDAPI
#
-if [ "$ldapi" = "on" ] && [ "$openldap" = "yes" ]; then
- if [ "$protocol" = "LDAPI" ] || [ -z "$protocol" ]; then
- if [ $(id -u) -eq 0 ] && [ "$autobind" = "on" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then
+ if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then
+ if [ "$(id -u)" == "0" ] && [ "$autobind" == "on" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(LDAPI/AUTOBIND)"
fi
ldapsearch -LLL -H "$ldapiURL" -b "$MDN" -s base -Y EXTERNAL "objectClass=*" 2>/dev/null
else
- if [ "$error" = "yes" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(LDAPI)"
fi
ldapsearch -x -LLL -H "$ldapiURL" -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -157,14 +157,14 @@ fi
#
# LDAP
#
-if [ "$protocol" = "LDAP" ] || [ "$protocol" = "" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(LDAP)"
fi
- if [ "$openldap" = "yes" ]; then
+ if [ "$openldap" == "yes" ]; then
ldapsearch -x -LLL -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
- fi
+ fi
exit $?
fi
diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in
index e86a24c..130e06e 100644
--- a/ldap/admin/src/scripts/restart-dirsrv.in
+++ b/ldap/admin/src/scripts/restart-dirsrv.in
@@ -7,7 +7,7 @@
# 2: Server started successfully (was not running)
# 3: Server could not be stopped
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
restart_instance() {
SERV_ID=$1
diff --git a/ldap/admin/src/scripts/restoreconfig.in b/ldap/admin/src/scripts/restoreconfig.in
index 56c9e43..9bb1acf 100755
--- a/ldap/admin/src/scripts/restoreconfig.in
+++ b/ldap/admin/src/scripts/restoreconfig.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -31,7 +31,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/saveconfig.in b/ldap/admin/src/scripts/saveconfig.in
index 16e3efc..65d80f3 100755
--- a/ldap/admin/src/scripts/saveconfig.in
+++ b/ldap/admin/src/scripts/saveconfig.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -31,7 +31,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
@@ -45,7 +45,7 @@ servid=`normalize_server_id $initfile`
echo saving configuration...
conf_ldif=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
@sbindir@/ns-slapd db2ldif -N -D $CONFIG_DIR -s "o=NetscapeRoot" -a $conf_ldif -n NetscapeRoot 2>&1
-if [ $? -ge 1 ]
+if [ "$?" -ge 1 ]
then
echo Error occurred while saving configuration
exit 1
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
index 458f0e8..481797d 100755
--- a/ldap/admin/src/scripts/start-dirsrv.in
+++ b/ldap/admin/src/scripts/start-dirsrv.in
@@ -6,7 +6,7 @@
# 1: Server could not be started
# 2: Server already running
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
# Starts a single instance
start_instance() {
@@ -44,7 +44,7 @@ start_instance() {
STARTPIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.startpid
if test -f $STARTPIDFILE ; then
PID=`cat $STARTPIDFILE`
- if kill -s 0 $PID > /dev/null 2>&1 ; then
+ if kill -0 $PID > /dev/null 2>&1 ; then
echo There is an ns-slapd process already running: $PID
return 2;
else
@@ -53,7 +53,7 @@ start_instance() {
fi
if test -f $PIDFILE ; then
PID=`cat $PIDFILE`
- if kill -s 0 $PID > /dev/null 2>&1 ; then
+ if kill -0 $PID > /dev/null 2>&1 ; then
echo There is an ns-slapd running: $PID
return 2;
else
@@ -64,7 +64,7 @@ start_instance() {
# Use systemctl if available and running as root,
# otherwise start the instance the old way.
#
- if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
+ if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
@bindir@/systemctl start @package_name@(a)$SERV_ID.service
if [ $? -ne 0 ]; then
return 1
@@ -96,7 +96,7 @@ start_instance() {
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $PIDFILE ; then
- if kill -s 0 $PID > /dev/null 2>&1 ; then
+ if kill -0 $PID > /dev/null 2>&1 ; then
sleep 1
else
echo Server failed to start !!! Please check errors log for problems
@@ -123,12 +123,12 @@ do
done
shift $(($OPTIND-1))
-if [ -z "$initconfig_dir" ]; then
+if [ "$initconfig_dir" = "" ]; then
initconfig_dir=@initconfigdir@
fi
found=0
-if [ $# -eq 0 ]; then
+if [ "$#" -eq 0 ]; then
# We're starting all instances.
ret=0
initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
@@ -137,7 +137,7 @@ if [ $# -eq 0 ]; then
echo Starting instance \"$inst\"
start_instance $inst
rv=$?
- if [ $rv -ne 0 ]; then
+ if [ "$rv" -ne 0 ]; then
ret=$rv
fi
done
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
index 72e2b85..3f02e78 100755
--- a/ldap/admin/src/scripts/stop-dirsrv.in
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
@@ -6,7 +6,7 @@
# 1: Server could not be stopped
# 2: Server was not running
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
stop_instance() {
SERV_ID=$1
@@ -28,7 +28,7 @@ stop_instance() {
fi
PID=`cat $PIDFILE`
# see if the server is already stopped
- kill -s 0 $PID > /dev/null 2>&1 || {
+ kill -0 $PID > /dev/null 2>&1 || {
echo Server not running
if test -f $PIDFILE ; then
rm -f $PIDFILE
@@ -39,7 +39,7 @@ stop_instance() {
#
# use systemctl if running as root
#
- if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
+ if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
#
# Now, check if systemctl is aware of this running instance
#
@@ -65,7 +65,7 @@ stop_instance() {
max_count=600
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -s 0 $PID > /dev/null 2>&1 ; then
+ if kill -0 $PID > /dev/null 2>&1 ; then
sleep 1;
else
if test -f $PIDFILE ; then
@@ -88,11 +88,11 @@ do
done
shift $(($OPTIND-1))
-if [ -z "$initconfig_dir" ]; then
+if [ "$initconfig_dir" = "" ]; then
initconfig_dir=@initconfigdir@
fi
-if [ $# -eq 0 ]; then
+if [ "$#" -eq 0 ]; then
# We're stopping all instances.
ret=0
initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
@@ -105,7 +105,7 @@ if [ $# -eq 0 ]; then
echo Stopping instance \"$inst\"
stop_instance $inst
rv=$?
- if [ $rv -ne 0 ]; then
+ if [ "$rv" -ne 0 ]; then
ret=$rv
fi
done
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index 7774148..e2f73c3 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -32,14 +32,14 @@ do
esac
done
-if [ -z "$args" ]
+if [ "$args" == "" ]
then
usage
exit 1
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index bf600dd..211bdce 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -39,7 +39,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
echo "Available instances: $initfile"
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index 51585ae..e9d8cab 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
# upgradednformat -- upgrade DN format to the new style (RFC 4514)
# Usgae: upgradednformat [-N] -n backend_instance -a db_instance_directory
@@ -49,13 +49,13 @@ do
esac
done
-if [ -z "$be" ] || [ -z "$dir" ]; then
+if [ "$be" = "" ] || [ "$dir" = "" ]; then
usage
exit 1
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index 365e32f..0b46b27 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -45,7 +45,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/rpm/389-ds-base-git.sh b/rpm/389-ds-base-git.sh
index 1a38da1..e5aaa8a 100644
--- a/rpm/389-ds-base-git.sh
+++ b/rpm/389-ds-base-git.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
DATE=`date +%Y%m%d`
# use a real tag name here
diff --git a/rpm/add_patches.sh b/rpm/add_patches.sh
index 31823d5..690d0b2 100755
--- a/rpm/add_patches.sh
+++ b/rpm/add_patches.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-usage()
+function usage()
{
echo "Adds patches to a specfile"
echo ""
@@ -51,5 +51,5 @@ for p in $patches; do
sed -i -e "/${prefix}/a Patch${i}: ${p}" -e "/$prepprefix/a %patch${i} -p1" $specfile
prefix="Patch${i}:"
prepprefix="%patch${i}"
- i=`expr $i + 1`
+ i=$(($i+1))
done
diff --git a/rpm/rpmverrel.sh b/rpm/rpmverrel.sh
index 06e97c7..86b808e 100755
--- a/rpm/rpmverrel.sh
+++ b/rpm/rpmverrel.sh
@@ -6,7 +6,7 @@ srcdir=`pwd`
# Source VERSION.sh to set the version
# and release environment variables.
-. ./VERSION.sh
+source ./VERSION.sh
if [ "$1" = "version" ]; then
echo $RPM_VERSION
diff --git a/wrappers/initscript.in b/wrappers/initscript.in
index fa79dbd..ad4ea2b 100644
--- a/wrappers/initscript.in
+++ b/wrappers/initscript.in
@@ -32,20 +32,28 @@ then
fi
fi
+# figure out which echo we're using
+ECHO_N=`echo -n`
+
+# some shells echo cannot use -n - linux echo by default cannot use \c
echo_n()
{
- printf '%s' "$*"
+ if [ "$ECHO_N" = '-n' ] ; then
+ echo "$*\c"
+ else
+ echo -n "$*"
+ fi
}
# failure and success are not defined on some platforms
-which failure > /dev/null 2>&1 || {
+type failure > /dev/null 2>&1 || {
failure()
{
echo_n " FAILED"
}
}
-which success > /dev/null 2>&1 || {
+type success > /dev/null 2>&1 || {
success()
{
echo_n " SUCCESS"
@@ -170,7 +178,7 @@ start() {
pid=`cat $pidfile`
instlockfile="@localstatedir@/lock/@package_name@/slapd-$instance/server/$pid"
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -s 0 $pid && [ $name = "ns-slapd" ]; then
+ if kill -0 $pid && [ $name = "ns-slapd" ]; then
echo_n " already running"
success; echo
successes=`expr $successes + 1`
@@ -231,7 +239,7 @@ start() {
while test $loop_counter -le $max_count ; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $pidfile ; then
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
sleep 1
else
break
@@ -241,7 +249,7 @@ start() {
break
fi
done
- if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
+ if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
success; echo
successes=`expr $successes + 1`
else
@@ -270,7 +278,7 @@ stop() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
server_stopped=0
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
server_stopped=1
@@ -289,7 +297,7 @@ stop() {
max_count=600
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
sleep 1
else
if test -f $pidfile ; then
@@ -331,7 +339,7 @@ status() {
for instance in $INSTANCES; do
if [ -f $piddir/slapd-$instance.pid ]; then
pid=`cat $piddir/slapd-$instance.pid`
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
echo "$prog $instance (pid $pid) is running..."
else
echo "$prog $instance dead but pid file exists"
diff --git a/wrappers/ldap-agent-initscript.in b/wrappers/ldap-agent-initscript.in
index b7aa4fe..dd8ee97 100644
--- a/wrappers/ldap-agent-initscript.in
+++ b/wrappers/ldap-agent-initscript.in
@@ -31,20 +31,28 @@ then
fi
fi
+# figure out which echo we're using
+ECHO_N=`echo -n`
+
+# some shells echo cannot use -n - linux echo by default cannot use \c
echo_n()
{
- printf '%s' "$*"
+ if [ "$ECHO_N" = '-n' ] ; then
+ echo "$*\c"
+ else
+ echo -n "$*"
+ fi
}
# failure and success are not defined on some platforms
-which failure > /dev/null 2>&1 || {
+type failure > /dev/null 2>&1 || {
failure()
{
echo_n " FAILED"
}
}
-which success > /dev/null 2>&1 || {
+type success > /dev/null 2>&1 || {
success()
{
echo_n " SUCCESS"
@@ -84,7 +92,7 @@ start() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -s 0 $pid && [ $name = "$processname" ]; then
+ if kill -0 $pid && [ $name = "$processname" ]; then
echo_n " already running"
success; echo
subagent_running=1
@@ -113,7 +121,7 @@ start() {
while test $loop_counter -le $max_count ; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $pidfile ; then
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
sleep 1
else
break
@@ -123,7 +131,7 @@ start() {
break
fi
done
- if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
+ if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
success; echo
else
failure; echo
@@ -139,7 +147,7 @@ stop() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
subagent_stopped=0
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
subagent_stopped=1
@@ -156,7 +164,7 @@ stop() {
max_count=10
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
sleep 1
else
if test -f $pidfile ; then
@@ -192,7 +200,7 @@ condrestart() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -s 0 $pid && [ $name = "$processname" ]; then
+ if kill -0 $pid && [ $name = "$processname" ]; then
restart
fi
fi
@@ -202,7 +210,7 @@ status() {
ret=0
if [ -f $pidfile ]; then
pid=`cat $pidfile`
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
echo "$prog (pid $pid) is running..."
else
echo "$prog dead but pid file exists"
commit 132b04f6e67c9b754eb826ba657ee7faa2a19f62
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Sep 14 11:21:31 2015 -0700
Revert "Ticket #48254 - Shell CLI fails with usage errors if an argument containing white spaces is given"
This reverts commit 19b0d4af54e319e3479b16bf1366568271e3daa6.
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index ab7c6b3..a2e54cc 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -44,12 +44,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n \"$OPTARG\"";;
+ n) args=$args" -n $OPTARG";;
q) args=$args" -q";;
- d) args=$args" -d \"$OPTARG\"";;
+ d) args=$args" -d $OPTARG";;
v) args=$args" -v";;
- D) args=$args" -D \"$OPTARG\"";;
- i) args=$args" -i \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
+ i) args=$args" -i $OPTARG";;
a) archivedir=$OPTARG;;
S) args=$args" -S";;
?) usage
@@ -76,4 +76,4 @@ else
archivedir=`pwd`/$archivedir
fi
-eval @sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
+@sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index adbe30b..1896c19 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -43,10 +43,10 @@ do
q) args=$args" -q";;
v) args=$args" -v";;
S) args=$args" -S";;
- D) args=$args" -D \"$OPTARG\"";;
- i) args=$args" -i \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
+ i) args=$args" -i $OPTARG";;
a) $bakdir=$OPTARG;;
- d) args=$args" -d \"$OPTARG\"";;
+ d) args=$args" -d $OPTARG";;
Z) servid=$OPTARG;;
?) usage
exit 1;;
@@ -72,4 +72,4 @@ then
fi
echo "Back up directory: $bak_dir"
-eval @sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
+@sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index c8e9075..6a0785e 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -35,15 +35,15 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n \"$OPTARG\""
+ n) args=$args" -n $OPTARG"
benameopt="set";;
- s) args=$args" -s \"$OPTARG\""
+ s) args=$args" -s $OPTARG"
includeSuffix="set";;
t) args=$args" -t "\"$OPTARG\";;
T) args=$args" -T "\"$OPTARG\";;
- d) args=$args" -d \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\"";;
- x) args=$args" -x \"$OPTARG\"";;
+ d) args=$args" -d $OPTARG";;
+ a) args=$args" -a $OPTARG";;
+ x) args=$args" -x $OPTARG";;
v) args=$args" -v";;
S) args=$args" -S";;
D) args=$args" -D $OPTARG";;
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index e9f7f7e..fcf73a0 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -106,12 +106,12 @@ do
Z) servid=$OPTARG;;
n) benameopt="-n $OPTARG"
required_param="yes";;
- s) includeSuffix="-s \"$OPTARG\""
+ s) includeSuffix="-s $OPTARG"
required_param="yes";;
- x) excludeSuffix="-x \"$OPTARG\"";;
- a) outputFile="-a \"$OPTARG\"";;
- d) args=$args" -d \"$OPTARG\"";;
- D) args=$args" -D \"$OPTARG\"";;
+ x) excludeSuffix="-x $OPTARG";;
+ a) outputFile="-a $OPTARG";;
+ d) args=$args" -d $OPTARG";;
+ D) args=$args" -D $OPTARG";;
N) args=$args" -N";;
E) args=$args" -E";;
S) args=$args" -S";;
@@ -154,7 +154,7 @@ rn=$?
echo "Exported ldif file: $ldif_file"
if [ $rn -eq 1 ]
then
- eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
+ @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
else
- eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
+ @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
fi
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index b98e9b2..bbacc17 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -33,14 +33,14 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n \"$OPTARG\"";;
- d) args=$args" -d \"$OPTARG\"";;
+ n) args=$args" -n $OPTARG";;
+ d) args=$args" -d $OPTARG";;
V) args=$args" -V";;
v) args=$args" -v"
display_version="yes";;
f) args=$args" -f";;
- D) args=$args" -D \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
+ a) args=$args" -a $OPTARG";;
?) usage
exit 1;;
esac
@@ -57,7 +57,7 @@ fi
. $initfile
-eval @sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
+@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
if [ $display_version = "yes" ]; then
exit 0
fi
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 762e63a..616969a 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -27,12 +27,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- d) arg=$arg" -d \"$OPTARG\"";;
- a) arg=$arg" -a \"$OPTARG\""
+ d) arg=$arg" -d $OPTARG";;
+ a) arg=$arg" -a $OPTARG"
archive="provided";;
v) arg=$arg" -v";;
f) arg=$arg" -f";;
- D) arg=$arg" -D \"$OPTARG\"";;
+ D) arg=$arg" -D $OPTARG";;
?) usage
exit 1;;
esac
@@ -55,4 +55,4 @@ if [ "$archive" != "provided" ]; then
args=$args"-a $bak_dir"
fi
-eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
+@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index 3aed469..a34241a 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -59,16 +59,16 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n \"$OPTARG\"";;
- i) args=$args" -i \"$OPTARG\"";;
- s) args=$args" -s \"$OPTARG\"";;
- x) args=$args" -x \"$OPTARG\"";;
- c) args=$args" -c \"$OPTARG\"";;
- d) args=$args" -d \"$OPTARG\"";;
- g) args=$args" -g \"$OPTARG\"";;
- G) args=$args" -G \"$OPTARG\"";;
- t) args=$args" -t \"$OPTARG\"";;
- D) args=$args" -D \"$OPTARG\"";;
+ n) args=$args" -n $OPTARG";;
+ i) args=$args" -i $OPTARG";;
+ s) args=$args" -s $OPTARG";;
+ x) args=$args" -x $OPTARG";;
+ c) args=$args" -c $OPTARG";;
+ d) args=$args" -d $OPTARG";;
+ g) args=$args" -g $OPTARG";;
+ G) args=$args" -G $OPTARG";;
+ t) args=$args" -t $OPTARG";;
+ D) args=$args" -D $OPTARG";;
E) args=$args" -E";;
v) args=$args" -v";;
N) args=$args" -N";;
@@ -104,6 +104,6 @@ if [ $quiet -eq 0 ]; then
echo importing data ...
fi
-eval @sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
+@sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
exit $?
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index e9265a1..36a2fc9 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -73,8 +73,8 @@ fi
rm $file
if [ -n "$passwd" ]; then
- dn="-D \"$rootdn\""
- passwd="-w \"$passwd\""
+ dn="-D $rootdn"
+ passwd="-w$passwd"
fi
if [ -n "$ldapiURL" ]
then
@@ -109,9 +109,9 @@ if [ "$security" = "on" ]; then
echo "Using the next most secure protocol(STARTTLS)"
fi
if [ "$openldap" = "yes" ]; then
- eval ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
- eval ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
fi
exit $?
fi
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index d7c6661..7774148 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -24,7 +24,7 @@ while getopts "Z:s:h" flag
do
case $flag in
Z) servid=$OPTARG;;
- s) args=$args" -s \"$OPTARG\"";;
+ s) args=$args" -s $OPTARG";;
h) usage
exit 0;;
?) usage
@@ -55,4 +55,4 @@ then
exit 1
fi
-eval @sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
+@sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index 2b7c79d..bf600dd 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -29,10 +29,10 @@ do
v) args=$args" -v";;
f) args=$args" -f";;
r) args=$args" -r";;
- d) args=$args" -d \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\""
+ d) args=$args" -d $OPTARG";;
+ a) args=$args" -a $OPTARG"
archive_provided="yes";;
- D) args=$args" -D \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
h) usage
exit 0;;
esac
@@ -56,4 +56,4 @@ then
fi
echo upgrade index files ...
-eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
+@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index 9de60ea..51585ae 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -36,14 +36,14 @@ do
Z) servid=$OPTARG;;
v) args=$args" -v";;
N) args=$args" -N";;
- d) args=$args" -d \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\""
+ d) args=$args" -d $OPTARG";;
+ a) args=$args" -a $OPTARG"
dir="set";;
- n) args=$args" -n \"$OPTARG\""
+ n) args=$args" -n $OPTARG"
be="set";;
h) usage
exit 0;;
- D) args=$args" -D \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
?) usage
exit 1;;
esac
@@ -65,7 +65,7 @@ fi
. $initfile
-eval @sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
+@sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
rc=$?
exit $rc
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index a1696bc..365e32f 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -29,14 +29,14 @@ do
case $flag in
Z) servid=$OPTARG;;
v) args=$args" -v";;
- s) args=$args" -s \"$OPTARG\"";;
- d) args=$args" -d \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\"";;
- T) args=$args" -T \"$OPTARG\"";;
+ s) args=$args" -s $OPTARG";;
+ d) args=$args" -d $OPTARG";;
+ a) args=$args" -a $OPTARG";;
+ T) args=$args" -T $OPTARG";;
S) args=$args" -S";;
- n) args=$args" -n \"$OPTARG\"";;
- x) args=$args" -x \"$OPTARG\"";;
- D) args=$args" -D \"$OPTARG\"";;
+ n) args=$args" -n $OPTARG";;
+ x) args=$args" -x $OPTARG";;
+ D) args=$args" -D $OPTARG";;
h) usage
exit 0;;
?) usage
@@ -61,4 +61,4 @@ then
exit 1
fi
-eval @sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
+@sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months
4 commits -
by Noriko Hosoi
0 files changed
New commits:
commit 0584156ba21823c138f91a68b9a0715fd81f82f7
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Aug 25 11:48:31 2015 -0700
Ticket #48254 - Shell CLI fails with usage errors if an argument containing white spaces is given
Description: In addition to the patch:
Ticket #48254 - CLI db2index fails with usage errors
commit 3507c46c9f1156df11b6cf05eba695d81088b416
applying the similar changes to all the shell CLI which could be given
arguments that include white spaces.
https://fedorahosted.org/389/ticket/48254
Reviewed by mreynolds(a)redhat.com (Thank you, Mark!!)
(cherry picked from commit 5fe28921810a53dcd31525ba1f675582b6aba0f7)
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index a2e54cc..ab7c6b3 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -44,12 +44,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
q) args=$args" -q";;
- d) args=$args" -d $OPTARG";;
+ d) args=$args" -d \"$OPTARG\"";;
v) args=$args" -v";;
- D) args=$args" -D $OPTARG";;
- i) args=$args" -i $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
+ i) args=$args" -i \"$OPTARG\"";;
a) archivedir=$OPTARG;;
S) args=$args" -S";;
?) usage
@@ -76,4 +76,4 @@ else
archivedir=`pwd`/$archivedir
fi
-@sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
+eval @sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index 1896c19..adbe30b 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -43,10 +43,10 @@ do
q) args=$args" -q";;
v) args=$args" -v";;
S) args=$args" -S";;
- D) args=$args" -D $OPTARG";;
- i) args=$args" -i $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
+ i) args=$args" -i \"$OPTARG\"";;
a) $bakdir=$OPTARG;;
- d) args=$args" -d $OPTARG";;
+ d) args=$args" -d \"$OPTARG\"";;
Z) servid=$OPTARG;;
?) usage
exit 1;;
@@ -72,4 +72,4 @@ then
fi
echo "Back up directory: $bak_dir"
-@sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
+eval @sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index 6a0785e..c8e9075 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -35,15 +35,15 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG"
+ n) args=$args" -n \"$OPTARG\""
benameopt="set";;
- s) args=$args" -s $OPTARG"
+ s) args=$args" -s \"$OPTARG\""
includeSuffix="set";;
t) args=$args" -t "\"$OPTARG\";;
T) args=$args" -T "\"$OPTARG\";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG";;
- x) args=$args" -x $OPTARG";;
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\"";;
+ x) args=$args" -x \"$OPTARG\"";;
v) args=$args" -v";;
S) args=$args" -S";;
D) args=$args" -D $OPTARG";;
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index fcf73a0..e9f7f7e 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -106,12 +106,12 @@ do
Z) servid=$OPTARG;;
n) benameopt="-n $OPTARG"
required_param="yes";;
- s) includeSuffix="-s $OPTARG"
+ s) includeSuffix="-s \"$OPTARG\""
required_param="yes";;
- x) excludeSuffix="-x $OPTARG";;
- a) outputFile="-a $OPTARG";;
- d) args=$args" -d $OPTARG";;
- D) args=$args" -D $OPTARG";;
+ x) excludeSuffix="-x \"$OPTARG\"";;
+ a) outputFile="-a \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
+ D) args=$args" -D \"$OPTARG\"";;
N) args=$args" -N";;
E) args=$args" -E";;
S) args=$args" -S";;
@@ -154,7 +154,7 @@ rn=$?
echo "Exported ldif file: $ldif_file"
if [ $rn -eq 1 ]
then
- @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
+ eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
else
- @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
+ eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
fi
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index bbacc17..b98e9b2 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -33,14 +33,14 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG";;
- d) args=$args" -d $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
V) args=$args" -V";;
v) args=$args" -v"
display_version="yes";;
f) args=$args" -f";;
- D) args=$args" -D $OPTARG";;
- a) args=$args" -a $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\"";;
?) usage
exit 1;;
esac
@@ -57,7 +57,7 @@ fi
. $initfile
-@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
if [ $display_version = "yes" ]; then
exit 0
fi
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 616969a..762e63a 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -27,12 +27,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- d) arg=$arg" -d $OPTARG";;
- a) arg=$arg" -a $OPTARG"
+ d) arg=$arg" -d \"$OPTARG\"";;
+ a) arg=$arg" -a \"$OPTARG\""
archive="provided";;
v) arg=$arg" -v";;
f) arg=$arg" -f";;
- D) arg=$arg" -D $OPTARG";;
+ D) arg=$arg" -D \"$OPTARG\"";;
?) usage
exit 1;;
esac
@@ -55,4 +55,4 @@ if [ "$archive" != "provided" ]; then
args=$args"-a $bak_dir"
fi
-@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
+eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index a34241a..3aed469 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -59,16 +59,16 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n $OPTARG";;
- i) args=$args" -i $OPTARG";;
- s) args=$args" -s $OPTARG";;
- x) args=$args" -x $OPTARG";;
- c) args=$args" -c $OPTARG";;
- d) args=$args" -d $OPTARG";;
- g) args=$args" -g $OPTARG";;
- G) args=$args" -G $OPTARG";;
- t) args=$args" -t $OPTARG";;
- D) args=$args" -D $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
+ i) args=$args" -i \"$OPTARG\"";;
+ s) args=$args" -s \"$OPTARG\"";;
+ x) args=$args" -x \"$OPTARG\"";;
+ c) args=$args" -c \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
+ g) args=$args" -g \"$OPTARG\"";;
+ G) args=$args" -G \"$OPTARG\"";;
+ t) args=$args" -t \"$OPTARG\"";;
+ D) args=$args" -D \"$OPTARG\"";;
E) args=$args" -E";;
v) args=$args" -v";;
N) args=$args" -N";;
@@ -104,6 +104,6 @@ if [ $quiet -eq 0 ]; then
echo importing data ...
fi
-@sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
+eval @sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
exit $?
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index 36a2fc9..e9265a1 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -73,8 +73,8 @@ fi
rm $file
if [ -n "$passwd" ]; then
- dn="-D $rootdn"
- passwd="-w$passwd"
+ dn="-D \"$rootdn\""
+ passwd="-w \"$passwd\""
fi
if [ -n "$ldapiURL" ]
then
@@ -109,9 +109,9 @@ if [ "$security" = "on" ]; then
echo "Using the next most secure protocol(STARTTLS)"
fi
if [ "$openldap" = "yes" ]; then
- ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ eval ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
- ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ eval ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
fi
exit $?
fi
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index 7774148..d7c6661 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -24,7 +24,7 @@ while getopts "Z:s:h" flag
do
case $flag in
Z) servid=$OPTARG;;
- s) args=$args" -s $OPTARG";;
+ s) args=$args" -s \"$OPTARG\"";;
h) usage
exit 0;;
?) usage
@@ -55,4 +55,4 @@ then
exit 1
fi
-@sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
+eval @sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index bf600dd..2b7c79d 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -29,10 +29,10 @@ do
v) args=$args" -v";;
f) args=$args" -f";;
r) args=$args" -r";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG"
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\""
archive_provided="yes";;
- D) args=$args" -D $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
h) usage
exit 0;;
esac
@@ -56,4 +56,4 @@ then
fi
echo upgrade index files ...
-@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index 51585ae..9de60ea 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -36,14 +36,14 @@ do
Z) servid=$OPTARG;;
v) args=$args" -v";;
N) args=$args" -N";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG"
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\""
dir="set";;
- n) args=$args" -n $OPTARG"
+ n) args=$args" -n \"$OPTARG\""
be="set";;
h) usage
exit 0;;
- D) args=$args" -D $OPTARG";;
+ D) args=$args" -D \"$OPTARG\"";;
?) usage
exit 1;;
esac
@@ -65,7 +65,7 @@ fi
. $initfile
-@sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
rc=$?
exit $rc
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index 365e32f..a1696bc 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -29,14 +29,14 @@ do
case $flag in
Z) servid=$OPTARG;;
v) args=$args" -v";;
- s) args=$args" -s $OPTARG";;
- d) args=$args" -d $OPTARG";;
- a) args=$args" -a $OPTARG";;
- T) args=$args" -T $OPTARG";;
+ s) args=$args" -s \"$OPTARG\"";;
+ d) args=$args" -d \"$OPTARG\"";;
+ a) args=$args" -a \"$OPTARG\"";;
+ T) args=$args" -T \"$OPTARG\"";;
S) args=$args" -S";;
- n) args=$args" -n $OPTARG";;
- x) args=$args" -x $OPTARG";;
- D) args=$args" -D $OPTARG";;
+ n) args=$args" -n \"$OPTARG\"";;
+ x) args=$args" -x \"$OPTARG\"";;
+ D) args=$args" -D \"$OPTARG\"";;
h) usage
exit 0;;
?) usage
@@ -61,4 +61,4 @@ then
exit 1
fi
-@sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
+eval @sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
commit b35286b78abffc3ce93db838a0a1c8310b10ff2f
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Aug 10 17:04:25 2015 -0700
Ticket #47511 - bashisms in 389-ds-base admin scripts
Description by mvocu (Thank you):
The shell scripts in 389-ds-base/ldap/admin/src/scripts use 'source'
to source common scripts; the 'source' keyword is bash-specific (or
c-shell, if memory serves). The interpreter is set to /bin/sh, which
is not guaranteed to be bash (and at least on Debian 7.1 it is dash).
The 'source' keyword can be replaced by '.', which should work.
Thanks to Rowan Thorpe (rowan(a)rowanthorpe.com) for providing us the
patch.
Note: The comment of commit 2ce7a7334bcb89e47c0f5c544144aec37010a5b9
had an incorrect credit, which is fixed by this commit.
https://fedorahosted.org/389/ticket/47511
Reviewed and tested by nhosoi(a)redhat.com.
(cherry picked from commit 2ce7a7334bcb89e47c0f5c544144aec37010a5b9)
diff --git a/ldap/admin/src/initconfig.in b/ldap/admin/src/initconfig.in
index 134e82c..7afa315 100644
--- a/ldap/admin/src/initconfig.in
+++ b/ldap/admin/src/initconfig.in
@@ -2,11 +2,11 @@
OS=`uname -s`
# use the new mt slab memory allocator on Solaris
# this requires Solaris 9 update 3 or later
-if [ "$OS" = "SunOS" -a -f /usr/lib/libumem.so ] ; then
+if [ "$OS" = "SunOS" ] && [ -f /usr/lib/libumem.so ] ; then
LD_PRELOAD=/usr/lib/libumem.so
export LD_PRELOAD
fi
-if [ "$OS" = "SunOS" -a -f /usr/lib/64/libumem.so ] ; then
+if [ "$OS" = "SunOS" ] && [ -f /usr/lib/64/libumem.so ] ; then
LD_PRELOAD_64=/usr/lib/64/libumem.so
export LD_PRELOAD_64
fi
diff --git a/ldap/admin/src/scripts/DSSharedLib.in b/ldap/admin/src/scripts/DSSharedLib.in
index 3683696..8317c58 100644
--- a/ldap/admin/src/scripts/DSSharedLib.in
+++ b/ldap/admin/src/scripts/DSSharedLib.in
@@ -98,13 +98,13 @@ get_init_file()
do
inst_count=`expr $inst_count + 1`
id=`normalize_server_id $configfile`
- if [ -n "$servid" -a "$id" = "$servid" ]
+ if [ -n "$servid" ] && [ "$id" = "$servid" ]
then
# found it
echo $configfile
exit 0
fi
- if [ $first == "yes" ]
+ if [ $first = "yes" ]
then
instances=$id
first="no"
@@ -114,7 +114,7 @@ get_init_file()
done
# server id not provided, check if there is only one instance
- if [ -z "$servid" -a $inst_count -eq 1 ]
+ if [ -z "$servid" ] && [ $inst_count -eq 1 ]
then
# return the file
echo $configfile
@@ -135,48 +135,44 @@ process_dse ()
configdir=$1
pid=$2
file="$configdir/dse.ldif"
- shopt -s nocasematch
- OLD_IFC=$IFC
+ OLD_IFS=$IFS
IFS=""
while read -r LINE
do
- if [[ $LINE != \ * ]] && [ "$output" != "" ]
+ case $LINE in
+ ' '*)
+ ;;
+ *)
+ if [ -n "$output" ]
+ then
+ echo "$output" >> /tmp/DSSharedLib.$pid
+ output=""
+ fi
+ ;;
+ esac
+ if [ -n "$output" ]
then
- echo "$output" >> /tmp/DSSharedLib.$pid
- output=""
- fi
- if [ "$output" != "" ] && [[ $LINE == \ * ]]
- then
- # continuation line, strip the space and append it
- LINE=`echo "$LINE" | sed -e 's/^ //'`
- output=$output$LINE
- elif [[ $LINE == nsslapd-port* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-localhost* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-securePort* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-security* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-ldapilisten* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-ldapifilepath* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-rootdn* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-ldapiautobind* ]]
- then
- output=$LINE;
- elif [[ $LINE == nsslapd-certdir* ]]
- then
- output=$LINE;
+ case $LINE in
+ ' '*)
+ # continuation line, strip the space and append it
+ LINE=`echo "$LINE" | sed -e 's/^ //'`
+ output=$output$LINE
+ ;;
+ esac
+ else
+ case $LINE in
+ nsslapd-certdir*|\
+ nsslapd-ldapiautobind*|\
+ nsslapd-ldapilisten*|\
+ nsslapd-ldapifilepath*|\
+ nsslapd-localhost*|\
+ nsslapd-port*|\
+ nsslapd-rootdn*|\
+ nsslapd-securePort*|\
+ nsslapd-security*)
+ output=$LINE
+ ;;
+ esac
fi
done < $file
@@ -194,19 +190,19 @@ check_protocol ()
ldapi=$3
openldap=$4
- if [ "$protocol" == "LDAPI" ] && [ "$openldap" != "yes" ]; then
+ if [ "$protocol" = "LDAPI" ] && [ "$openldap" != "yes" ]; then
echo ""
exit
- elif [ "$protocol" == "LDAPI" ] && [ "$ldapi" == "off" ]; then
+ elif [ "$protocol" = "LDAPI" ] && [ "$ldapi" = "off" ]; then
echo ""
exit
- elif [ "$protocol" == "STARTTLS" ]; then
- if [ "$security" == "" ] || [ "$security" == "off" ]; then
+ elif [ "$protocol" = "STARTTLS" ]; then
+ if [ -z "$security" ] || [ "$security" = "off" ]; then
echo ""
exit
fi
- elif [ "$protocol" == "LDAPS" ]; then
- if [ "$security" == "" ] || [ "$security" == "off" ]; then
+ elif [ "$protocol" = "LDAPS" ]; then
+ if [ -z "$security" ] || [ "$security" = "off" ]; then
echo ""
exit
fi
@@ -224,4 +220,4 @@ check_protocol ()
fi
echo "$protocol"
-}
\ No newline at end of file
+}
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index f0cede4..a2e54cc 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -26,15 +26,18 @@ if [ $# -lt 1 ] || [ $# -gt 7 ]
then
usage
exit 1
-elif [[ $1 == -* ]]
-then
- usage
- exit 1
-else
- archivedir=$1
- shift
fi
-
+case $1 in
+ -*)
+ usage
+ exit 1
+ ;;
+ *)
+ archivedir=$1
+ shift
+ ;;
+esac
+
while getopts "hn:Z:qd:vi:a:SD:" flag
do
case $flag in
@@ -55,7 +58,7 @@ do
done
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"
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index dacd7b0..1896c19 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -26,7 +26,6 @@ then
usage
exit 1
fi
-
if [ "$#" -gt 0 ]
then
if [[ $1 != -* ]]
@@ -56,7 +55,7 @@ done
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,7 +66,7 @@ fi
servid=`normalize_server_id $initfile`
. $initfile
-if [ -z $bak_dir ]
+if [ -z "$bak_dir" ]
then
bak_dir=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H_%M_%S`
fi
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index 9af8fc8..6a0785e 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -59,7 +59,7 @@ then
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"
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index d7e0ff0..fcf73a0 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -39,7 +39,7 @@ make_ldiffile()
be=""
while [ "$1" != "" ]
do
- if [ "$1" = "-a" ]; then
+ if [ "x$1" = "x-a" ]; then
shift
if [ `expr "$1" : "/.*"` -gt 0 ]; then
if [ `expr "$1" : "/.*"` -gt 0 ]; then
@@ -56,17 +56,17 @@ make_ldiffile()
shift
return 0
fi
- elif [ "$1" = "-n" ]; then
+ elif [ "x$1" = "x-n" ]; then
shift
- if [ "$be" = "" ]; then
+ if [ -z "$be" ]; then
be="$1"
else
tmpbe="$be"
be="${tmpbe}-$1"
fi
- elif [ "$1" = "-s" ]; then
+ elif [ "x$1" = "x-s" ]; then
shift
- if [ "$1" != "" ]; then
+ if [ -n "$1" ]; then
rdn=`echo $1 | awk -F, '{print $1}'`
rdnval=`echo $rdn | awk -F= '{print $2}'`
if [ "$be" = "" ]; then
@@ -76,15 +76,15 @@ make_ldiffile()
be="${tmpbe}-$rdnval"
fi
fi
- elif [ "$1" = "-M" ]; then
+ elif [ "x$1" = "x-M" ]; then
be=""
fi
- if [ "$1" != "" ]; then
+ if [ -n "$1" ]; then
shift
fi
done
- if [ "$be" = "" ]; then
+ if [ -z "$be" ]; then
echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
else
echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-${be}-`date +%Y_%m_%d_%H%M%S`.ldif
@@ -92,7 +92,7 @@ make_ldiffile()
return 0
}
-if [ "$#" -lt 2 ];
+if [ $# -lt 2 ];
then
usage
exit 1
@@ -137,7 +137,7 @@ then
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"
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index 461cc16..bbacc17 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -47,7 +47,7 @@ do
done
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"
@@ -58,7 +58,7 @@ fi
. $initfile
@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
-if [ $display_version == "yes" ]; then
+if [ $display_version = "yes" ]; then
exit 0
fi
if [ $? -eq 0 ]; then
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 32a70c8..616969a 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -39,7 +39,7 @@ do
done
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"
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index ce15349..a34241a 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -82,7 +82,7 @@ do
done
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"
diff --git a/ldap/admin/src/scripts/ldif2ldap.in b/ldap/admin/src/scripts/ldif2ldap.in
index 874b1bb..1e871be 100755
--- a/ldap/admin/src/scripts/ldif2ldap.in
+++ b/ldap/admin/src/scripts/ldif2ldap.in
@@ -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
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index 7b2058b..36a2fc9 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@ldapsdk_libdir@"
@@ -41,7 +41,7 @@ do
done
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"
@@ -66,17 +66,17 @@ 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 [ "$passwd" != "" ]; then
+if [ -n "$passwd" ]; then
dn="-D $rootdn"
passwd="-w$passwd"
fi
-if [ "$ldapiURL" != "" ]
+if [ -n "$ldapiURL" ]
then
ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'`
ldapiURL="ldapi://"$ldapiURL
@@ -103,12 +103,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
ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -120,12 +120,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
ldapsearch -x -LLL -H "ldaps://$host:$secure_port" -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -Z -P $certdir -p $secure_port -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -137,15 +137,15 @@ 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
ldapsearch -LLL -H "$ldapiURL" -b "$MDN" -s base -Y EXTERNAL "objectClass=*" 2>/dev/null
else
- if [ "$error" == "yes" ]; then
+ if [ "$error" = "yes" ]; then
echo "Using the next most secure protocol(LDAPI)"
fi
ldapsearch -x -LLL -H "$ldapiURL" -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -157,14 +157,14 @@ fi
#
# LDAP
#
-if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then
- if [ "$error" == "yes" ]; then
+if [ "$protocol" = "LDAP" ] || [ "$protocol" = "" ]; then
+ if [ "$error" = "yes" ]; then
echo "Using the next most secure protocol(LDAP)"
fi
- if [ "$openldap" == "yes" ]; then
+ if [ "$openldap" = "yes" ]; then
ldapsearch -x -LLL -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
- fi
+ fi
exit $?
fi
diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in
index 130e06e..e86a24c 100644
--- a/ldap/admin/src/scripts/restart-dirsrv.in
+++ b/ldap/admin/src/scripts/restart-dirsrv.in
@@ -7,7 +7,7 @@
# 2: Server started successfully (was not running)
# 3: Server could not be stopped
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
restart_instance() {
SERV_ID=$1
diff --git a/ldap/admin/src/scripts/restoreconfig.in b/ldap/admin/src/scripts/restoreconfig.in
index 9bb1acf..56c9e43 100755
--- a/ldap/admin/src/scripts/restoreconfig.in
+++ b/ldap/admin/src/scripts/restoreconfig.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -31,7 +31,7 @@ do
done
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"
diff --git a/ldap/admin/src/scripts/saveconfig.in b/ldap/admin/src/scripts/saveconfig.in
index 65d80f3..16e3efc 100755
--- a/ldap/admin/src/scripts/saveconfig.in
+++ b/ldap/admin/src/scripts/saveconfig.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -31,7 +31,7 @@ do
done
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"
@@ -45,7 +45,7 @@ servid=`normalize_server_id $initfile`
echo saving configuration...
conf_ldif=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
@sbindir@/ns-slapd db2ldif -N -D $CONFIG_DIR -s "o=NetscapeRoot" -a $conf_ldif -n NetscapeRoot 2>&1
-if [ "$?" -ge 1 ]
+if [ $? -ge 1 ]
then
echo Error occurred while saving configuration
exit 1
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
index 481797d..458f0e8 100755
--- a/ldap/admin/src/scripts/start-dirsrv.in
+++ b/ldap/admin/src/scripts/start-dirsrv.in
@@ -6,7 +6,7 @@
# 1: Server could not be started
# 2: Server already running
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
# Starts a single instance
start_instance() {
@@ -44,7 +44,7 @@ start_instance() {
STARTPIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.startpid
if test -f $STARTPIDFILE ; then
PID=`cat $STARTPIDFILE`
- if kill -0 $PID > /dev/null 2>&1 ; then
+ if kill -s 0 $PID > /dev/null 2>&1 ; then
echo There is an ns-slapd process already running: $PID
return 2;
else
@@ -53,7 +53,7 @@ start_instance() {
fi
if test -f $PIDFILE ; then
PID=`cat $PIDFILE`
- if kill -0 $PID > /dev/null 2>&1 ; then
+ if kill -s 0 $PID > /dev/null 2>&1 ; then
echo There is an ns-slapd running: $PID
return 2;
else
@@ -64,7 +64,7 @@ start_instance() {
# Use systemctl if available and running as root,
# otherwise start the instance the old way.
#
- if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
+ if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
@bindir@/systemctl start @package_name@(a)$SERV_ID.service
if [ $? -ne 0 ]; then
return 1
@@ -96,7 +96,7 @@ start_instance() {
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $PIDFILE ; then
- if kill -0 $PID > /dev/null 2>&1 ; then
+ if kill -s 0 $PID > /dev/null 2>&1 ; then
sleep 1
else
echo Server failed to start !!! Please check errors log for problems
@@ -123,12 +123,12 @@ do
done
shift $(($OPTIND-1))
-if [ "$initconfig_dir" = "" ]; then
+if [ -z "$initconfig_dir" ]; then
initconfig_dir=@initconfigdir@
fi
found=0
-if [ "$#" -eq 0 ]; then
+if [ $# -eq 0 ]; then
# We're starting all instances.
ret=0
initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
@@ -137,7 +137,7 @@ if [ "$#" -eq 0 ]; then
echo Starting instance \"$inst\"
start_instance $inst
rv=$?
- if [ "$rv" -ne 0 ]; then
+ if [ $rv -ne 0 ]; then
ret=$rv
fi
done
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
index 3f02e78..72e2b85 100755
--- a/ldap/admin/src/scripts/stop-dirsrv.in
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
@@ -6,7 +6,7 @@
# 1: Server could not be stopped
# 2: Server was not running
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
stop_instance() {
SERV_ID=$1
@@ -28,7 +28,7 @@ stop_instance() {
fi
PID=`cat $PIDFILE`
# see if the server is already stopped
- kill -0 $PID > /dev/null 2>&1 || {
+ kill -s 0 $PID > /dev/null 2>&1 || {
echo Server not running
if test -f $PIDFILE ; then
rm -f $PIDFILE
@@ -39,7 +39,7 @@ stop_instance() {
#
# use systemctl if running as root
#
- if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
+ if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
#
# Now, check if systemctl is aware of this running instance
#
@@ -65,7 +65,7 @@ stop_instance() {
max_count=600
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -0 $PID > /dev/null 2>&1 ; then
+ if kill -s 0 $PID > /dev/null 2>&1 ; then
sleep 1;
else
if test -f $PIDFILE ; then
@@ -88,11 +88,11 @@ do
done
shift $(($OPTIND-1))
-if [ "$initconfig_dir" = "" ]; then
+if [ -z "$initconfig_dir" ]; then
initconfig_dir=@initconfigdir@
fi
-if [ "$#" -eq 0 ]; then
+if [ $# -eq 0 ]; then
# We're stopping all instances.
ret=0
initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
@@ -105,7 +105,7 @@ if [ "$#" -eq 0 ]; then
echo Stopping instance \"$inst\"
stop_instance $inst
rv=$?
- if [ "$rv" -ne 0 ]; then
+ if [ $rv -ne 0 ]; then
ret=$rv
fi
done
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index e2f73c3..7774148 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -32,14 +32,14 @@ do
esac
done
-if [ "$args" == "" ]
+if [ -z "$args" ]
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"
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index 211bdce..bf600dd 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -39,7 +39,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? == 1 ]
+if [ $? -eq 1 ]
then
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
echo "Available instances: $initfile"
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index e9d8cab..51585ae 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
# upgradednformat -- upgrade DN format to the new style (RFC 4514)
# Usgae: upgradednformat [-N] -n backend_instance -a db_instance_directory
@@ -49,13 +49,13 @@ do
esac
done
-if [ "$be" = "" ] || [ "$dir" = "" ]; then
+if [ -z "$be" ] || [ -z "$dir" ]; 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"
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index 0b46b27..365e32f 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -1,6 +1,6 @@
#!/bin/sh
-source @datadir@/@package_name@/data/DSSharedLib
+. @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -45,7 +45,7 @@ do
done
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"
diff --git a/rpm/389-ds-base-git.sh b/rpm/389-ds-base-git.sh
index e5aaa8a..1a38da1 100644
--- a/rpm/389-ds-base-git.sh
+++ b/rpm/389-ds-base-git.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
DATE=`date +%Y%m%d`
# use a real tag name here
diff --git a/rpm/add_patches.sh b/rpm/add_patches.sh
index 690d0b2..31823d5 100755
--- a/rpm/add_patches.sh
+++ b/rpm/add_patches.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-function usage()
+usage()
{
echo "Adds patches to a specfile"
echo ""
@@ -51,5 +51,5 @@ for p in $patches; do
sed -i -e "/${prefix}/a Patch${i}: ${p}" -e "/$prepprefix/a %patch${i} -p1" $specfile
prefix="Patch${i}:"
prepprefix="%patch${i}"
- i=$(($i+1))
+ i=`expr $i + 1`
done
diff --git a/rpm/rpmverrel.sh b/rpm/rpmverrel.sh
index 86b808e..06e97c7 100755
--- a/rpm/rpmverrel.sh
+++ b/rpm/rpmverrel.sh
@@ -6,7 +6,7 @@ srcdir=`pwd`
# Source VERSION.sh to set the version
# and release environment variables.
-source ./VERSION.sh
+. ./VERSION.sh
if [ "$1" = "version" ]; then
echo $RPM_VERSION
diff --git a/wrappers/initscript.in b/wrappers/initscript.in
index ad4ea2b..fa79dbd 100644
--- a/wrappers/initscript.in
+++ b/wrappers/initscript.in
@@ -32,28 +32,20 @@ then
fi
fi
-# figure out which echo we're using
-ECHO_N=`echo -n`
-
-# some shells echo cannot use -n - linux echo by default cannot use \c
echo_n()
{
- if [ "$ECHO_N" = '-n' ] ; then
- echo "$*\c"
- else
- echo -n "$*"
- fi
+ printf '%s' "$*"
}
# failure and success are not defined on some platforms
-type failure > /dev/null 2>&1 || {
+which failure > /dev/null 2>&1 || {
failure()
{
echo_n " FAILED"
}
}
-type success > /dev/null 2>&1 || {
+which success > /dev/null 2>&1 || {
success()
{
echo_n " SUCCESS"
@@ -178,7 +170,7 @@ start() {
pid=`cat $pidfile`
instlockfile="@localstatedir@/lock/@package_name@/slapd-$instance/server/$pid"
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -0 $pid && [ $name = "ns-slapd" ]; then
+ if kill -s 0 $pid && [ $name = "ns-slapd" ]; then
echo_n " already running"
success; echo
successes=`expr $successes + 1`
@@ -239,7 +231,7 @@ start() {
while test $loop_counter -le $max_count ; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $pidfile ; then
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
sleep 1
else
break
@@ -249,7 +241,7 @@ start() {
break
fi
done
- if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
+ if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
success; echo
successes=`expr $successes + 1`
else
@@ -278,7 +270,7 @@ stop() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
server_stopped=0
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
server_stopped=1
@@ -297,7 +289,7 @@ stop() {
max_count=600
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
sleep 1
else
if test -f $pidfile ; then
@@ -339,7 +331,7 @@ status() {
for instance in $INSTANCES; do
if [ -f $piddir/slapd-$instance.pid ]; then
pid=`cat $piddir/slapd-$instance.pid`
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
echo "$prog $instance (pid $pid) is running..."
else
echo "$prog $instance dead but pid file exists"
diff --git a/wrappers/ldap-agent-initscript.in b/wrappers/ldap-agent-initscript.in
index dd8ee97..b7aa4fe 100644
--- a/wrappers/ldap-agent-initscript.in
+++ b/wrappers/ldap-agent-initscript.in
@@ -31,28 +31,20 @@ then
fi
fi
-# figure out which echo we're using
-ECHO_N=`echo -n`
-
-# some shells echo cannot use -n - linux echo by default cannot use \c
echo_n()
{
- if [ "$ECHO_N" = '-n' ] ; then
- echo "$*\c"
- else
- echo -n "$*"
- fi
+ printf '%s' "$*"
}
# failure and success are not defined on some platforms
-type failure > /dev/null 2>&1 || {
+which failure > /dev/null 2>&1 || {
failure()
{
echo_n " FAILED"
}
}
-type success > /dev/null 2>&1 || {
+which success > /dev/null 2>&1 || {
success()
{
echo_n " SUCCESS"
@@ -92,7 +84,7 @@ start() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -0 $pid && [ $name = "$processname" ]; then
+ if kill -s 0 $pid && [ $name = "$processname" ]; then
echo_n " already running"
success; echo
subagent_running=1
@@ -121,7 +113,7 @@ start() {
while test $loop_counter -le $max_count ; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $pidfile ; then
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
sleep 1
else
break
@@ -131,7 +123,7 @@ start() {
break
fi
done
- if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
+ if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
success; echo
else
failure; echo
@@ -147,7 +139,7 @@ stop() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
subagent_stopped=0
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
subagent_stopped=1
@@ -164,7 +156,7 @@ stop() {
max_count=10
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
sleep 1
else
if test -f $pidfile ; then
@@ -200,7 +192,7 @@ condrestart() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -0 $pid && [ $name = "$processname" ]; then
+ if kill -s 0 $pid && [ $name = "$processname" ]; then
restart
fi
fi
@@ -210,7 +202,7 @@ status() {
ret=0
if [ -f $pidfile ]; then
pid=`cat $pidfile`
- if kill -0 $pid > /dev/null 2>&1 ; then
+ if kill -s 0 $pid > /dev/null 2>&1 ; then
echo "$prog (pid $pid) is running..."
else
echo "$prog dead but pid file exists"
commit 8ce49b576b5a31c78c06d5c865727f84ae684808
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Sep 14 11:15:36 2015 -0700
Revert "Ticket #47511 - bashisms in 389-ds-base admin scripts"
This reverts commit 2ce7a7334bcb89e47c0f5c544144aec37010a5b9.
diff --git a/ldap/admin/src/initconfig.in b/ldap/admin/src/initconfig.in
index 7afa315..134e82c 100644
--- a/ldap/admin/src/initconfig.in
+++ b/ldap/admin/src/initconfig.in
@@ -2,11 +2,11 @@
OS=`uname -s`
# use the new mt slab memory allocator on Solaris
# this requires Solaris 9 update 3 or later
-if [ "$OS" = "SunOS" ] && [ -f /usr/lib/libumem.so ] ; then
+if [ "$OS" = "SunOS" -a -f /usr/lib/libumem.so ] ; then
LD_PRELOAD=/usr/lib/libumem.so
export LD_PRELOAD
fi
-if [ "$OS" = "SunOS" ] && [ -f /usr/lib/64/libumem.so ] ; then
+if [ "$OS" = "SunOS" -a -f /usr/lib/64/libumem.so ] ; then
LD_PRELOAD_64=/usr/lib/64/libumem.so
export LD_PRELOAD_64
fi
diff --git a/ldap/admin/src/scripts/DSSharedLib.in b/ldap/admin/src/scripts/DSSharedLib.in
index 8317c58..3683696 100644
--- a/ldap/admin/src/scripts/DSSharedLib.in
+++ b/ldap/admin/src/scripts/DSSharedLib.in
@@ -98,13 +98,13 @@ get_init_file()
do
inst_count=`expr $inst_count + 1`
id=`normalize_server_id $configfile`
- if [ -n "$servid" ] && [ "$id" = "$servid" ]
+ if [ -n "$servid" -a "$id" = "$servid" ]
then
# found it
echo $configfile
exit 0
fi
- if [ $first = "yes" ]
+ if [ $first == "yes" ]
then
instances=$id
first="no"
@@ -114,7 +114,7 @@ get_init_file()
done
# server id not provided, check if there is only one instance
- if [ -z "$servid" ] && [ $inst_count -eq 1 ]
+ if [ -z "$servid" -a $inst_count -eq 1 ]
then
# return the file
echo $configfile
@@ -135,44 +135,48 @@ process_dse ()
configdir=$1
pid=$2
file="$configdir/dse.ldif"
- OLD_IFS=$IFS
+ shopt -s nocasematch
+ OLD_IFC=$IFC
IFS=""
while read -r LINE
do
- case $LINE in
- ' '*)
- ;;
- *)
- if [ -n "$output" ]
- then
- echo "$output" >> /tmp/DSSharedLib.$pid
- output=""
- fi
- ;;
- esac
- if [ -n "$output" ]
+ if [[ $LINE != \ * ]] && [ "$output" != "" ]
then
- case $LINE in
- ' '*)
- # continuation line, strip the space and append it
- LINE=`echo "$LINE" | sed -e 's/^ //'`
- output=$output$LINE
- ;;
- esac
- else
- case $LINE in
- nsslapd-certdir*|\
- nsslapd-ldapiautobind*|\
- nsslapd-ldapilisten*|\
- nsslapd-ldapifilepath*|\
- nsslapd-localhost*|\
- nsslapd-port*|\
- nsslapd-rootdn*|\
- nsslapd-securePort*|\
- nsslapd-security*)
- output=$LINE
- ;;
- esac
+ echo "$output" >> /tmp/DSSharedLib.$pid
+ output=""
+ fi
+ if [ "$output" != "" ] && [[ $LINE == \ * ]]
+ then
+ # continuation line, strip the space and append it
+ LINE=`echo "$LINE" | sed -e 's/^ //'`
+ output=$output$LINE
+ elif [[ $LINE == nsslapd-port* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-localhost* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-securePort* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-security* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-ldapilisten* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-ldapifilepath* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-rootdn* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-ldapiautobind* ]]
+ then
+ output=$LINE;
+ elif [[ $LINE == nsslapd-certdir* ]]
+ then
+ output=$LINE;
fi
done < $file
@@ -190,19 +194,19 @@ check_protocol ()
ldapi=$3
openldap=$4
- if [ "$protocol" = "LDAPI" ] && [ "$openldap" != "yes" ]; then
+ if [ "$protocol" == "LDAPI" ] && [ "$openldap" != "yes" ]; then
echo ""
exit
- elif [ "$protocol" = "LDAPI" ] && [ "$ldapi" = "off" ]; then
+ elif [ "$protocol" == "LDAPI" ] && [ "$ldapi" == "off" ]; then
echo ""
exit
- elif [ "$protocol" = "STARTTLS" ]; then
- if [ -z "$security" ] || [ "$security" = "off" ]; then
+ elif [ "$protocol" == "STARTTLS" ]; then
+ if [ "$security" == "" ] || [ "$security" == "off" ]; then
echo ""
exit
fi
- elif [ "$protocol" = "LDAPS" ]; then
- if [ -z "$security" ] || [ "$security" = "off" ]; then
+ elif [ "$protocol" == "LDAPS" ]; then
+ if [ "$security" == "" ] || [ "$security" == "off" ]; then
echo ""
exit
fi
@@ -220,4 +224,4 @@ check_protocol ()
fi
echo "$protocol"
-}
+}
\ No newline at end of file
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index a2e54cc..f0cede4 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -26,18 +26,15 @@ if [ $# -lt 1 ] || [ $# -gt 7 ]
then
usage
exit 1
+elif [[ $1 == -* ]]
+then
+ usage
+ exit 1
+else
+ archivedir=$1
+ shift
fi
-case $1 in
- -*)
- usage
- exit 1
- ;;
- *)
- archivedir=$1
- shift
- ;;
-esac
-
+
while getopts "hn:Z:qd:vi:a:SD:" flag
do
case $flag in
@@ -58,7 +55,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index 1896c19..dacd7b0 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -26,6 +26,7 @@ then
usage
exit 1
fi
+
if [ "$#" -gt 0 ]
then
if [[ $1 != -* ]]
@@ -55,7 +56,7 @@ done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
@@ -66,7 +67,7 @@ fi
servid=`normalize_server_id $initfile`
. $initfile
-if [ -z "$bak_dir" ]
+if [ -z $bak_dir ]
then
bak_dir=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H_%M_%S`
fi
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index 6a0785e..9af8fc8 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -59,7 +59,7 @@ then
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index fcf73a0..d7e0ff0 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -39,7 +39,7 @@ make_ldiffile()
be=""
while [ "$1" != "" ]
do
- if [ "x$1" = "x-a" ]; then
+ if [ "$1" = "-a" ]; then
shift
if [ `expr "$1" : "/.*"` -gt 0 ]; then
if [ `expr "$1" : "/.*"` -gt 0 ]; then
@@ -56,17 +56,17 @@ make_ldiffile()
shift
return 0
fi
- elif [ "x$1" = "x-n" ]; then
+ elif [ "$1" = "-n" ]; then
shift
- if [ -z "$be" ]; then
+ if [ "$be" = "" ]; then
be="$1"
else
tmpbe="$be"
be="${tmpbe}-$1"
fi
- elif [ "x$1" = "x-s" ]; then
+ elif [ "$1" = "-s" ]; then
shift
- if [ -n "$1" ]; then
+ if [ "$1" != "" ]; then
rdn=`echo $1 | awk -F, '{print $1}'`
rdnval=`echo $rdn | awk -F= '{print $2}'`
if [ "$be" = "" ]; then
@@ -76,15 +76,15 @@ make_ldiffile()
be="${tmpbe}-$rdnval"
fi
fi
- elif [ "x$1" = "x-M" ]; then
+ elif [ "$1" = "-M" ]; then
be=""
fi
- if [ -n "$1" ]; then
+ if [ "$1" != "" ]; then
shift
fi
done
- if [ -z "$be" ]; then
+ if [ "$be" = "" ]; then
echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
else
echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-${be}-`date +%Y_%m_%d_%H%M%S`.ldif
@@ -92,7 +92,7 @@ make_ldiffile()
return 0
}
-if [ $# -lt 2 ];
+if [ "$#" -lt 2 ];
then
usage
exit 1
@@ -137,7 +137,7 @@ then
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index bbacc17..461cc16 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -47,7 +47,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
@@ -58,7 +58,7 @@ fi
. $initfile
@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
-if [ $display_version = "yes" ]; then
+if [ $display_version == "yes" ]; then
exit 0
fi
if [ $? -eq 0 ]; then
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 616969a..32a70c8 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -39,7 +39,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index a34241a..ce15349 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -82,7 +82,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/ldif2ldap.in b/ldap/admin/src/scripts/ldif2ldap.in
index 1e871be..874b1bb 100755
--- a/ldap/admin/src/scripts/ldif2ldap.in
+++ b/ldap/admin/src/scripts/ldif2ldap.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@ldapsdk_libdir@"
libpath_add "@libdir@"
@@ -40,14 +40,14 @@ do
esac
done
-if [ -z "$input_file" ]
+if [ "$input_file" == "" ]
then
usage
exit 1
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 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 [ -z "$rootdn" ]; then
+if [ "$rootdn" == "" ]; then
value=$(grep -i 'nsslapd-rootdn' $file)
rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'`
fi
rm $file
-if [ -n "$ldapiURL" ]; then
+if [ "$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" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$security" == "on" ]; then
+ if [ "$protocol" == "STARTTLS" ] || [ "$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" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$security" == "on" ]; then
+ if [ "$protocol" == "LDAPS" ] || [ "$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" ] || [ -z "$protocol" ]; then
- if [ $(id -u) -eq 0 ] && [ "$autobind" = "on" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then
+ if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then
+ if [ "$(id -u)" == "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 -ne 0 ]
+ if [ $rc != 0 ]
then
echo "Operation failed (error $rc)"
fi
@@ -158,11 +158,11 @@ fi
#
# LDAP
#
-if [ "$protocol" = "LDAP" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$protocol" == "LDAP" ] || [ "$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
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index 36a2fc9..7b2058b 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@ldapsdk_libdir@"
@@ -41,7 +41,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
@@ -66,17 +66,17 @@ 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 [ -z "$rootdn" ]; then
+if [ "$rootdn" == "" ]; then
value=$(grep -i 'nsslapd-rootdn' $file)
rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'`
fi
rm $file
-if [ -n "$passwd" ]; then
+if [ "$passwd" != "" ]; then
dn="-D $rootdn"
passwd="-w$passwd"
fi
-if [ -n "$ldapiURL" ]
+if [ "$ldapiURL" != "" ]
then
ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'`
ldapiURL="ldapi://"$ldapiURL
@@ -103,12 +103,12 @@ protocol=$revised_protocol
#
# STARTTLS
#
-if [ "$security" = "on" ]; then
- if [ "$protocol" = "STARTTLS" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$security" == "on" ]; then
+ if [ "$protocol" == "STARTTLS" ] || [ "$protocol" == "" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(STARTTLS)"
fi
- if [ "$openldap" = "yes" ]; then
+ if [ "$openldap" == "yes" ]; then
ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -120,12 +120,12 @@ fi
#
# LDAPS
#
-if [ "$security" = "on" ]; then
- if [ "$protocol" = "LDAPS" ] || [ -z "$protocol" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$security" == "on" ]; then
+ if [ "$protocol" == "LDAPS" ] || [ "$protocol" == "" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(LDAPS)"
fi
- if [ "$openldap" = "yes" ]; then
+ if [ "$openldap" == "yes" ]; then
ldapsearch -x -LLL -H "ldaps://$host:$secure_port" -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -Z -P $certdir -p $secure_port -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -137,15 +137,15 @@ fi
#
# LDAPI
#
-if [ "$ldapi" = "on" ] && [ "$openldap" = "yes" ]; then
- if [ "$protocol" = "LDAPI" ] || [ -z "$protocol" ]; then
- if [ $(id -u) -eq 0 ] && [ "$autobind" = "on" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then
+ if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then
+ if [ "$(id -u)" == "0" ] && [ "$autobind" == "on" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(LDAPI/AUTOBIND)"
fi
ldapsearch -LLL -H "$ldapiURL" -b "$MDN" -s base -Y EXTERNAL "objectClass=*" 2>/dev/null
else
- if [ "$error" = "yes" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(LDAPI)"
fi
ldapsearch -x -LLL -H "$ldapiURL" -b "$MDN" -s base $dn $passwd "objectClass=*"
@@ -157,14 +157,14 @@ fi
#
# LDAP
#
-if [ "$protocol" = "LDAP" ] || [ "$protocol" = "" ]; then
- if [ "$error" = "yes" ]; then
+if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then
+ if [ "$error" == "yes" ]; then
echo "Using the next most secure protocol(LDAP)"
fi
- if [ "$openldap" = "yes" ]; then
+ if [ "$openldap" == "yes" ]; then
ldapsearch -x -LLL -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
ldapsearch -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
- fi
+ fi
exit $?
fi
diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in
index e86a24c..130e06e 100644
--- a/ldap/admin/src/scripts/restart-dirsrv.in
+++ b/ldap/admin/src/scripts/restart-dirsrv.in
@@ -7,7 +7,7 @@
# 2: Server started successfully (was not running)
# 3: Server could not be stopped
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
restart_instance() {
SERV_ID=$1
diff --git a/ldap/admin/src/scripts/restoreconfig.in b/ldap/admin/src/scripts/restoreconfig.in
index 56c9e43..9bb1acf 100755
--- a/ldap/admin/src/scripts/restoreconfig.in
+++ b/ldap/admin/src/scripts/restoreconfig.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@nss_libdir@"
@@ -31,7 +31,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/saveconfig.in b/ldap/admin/src/scripts/saveconfig.in
index 16e3efc..65d80f3 100755
--- a/ldap/admin/src/scripts/saveconfig.in
+++ b/ldap/admin/src/scripts/saveconfig.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -31,7 +31,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
@@ -45,7 +45,7 @@ servid=`normalize_server_id $initfile`
echo saving configuration...
conf_ldif=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
@sbindir@/ns-slapd db2ldif -N -D $CONFIG_DIR -s "o=NetscapeRoot" -a $conf_ldif -n NetscapeRoot 2>&1
-if [ $? -ge 1 ]
+if [ "$?" -ge 1 ]
then
echo Error occurred while saving configuration
exit 1
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
index 458f0e8..481797d 100755
--- a/ldap/admin/src/scripts/start-dirsrv.in
+++ b/ldap/admin/src/scripts/start-dirsrv.in
@@ -6,7 +6,7 @@
# 1: Server could not be started
# 2: Server already running
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
# Starts a single instance
start_instance() {
@@ -44,7 +44,7 @@ start_instance() {
STARTPIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.startpid
if test -f $STARTPIDFILE ; then
PID=`cat $STARTPIDFILE`
- if kill -s 0 $PID > /dev/null 2>&1 ; then
+ if kill -0 $PID > /dev/null 2>&1 ; then
echo There is an ns-slapd process already running: $PID
return 2;
else
@@ -53,7 +53,7 @@ start_instance() {
fi
if test -f $PIDFILE ; then
PID=`cat $PIDFILE`
- if kill -s 0 $PID > /dev/null 2>&1 ; then
+ if kill -0 $PID > /dev/null 2>&1 ; then
echo There is an ns-slapd running: $PID
return 2;
else
@@ -64,7 +64,7 @@ start_instance() {
# Use systemctl if available and running as root,
# otherwise start the instance the old way.
#
- if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
+ if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
@bindir@/systemctl start @package_name@(a)$SERV_ID.service
if [ $? -ne 0 ]; then
return 1
@@ -96,7 +96,7 @@ start_instance() {
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $PIDFILE ; then
- if kill -s 0 $PID > /dev/null 2>&1 ; then
+ if kill -0 $PID > /dev/null 2>&1 ; then
sleep 1
else
echo Server failed to start !!! Please check errors log for problems
@@ -123,12 +123,12 @@ do
done
shift $(($OPTIND-1))
-if [ -z "$initconfig_dir" ]; then
+if [ "$initconfig_dir" = "" ]; then
initconfig_dir=@initconfigdir@
fi
found=0
-if [ $# -eq 0 ]; then
+if [ "$#" -eq 0 ]; then
# We're starting all instances.
ret=0
initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
@@ -137,7 +137,7 @@ if [ $# -eq 0 ]; then
echo Starting instance \"$inst\"
start_instance $inst
rv=$?
- if [ $rv -ne 0 ]; then
+ if [ "$rv" -ne 0 ]; then
ret=$rv
fi
done
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
index 72e2b85..3f02e78 100755
--- a/ldap/admin/src/scripts/stop-dirsrv.in
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
@@ -6,7 +6,7 @@
# 1: Server could not be stopped
# 2: Server was not running
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
stop_instance() {
SERV_ID=$1
@@ -28,7 +28,7 @@ stop_instance() {
fi
PID=`cat $PIDFILE`
# see if the server is already stopped
- kill -s 0 $PID > /dev/null 2>&1 || {
+ kill -0 $PID > /dev/null 2>&1 || {
echo Server not running
if test -f $PIDFILE ; then
rm -f $PIDFILE
@@ -39,7 +39,7 @@ stop_instance() {
#
# use systemctl if running as root
#
- if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
+ if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
#
# Now, check if systemctl is aware of this running instance
#
@@ -65,7 +65,7 @@ stop_instance() {
max_count=600
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -s 0 $PID > /dev/null 2>&1 ; then
+ if kill -0 $PID > /dev/null 2>&1 ; then
sleep 1;
else
if test -f $PIDFILE ; then
@@ -88,11 +88,11 @@ do
done
shift $(($OPTIND-1))
-if [ -z "$initconfig_dir" ]; then
+if [ "$initconfig_dir" = "" ]; then
initconfig_dir=@initconfigdir@
fi
-if [ $# -eq 0 ]; then
+if [ "$#" -eq 0 ]; then
# We're stopping all instances.
ret=0
initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
@@ -105,7 +105,7 @@ if [ $# -eq 0 ]; then
echo Stopping instance \"$inst\"
stop_instance $inst
rv=$?
- if [ $rv -ne 0 ]; then
+ if [ "$rv" -ne 0 ]; then
ret=$rv
fi
done
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index 7774148..e2f73c3 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -32,14 +32,14 @@ do
esac
done
-if [ -z "$args" ]
+if [ "$args" == "" ]
then
usage
exit 1
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index bf600dd..211bdce 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -39,7 +39,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
echo "Available instances: $initfile"
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index 51585ae..e9d8cab 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
# upgradednformat -- upgrade DN format to the new style (RFC 4514)
# Usgae: upgradednformat [-N] -n backend_instance -a db_instance_directory
@@ -49,13 +49,13 @@ do
esac
done
-if [ -z "$be" ] || [ -z "$dir" ]; then
+if [ "$be" = "" ] || [ "$dir" = "" ]; then
usage
exit 1
fi
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index 365e32f..0b46b27 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -1,6 +1,6 @@
#!/bin/sh
-. @datadir@/@package_name@/data/DSSharedLib
+source @datadir@/@package_name@/data/DSSharedLib
libpath_add "@libdir@/@package_name@/"
libpath_add "@libdir@"
@@ -45,7 +45,7 @@ do
done
initfile=$(get_init_file "@initconfigdir@" $servid)
-if [ $? -eq 1 ]
+if [ $? == 1 ]
then
usage
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
diff --git a/rpm/389-ds-base-git.sh b/rpm/389-ds-base-git.sh
index 1a38da1..e5aaa8a 100644
--- a/rpm/389-ds-base-git.sh
+++ b/rpm/389-ds-base-git.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
DATE=`date +%Y%m%d`
# use a real tag name here
diff --git a/rpm/add_patches.sh b/rpm/add_patches.sh
index 31823d5..690d0b2 100755
--- a/rpm/add_patches.sh
+++ b/rpm/add_patches.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-usage()
+function usage()
{
echo "Adds patches to a specfile"
echo ""
@@ -51,5 +51,5 @@ for p in $patches; do
sed -i -e "/${prefix}/a Patch${i}: ${p}" -e "/$prepprefix/a %patch${i} -p1" $specfile
prefix="Patch${i}:"
prepprefix="%patch${i}"
- i=`expr $i + 1`
+ i=$(($i+1))
done
diff --git a/rpm/rpmverrel.sh b/rpm/rpmverrel.sh
index 06e97c7..86b808e 100755
--- a/rpm/rpmverrel.sh
+++ b/rpm/rpmverrel.sh
@@ -6,7 +6,7 @@ srcdir=`pwd`
# Source VERSION.sh to set the version
# and release environment variables.
-. ./VERSION.sh
+source ./VERSION.sh
if [ "$1" = "version" ]; then
echo $RPM_VERSION
diff --git a/wrappers/initscript.in b/wrappers/initscript.in
index fa79dbd..ad4ea2b 100644
--- a/wrappers/initscript.in
+++ b/wrappers/initscript.in
@@ -32,20 +32,28 @@ then
fi
fi
+# figure out which echo we're using
+ECHO_N=`echo -n`
+
+# some shells echo cannot use -n - linux echo by default cannot use \c
echo_n()
{
- printf '%s' "$*"
+ if [ "$ECHO_N" = '-n' ] ; then
+ echo "$*\c"
+ else
+ echo -n "$*"
+ fi
}
# failure and success are not defined on some platforms
-which failure > /dev/null 2>&1 || {
+type failure > /dev/null 2>&1 || {
failure()
{
echo_n " FAILED"
}
}
-which success > /dev/null 2>&1 || {
+type success > /dev/null 2>&1 || {
success()
{
echo_n " SUCCESS"
@@ -170,7 +178,7 @@ start() {
pid=`cat $pidfile`
instlockfile="@localstatedir@/lock/@package_name@/slapd-$instance/server/$pid"
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -s 0 $pid && [ $name = "ns-slapd" ]; then
+ if kill -0 $pid && [ $name = "ns-slapd" ]; then
echo_n " already running"
success; echo
successes=`expr $successes + 1`
@@ -231,7 +239,7 @@ start() {
while test $loop_counter -le $max_count ; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $pidfile ; then
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
sleep 1
else
break
@@ -241,7 +249,7 @@ start() {
break
fi
done
- if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
+ if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
success; echo
successes=`expr $successes + 1`
else
@@ -270,7 +278,7 @@ stop() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
server_stopped=0
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
server_stopped=1
@@ -289,7 +297,7 @@ stop() {
max_count=600
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
sleep 1
else
if test -f $pidfile ; then
@@ -331,7 +339,7 @@ status() {
for instance in $INSTANCES; do
if [ -f $piddir/slapd-$instance.pid ]; then
pid=`cat $piddir/slapd-$instance.pid`
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
echo "$prog $instance (pid $pid) is running..."
else
echo "$prog $instance dead but pid file exists"
diff --git a/wrappers/ldap-agent-initscript.in b/wrappers/ldap-agent-initscript.in
index b7aa4fe..dd8ee97 100644
--- a/wrappers/ldap-agent-initscript.in
+++ b/wrappers/ldap-agent-initscript.in
@@ -31,20 +31,28 @@ then
fi
fi
+# figure out which echo we're using
+ECHO_N=`echo -n`
+
+# some shells echo cannot use -n - linux echo by default cannot use \c
echo_n()
{
- printf '%s' "$*"
+ if [ "$ECHO_N" = '-n' ] ; then
+ echo "$*\c"
+ else
+ echo -n "$*"
+ fi
}
# failure and success are not defined on some platforms
-which failure > /dev/null 2>&1 || {
+type failure > /dev/null 2>&1 || {
failure()
{
echo_n " FAILED"
}
}
-which success > /dev/null 2>&1 || {
+type success > /dev/null 2>&1 || {
success()
{
echo_n " SUCCESS"
@@ -84,7 +92,7 @@ start() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -s 0 $pid && [ $name = "$processname" ]; then
+ if kill -0 $pid && [ $name = "$processname" ]; then
echo_n " already running"
success; echo
subagent_running=1
@@ -113,7 +121,7 @@ start() {
while test $loop_counter -le $max_count ; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $pidfile ; then
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
sleep 1
else
break
@@ -123,7 +131,7 @@ start() {
break
fi
done
- if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
+ if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
success; echo
else
failure; echo
@@ -139,7 +147,7 @@ stop() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
subagent_stopped=0
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
subagent_stopped=1
@@ -156,7 +164,7 @@ stop() {
max_count=10
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
sleep 1
else
if test -f $pidfile ; then
@@ -192,7 +200,7 @@ condrestart() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
- if kill -s 0 $pid && [ $name = "$processname" ]; then
+ if kill -0 $pid && [ $name = "$processname" ]; then
restart
fi
fi
@@ -202,7 +210,7 @@ status() {
ret=0
if [ -f $pidfile ]; then
pid=`cat $pidfile`
- if kill -s 0 $pid > /dev/null 2>&1 ; then
+ if kill -0 $pid > /dev/null 2>&1 ; then
echo "$prog (pid $pid) is running..."
else
echo "$prog dead but pid file exists"
commit f2c2eac92af3e46df392bb361afe3c2cd7441847
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Sep 14 11:15:26 2015 -0700
Revert "Ticket #48254 - Shell CLI fails with usage errors if an argument containing white spaces is given"
This reverts commit 5fe28921810a53dcd31525ba1f675582b6aba0f7.
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
index ab7c6b3..a2e54cc 100755
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -44,12 +44,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n \"$OPTARG\"";;
+ n) args=$args" -n $OPTARG";;
q) args=$args" -q";;
- d) args=$args" -d \"$OPTARG\"";;
+ d) args=$args" -d $OPTARG";;
v) args=$args" -v";;
- D) args=$args" -D \"$OPTARG\"";;
- i) args=$args" -i \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
+ i) args=$args" -i $OPTARG";;
a) archivedir=$OPTARG;;
S) args=$args" -S";;
?) usage
@@ -76,4 +76,4 @@ else
archivedir=`pwd`/$archivedir
fi
-eval @sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
+@sbindir@/ns-slapd archive2db -D $CONFIG_DIR -a $archivedir $args
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
index adbe30b..1896c19 100755
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -43,10 +43,10 @@ do
q) args=$args" -q";;
v) args=$args" -v";;
S) args=$args" -S";;
- D) args=$args" -D \"$OPTARG\"";;
- i) args=$args" -i \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
+ i) args=$args" -i $OPTARG";;
a) $bakdir=$OPTARG;;
- d) args=$args" -d \"$OPTARG\"";;
+ d) args=$args" -d $OPTARG";;
Z) servid=$OPTARG;;
?) usage
exit 1;;
@@ -72,4 +72,4 @@ then
fi
echo "Back up directory: $bak_dir"
-eval @sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
+@sbindir@/ns-slapd db2archive -D $CONFIG_DIR -a $bak_dir $args
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
index c8e9075..6a0785e 100755
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -35,15 +35,15 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n \"$OPTARG\""
+ n) args=$args" -n $OPTARG"
benameopt="set";;
- s) args=$args" -s \"$OPTARG\""
+ s) args=$args" -s $OPTARG"
includeSuffix="set";;
t) args=$args" -t "\"$OPTARG\";;
T) args=$args" -T "\"$OPTARG\";;
- d) args=$args" -d \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\"";;
- x) args=$args" -x \"$OPTARG\"";;
+ d) args=$args" -d $OPTARG";;
+ a) args=$args" -a $OPTARG";;
+ x) args=$args" -x $OPTARG";;
v) args=$args" -v";;
S) args=$args" -S";;
D) args=$args" -D $OPTARG";;
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
index e9f7f7e..fcf73a0 100755
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -106,12 +106,12 @@ do
Z) servid=$OPTARG;;
n) benameopt="-n $OPTARG"
required_param="yes";;
- s) includeSuffix="-s \"$OPTARG\""
+ s) includeSuffix="-s $OPTARG"
required_param="yes";;
- x) excludeSuffix="-x \"$OPTARG\"";;
- a) outputFile="-a \"$OPTARG\"";;
- d) args=$args" -d \"$OPTARG\"";;
- D) args=$args" -D \"$OPTARG\"";;
+ x) excludeSuffix="-x $OPTARG";;
+ a) outputFile="-a $OPTARG";;
+ d) args=$args" -d $OPTARG";;
+ D) args=$args" -D $OPTARG";;
N) args=$args" -N";;
E) args=$args" -E";;
S) args=$args" -S";;
@@ -154,7 +154,7 @@ rn=$?
echo "Exported ldif file: $ldif_file"
if [ $rn -eq 1 ]
then
- eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
+ @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $outputFile $args
else
- eval @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
+ @sbindir@/ns-slapd db2ldif -D $CONFIG_DIR $benameopt $includeSuffix $excludeSuffix $args -a $ldif_file
fi
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
index b98e9b2..bbacc17 100755
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -33,14 +33,14 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n \"$OPTARG\"";;
- d) args=$args" -d \"$OPTARG\"";;
+ n) args=$args" -n $OPTARG";;
+ d) args=$args" -d $OPTARG";;
V) args=$args" -V";;
v) args=$args" -v"
display_version="yes";;
f) args=$args" -f";;
- D) args=$args" -D \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
+ a) args=$args" -a $OPTARG";;
?) usage
exit 1;;
esac
@@ -57,7 +57,7 @@ fi
. $initfile
-eval @sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
+@sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
if [ $display_version = "yes" ]; then
exit 0
fi
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
index 762e63a..616969a 100755
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -27,12 +27,12 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- d) arg=$arg" -d \"$OPTARG\"";;
- a) arg=$arg" -a \"$OPTARG\""
+ d) arg=$arg" -d $OPTARG";;
+ a) arg=$arg" -a $OPTARG"
archive="provided";;
v) arg=$arg" -v";;
f) arg=$arg" -f";;
- D) arg=$arg" -D \"$OPTARG\"";;
+ D) arg=$arg" -D $OPTARG";;
?) usage
exit 1;;
esac
@@ -55,4 +55,4 @@ if [ "$archive" != "provided" ]; then
args=$args"-a $bak_dir"
fi
-eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
+@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR -r $args
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
index 3aed469..a34241a 100755
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -59,16 +59,16 @@ do
h) usage
exit 0;;
Z) servid=$OPTARG;;
- n) args=$args" -n \"$OPTARG\"";;
- i) args=$args" -i \"$OPTARG\"";;
- s) args=$args" -s \"$OPTARG\"";;
- x) args=$args" -x \"$OPTARG\"";;
- c) args=$args" -c \"$OPTARG\"";;
- d) args=$args" -d \"$OPTARG\"";;
- g) args=$args" -g \"$OPTARG\"";;
- G) args=$args" -G \"$OPTARG\"";;
- t) args=$args" -t \"$OPTARG\"";;
- D) args=$args" -D \"$OPTARG\"";;
+ n) args=$args" -n $OPTARG";;
+ i) args=$args" -i $OPTARG";;
+ s) args=$args" -s $OPTARG";;
+ x) args=$args" -x $OPTARG";;
+ c) args=$args" -c $OPTARG";;
+ d) args=$args" -d $OPTARG";;
+ g) args=$args" -g $OPTARG";;
+ G) args=$args" -G $OPTARG";;
+ t) args=$args" -t $OPTARG";;
+ D) args=$args" -D $OPTARG";;
E) args=$args" -E";;
v) args=$args" -v";;
N) args=$args" -N";;
@@ -104,6 +104,6 @@ if [ $quiet -eq 0 ]; then
echo importing data ...
fi
-eval @sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
+@sbindir@/ns-slapd ldif2db -D $CONFIG_DIR $args 2>&1
exit $?
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
index e9265a1..36a2fc9 100755
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -73,8 +73,8 @@ fi
rm $file
if [ -n "$passwd" ]; then
- dn="-D \"$rootdn\""
- passwd="-w \"$passwd\""
+ dn="-D $rootdn"
+ passwd="-w$passwd"
fi
if [ -n "$ldapiURL" ]
then
@@ -109,9 +109,9 @@ if [ "$security" = "on" ]; then
echo "Using the next most secure protocol(STARTTLS)"
fi
if [ "$openldap" = "yes" ]; then
- eval ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
else
- eval ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
+ ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
fi
exit $?
fi
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
index d7c6661..7774148 100755
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -24,7 +24,7 @@ while getopts "Z:s:h" flag
do
case $flag in
Z) servid=$OPTARG;;
- s) args=$args" -s \"$OPTARG\"";;
+ s) args=$args" -s $OPTARG";;
h) usage
exit 0;;
?) usage
@@ -55,4 +55,4 @@ then
exit 1
fi
-eval @sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
+@sbindir@/ns-slapd suffix2instance -D $CONFIG_DIR $args 2>&1
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
index 2b7c79d..bf600dd 100755
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -29,10 +29,10 @@ do
v) args=$args" -v";;
f) args=$args" -f";;
r) args=$args" -r";;
- d) args=$args" -d \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\""
+ d) args=$args" -d $OPTARG";;
+ a) args=$args" -a $OPTARG"
archive_provided="yes";;
- D) args=$args" -D \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
h) usage
exit 0;;
esac
@@ -56,4 +56,4 @@ then
fi
echo upgrade index files ...
-eval @sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
+@sbindir@/ns-slapd upgradedb -D $CONFIG_DIR $args
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
index 9de60ea..51585ae 100755
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -36,14 +36,14 @@ do
Z) servid=$OPTARG;;
v) args=$args" -v";;
N) args=$args" -N";;
- d) args=$args" -d \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\""
+ d) args=$args" -d $OPTARG";;
+ a) args=$args" -a $OPTARG"
dir="set";;
- n) args=$args" -n \"$OPTARG\""
+ n) args=$args" -n $OPTARG"
be="set";;
h) usage
exit 0;;
- D) args=$args" -D \"$OPTARG\"";;
+ D) args=$args" -D $OPTARG";;
?) usage
exit 1;;
esac
@@ -65,7 +65,7 @@ fi
. $initfile
-eval @sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
+@sbindir@/ns-slapd upgradednformat -D $CONFIG_DIR $args
rc=$?
exit $rc
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
index a1696bc..365e32f 100755
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -29,14 +29,14 @@ do
case $flag in
Z) servid=$OPTARG;;
v) args=$args" -v";;
- s) args=$args" -s \"$OPTARG\"";;
- d) args=$args" -d \"$OPTARG\"";;
- a) args=$args" -a \"$OPTARG\"";;
- T) args=$args" -T \"$OPTARG\"";;
+ s) args=$args" -s $OPTARG";;
+ d) args=$args" -d $OPTARG";;
+ a) args=$args" -a $OPTARG";;
+ T) args=$args" -T $OPTARG";;
S) args=$args" -S";;
- n) args=$args" -n \"$OPTARG\"";;
- x) args=$args" -x \"$OPTARG\"";;
- D) args=$args" -D \"$OPTARG\"";;
+ n) args=$args" -n $OPTARG";;
+ x) args=$args" -x $OPTARG";;
+ D) args=$args" -D $OPTARG";;
h) usage
exit 0;;
?) usage
@@ -61,4 +61,4 @@ then
exit 1
fi
-eval @sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
+@sbindir@/ns-slapd db2index -D $CONFIG_DIR $args
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 7 months