Skip to content

Commit 29c3a53

Browse files
committed
Switch to using slapd + -T<tool> for tool use
Using a locally compiled OpenLDAP impossible without this as libtool wrappers eat argv[0] of the symlinked binaries. Using a locally compiled OpenLDAP still often needs changes to the configuration, this should be a reasonably easy step forward.
1 parent 3957526 commit 29c3a53

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Lib/slapdtest/_slapdtest.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ def _find_commands(self):
259259
self.PATH_LDAPDELETE = self._find_command('ldapdelete')
260260
self.PATH_LDAPMODIFY = self._find_command('ldapmodify')
261261
self.PATH_LDAPWHOAMI = self._find_command('ldapwhoami')
262-
self.PATH_SLAPADD = self._find_command('slapadd')
263262

264263
self.PATH_SLAPD = os.environ.get('SLAPD', None)
265264
if not self.PATH_SLAPD:
@@ -276,7 +275,7 @@ def _find_command(self, cmd, in_sbin=False):
276275
if command is None:
277276
raise ValueError(
278277
"Command '{}' not found. Set the {} environment variable to "
279-
"override slapdtest's search path.".format(cmd, var_name)
278+
"override slapdtest's search path: {}.".format(cmd, var_name, path)
280279
)
281280
return command
282281

@@ -347,6 +346,7 @@ def gen_config(self):
347346
'cafile': self.cafile,
348347
'servercert': self.servercert,
349348
'serverkey': self.serverkey,
349+
'slapd_path': self.SBIN_PATH,
350350
}
351351
return self.slapd_conf_template % config_dict
352352

@@ -508,14 +508,17 @@ def _cli_auth_args(self):
508508

509509
# no cover to avoid spurious coverage changes
510510
def _cli_popen(self, ldapcommand, extra_args=None, ldap_uri=None,
511-
stdin_data=None): # pragma: no cover
511+
stdin_data=None, tool=None): # pragma: no cover
512512
if ldap_uri is None:
513513
ldap_uri = self.default_ldap_uri
514514

515515
if ldapcommand.split("/")[-1].startswith("ldap"):
516516
args = [ldapcommand, '-H', ldap_uri] + self._cli_auth_args()
517517
else:
518-
args = [ldapcommand, '-F', self._slapd_conf]
518+
if tool:
519+
args = [ldapcommand, '-T', tool, '-F', self._slapd_conf]
520+
else:
521+
args = [ldapcommand, '-F', self._slapd_conf]
519522

520523
args += (extra_args or [])
521524

@@ -574,9 +577,10 @@ def slapadd(self, ldif, extra_args=None):
574577
Runs slapadd on this slapd instance, passing it the ldif content
575578
"""
576579
self._cli_popen(
577-
self.PATH_SLAPADD,
580+
self.PATH_SLAPD,
578581
stdin_data=ldif.encode("utf-8") if ldif else None,
579582
extra_args=extra_args,
583+
tool='add'
580584
)
581585

582586
def __enter__(self):

0 commit comments

Comments
 (0)