From d0eae40961c78f61183b7ef90ff24fe3f95becbf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Tue, 13 Apr 2021 11:37:31 +0100 Subject: [PATCH] Expose slapTool for use elsewhere --- servers/slapd/slap.h | 16 ++++++++++++++++ servers/slapd/slapcommon.c | 2 ++ servers/slapd/slapcommon.h | 14 -------------- servers/slapd/slappasswd.c | 5 ++++- servers/slapd/slapschema.c | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index e85816e46c..335b2b268e 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1612,6 +1612,22 @@ LDAP_SLAPD_V (int) slapMode; #define SB_TLS_ON 1 #define SB_TLS_CRITICAL 2 +enum slaptool { + SLAPADD=1, /* LDIF -> database tool */ + SLAPCAT, /* database -> LDIF tool */ + SLAPDN, /* DN check w/ syntax tool */ + SLAPINDEX, /* database index tool */ + SLAPMODIFY, /* database modify tool */ + SLAPPASSWD, /* password generation tool */ + SLAPSCHEMA, /* schema checking tool */ + SLAPTEST, /* slapd.conf test tool */ + SLAPAUTH, /* test authz-regexp and authc/authz stuff */ + SLAPACL, /* test acl */ + SLAPLAST +}; + +LDAP_SLAPD_V(enum slaptool) slapTool; + typedef struct slap_keepalive { int sk_idle; int sk_probes; diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index be24359a92..09b2215466 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -39,6 +39,7 @@ #include "ldif.h" tool_vars tool_globals; +enum slaptool slapTool; #ifdef CSRIMALLOC static char *leakfilename; @@ -671,6 +672,7 @@ slap_tool_init( * initialize stuff and figure out which backend we're dealing with */ + slapTool = tool; rc = slap_init( mode, progname ); if ( rc != 0 ) { fprintf( stderr, "%s: slap_init failed!\n", progname ); diff --git a/servers/slapd/slapcommon.h b/servers/slapd/slapcommon.h index 744e1af021..bd4054b6ca 100644 --- a/servers/slapd/slapcommon.h +++ b/servers/slapd/slapcommon.h @@ -20,20 +20,6 @@ #define SLAPD_TOOLS 1 #include "slap.h" -enum slaptool { - SLAPADD=1, /* LDIF -> database tool */ - SLAPCAT, /* database -> LDIF tool */ - SLAPDN, /* DN check w/ syntax tool */ - SLAPINDEX, /* database index tool */ - SLAPMODIFY, /* database modify tool */ - SLAPPASSWD, /* password generation tool */ - SLAPSCHEMA, /* schema checking tool */ - SLAPTEST, /* slapd.conf test tool */ - SLAPAUTH, /* test authz-regexp and authc/authz stuff */ - SLAPACL, /* test acl */ - SLAPLAST -}; - typedef struct tool_vars { Backend *tv_be; int tv_dbnum; diff --git a/servers/slapd/slappasswd.c b/servers/slapd/slappasswd.c index 012c5daf2d..2028db4fa1 100644 --- a/servers/slapd/slappasswd.c +++ b/servers/slapd/slappasswd.c @@ -37,9 +37,11 @@ #include #include "ldap_defaults.h" + #include "slap.h" +#include "slap-config.h" +#include "slapcommon.h" -static int verbose = 0; static char *modulepath = NULL; static char *moduleload = NULL; @@ -204,6 +206,7 @@ slappasswd( int argc, char *argv[] ) usage ( progname ); } } + slapTool = SLAPPASSWD; if( argc - optind != 0 ) { usage( progname ); diff --git a/servers/slapd/slapschema.c b/servers/slapd/slapschema.c index 93107968b0..044c665204 100644 --- a/servers/slapd/slapschema.c +++ b/servers/slapd/slapschema.c @@ -53,7 +53,7 @@ slapschema( int argc, char **argv ) int requestBSF = 0; int doBSF = 0; - slap_tool_init( progname, SLAPCAT, argc, argv ); + slap_tool_init( progname, SLAPSCHEMA, argc, argv ); requestBSF = ( sub_ndn.bv_len || filter ); -- 2.47.3