ITS#9517 Add module args support to slappaswd and relevant docs

This commit is contained in:
Ondřej Kuzník 2021-04-09 10:38:42 +01:00
parent d0eae40961
commit 8b353df0e2
5 changed files with 29 additions and 7 deletions

View file

@ -1063,8 +1063,9 @@ per
Normally the config engine generates the "{x}" index in the RDN
automatically, so it can be omitted when initially loading these entries.
.TP
.B olcModuleLoad: <filename>
Specify the name of a dynamically loadable module to load. The filename
.B olcModuleLoad: <filename> [<arguments>...]
Specify the name of a dynamically loadable module to load and any
additional arguments if supported by the module. The filename
may be an absolute path name or a simple filename. Non-absolute names
are searched for in the directories specified by the
.B olcModulePath

View file

@ -747,8 +747,9 @@ help analyze the logs.
Specify the maximum depth of nested filters in search requests.
The default is 1000.
.TP
.B moduleload <filename>
Specify the name of a dynamically loadable module to load. The filename
.B moduleload <filename> [<arguments>...]
Specify the name of a dynamically loadable module to load and any
additional arguments if supported by the module. The filename
may be an absolute path name or a simple filename. Non-absolute names
are searched for in the directories specified by the
.B modulepath

View file

@ -75,6 +75,14 @@ The relevant option/value is:
.BR module\-load = argon2
.LP
.RE
Or if non-default parameters are required:
.RS
.LP
.B \-o
.BR module\-load =" argon2
.RB [ <param> ...]"
.LP
.RE
Depending on
.BR argon2 's
location, you may also need:

View file

@ -165,7 +165,7 @@ Possible generic options/values are:
.LP
.nf
module\-path=<pathspec> (see `\fBmodulepath\fP' in slapd.conf(5))
module\-load=<filename> (see `\fBmoduleload\fP' in slapd.conf(5))
module\-load="<filename> [<arguments>...]" (see `\fBmoduleload\fP' in slapd.conf(5))
.in
You can load a dynamically loadable password hash module by

View file

@ -44,6 +44,8 @@
static char *modulepath = NULL;
static char *moduleload = NULL;
static int moduleargc = 0;
static char **moduleargv = NULL;
static void
usage(const char *s)
@ -82,7 +84,17 @@ parse_slappasswdopt( void )
modulepath = p;
} else if ( strncasecmp( optarg, "module-load", len ) == 0 ) {
moduleload = p;
ConfigArgs c = { .line = p };
if ( config_fp_parse_line( &c ) ) {
return -1;
}
moduleload = c.argv[0];
moduleargc = c.argc - 1;
if ( moduleargc ) {
moduleargv = c.argv+1;
}
} else {
return -1;
@ -223,7 +235,7 @@ slappasswd( int argc, char *argv[] )
goto destroy;
}
if ( moduleload && module_load(moduleload, 0, NULL) ) {
if ( moduleload && module_load(moduleload, moduleargc, moduleargv) ) {
rc = EXIT_FAILURE;
goto destroy;
}