From 411f76d392072a5688e81c50e5fb3462cd4623f6 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Mon, 10 Jun 2024 16:01:25 +0200 Subject: [PATCH 1/4] Start using -H instead of deprecated -h and -p. Fixes #49 --- bin/bdii-update | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/bdii-update b/bin/bdii-update index 41ac979..dd80a91 100755 --- a/bin/bdii-update +++ b/bin/bdii-update @@ -271,6 +271,8 @@ def read_ldif(source): # Open pipe to LDIF if source[:7] == 'ldap://': url = source.split('/') + # TODO: use -H + # FIXME: where is my port? command = "ldapsearch -LLL -x -h %s -b %s 2>/dev/null" % ( url[2], url[3]) pipe = os.popen(command) @@ -701,7 +703,7 @@ def main(config, log): if "o=shadow" in config['BDII_PASSWD']: if root == "o=grid": bind = "o=shadow" - input_fh = os.popen(("ldapadd -d 256 -x -c -h %s -p %s" + input_fh = os.popen(("ldapadd -d 256 -x -c -H ldap://%s:%s" " -D %s -y %s >/dev/null 2>%s") % ( config['BDII_HOSTNAME'], config['BDII_PORT'], @@ -741,7 +743,7 @@ def main(config, log): if "o=shadow" in config['BDII_PASSWD']: if root == "o=grid": bind = "o=shadow" - input_fh = os.popen(("ldapmodify -d 256 -x -c -h %s -p %s -D" + input_fh = os.popen(("ldapmodify -d 256 -x -c -H ldap://%s:%s -D" " %s -y %s >/dev/null 2>%s") % ( config['BDII_HOSTNAME'], config['BDII_PORT'], @@ -841,7 +843,7 @@ def main(config, log): if "o=shadow" in config['BDII_PASSWD']: if root == "o=grid": bind = "o=shadow" - input_fh = os.popen(("ldapdelete -d 256 -x -c -h %s -p %s" + input_fh = os.popen(("ldapdelete -d 256 -x -c -H ldap://%s:%s" " -D %s -y %s >/dev/null 2>%s") % ( config['BDII_HOSTNAME'], config['BDII_PORT'], @@ -869,7 +871,7 @@ def main(config, log): for root in roots.keys(): # Stop flapping due to o=shadow if root == "o=shadow": - command = ("ldapsearch -LLL -x -h %s -p %s -b %s -s base" + command = ("ldapsearch -LLL -x -H ldap://%s:%s -b %s -s base" " >> %s/old.ldif 2>> %s/old.err") % ( config['BDII_HOSTNAME'], config['BDII_PORT'], @@ -877,7 +879,7 @@ def main(config, log): config['BDII_VAR_DIR'], config['BDII_VAR_DIR']) else: - command = ("ldapsearch -LLL -x -h %s -p %s -b %s" + command = ("ldapsearch -LLL -x -H ldap://%s:%s -b %s" " >> %s/old.ldif 2>> %s/old.err") % ( config['BDII_HOSTNAME'], config['BDII_PORT'], @@ -917,7 +919,7 @@ def main(config, log): infosys_output += "replace: Data\n" infosys_output += "Data: file://%s\n\n" % out_file try: - output_fh = os.popen(("%s -x -c -h %s -p %s -D o=infosys -y %s" + output_fh = os.popen(("%s -x -c -H ldap://%s:%s -D o=infosys -y %s" " >/dev/null") % ( command, config['BDII_HOSTNAME'], @@ -989,7 +991,7 @@ def main(config, log): infosys_output += "-\n" infosys_output += "\n" try: - output_fh = os.popen(("%s -x -c -h %s -p %s -D o=infosys -y %s" + output_fh = os.popen(("%s -x -c -h ldap://%s:%s -D o=infosys -y %s" " >/dev/null") % ( command, config['BDII_HOSTNAME'], From a1c135da87896c6c3cc7434b44fcbb35e1e0c4fb Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Mon, 10 Jun 2024 16:19:00 +0200 Subject: [PATCH 2/4] just use -H, if a port is available in the URI it should be used. If missing the default port 389 would likely be used. --- bin/bdii-update | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/bdii-update b/bin/bdii-update index dd80a91..ec8d069 100755 --- a/bin/bdii-update +++ b/bin/bdii-update @@ -271,9 +271,7 @@ def read_ldif(source): # Open pipe to LDIF if source[:7] == 'ldap://': url = source.split('/') - # TODO: use -H - # FIXME: where is my port? - command = "ldapsearch -LLL -x -h %s -b %s 2>/dev/null" % ( + command = "ldapsearch -LLL -x -H %s -b %s 2>/dev/null" % ( url[2], url[3]) pipe = os.popen(command) elif source[:7] == 'file://': From 0e0d95f45655ba88dd9e0f9335a6390b034e4284 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Tue, 11 Jun 2024 11:00:08 +0200 Subject: [PATCH 3/4] Fix parameter --- bin/bdii-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/bdii-update b/bin/bdii-update index ec8d069..90012a7 100755 --- a/bin/bdii-update +++ b/bin/bdii-update @@ -989,7 +989,7 @@ def main(config, log): infosys_output += "-\n" infosys_output += "\n" try: - output_fh = os.popen(("%s -x -c -h ldap://%s:%s -D o=infosys -y %s" + output_fh = os.popen(("%s -x -c -H ldap://%s:%s -D o=infosys -y %s" " >/dev/null") % ( command, config['BDII_HOSTNAME'], From 1756a2aa8759cc14fc4469e82e3236d52ea02a42 Mon Sep 17 00:00:00 2001 From: Baptiste Grenier Date: Fri, 14 Jun 2024 15:07:41 +0200 Subject: [PATCH 4/4] Ensure scheme is provided --- bin/bdii-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/bdii-update b/bin/bdii-update index 90012a7..9a167cc 100755 --- a/bin/bdii-update +++ b/bin/bdii-update @@ -271,7 +271,7 @@ def read_ldif(source): # Open pipe to LDIF if source[:7] == 'ldap://': url = source.split('/') - command = "ldapsearch -LLL -x -H %s -b %s 2>/dev/null" % ( + command = "ldapsearch -LLL -x -H ldap://%s -b %s 2>/dev/null" % ( url[2], url[3]) pipe = os.popen(command) elif source[:7] == 'file://':