From 8b353df0e2ba15be6fb78e886e0d6f343b329de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Fri, 9 Apr 2021 10:38:42 +0100 Subject: [PATCH] ITS#9517 Add module args support to slappaswd and relevant docs --- doc/man/man5/slapd-config.5 | 5 +++-- doc/man/man5/slapd.conf.5 | 5 +++-- doc/man/man5/slappw-argon2.5 | 8 ++++++++ doc/man/man8/slappasswd.8 | 2 +- servers/slapd/slappasswd.c | 16 ++++++++++++++-- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/doc/man/man5/slapd-config.5 b/doc/man/man5/slapd-config.5 index 1b28dc405d..a559b0c1cd 100644 --- a/doc/man/man5/slapd-config.5 +++ b/doc/man/man5/slapd-config.5 @@ -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: -Specify the name of a dynamically loadable module to load. The filename +.B olcModuleLoad: [...] +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 diff --git a/doc/man/man5/slapd.conf.5 b/doc/man/man5/slapd.conf.5 index 11190261bd..b6e9250026 100644 --- a/doc/man/man5/slapd.conf.5 +++ b/doc/man/man5/slapd.conf.5 @@ -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 -Specify the name of a dynamically loadable module to load. The filename +.B moduleload [...] +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 diff --git a/doc/man/man5/slappw-argon2.5 b/doc/man/man5/slappw-argon2.5 index 8ec53b2ace..f5907b673a 100644 --- a/doc/man/man5/slappw-argon2.5 +++ b/doc/man/man5/slappw-argon2.5 @@ -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 [ ...]" +.LP +.RE Depending on .BR argon2 's location, you may also need: diff --git a/doc/man/man8/slappasswd.8 b/doc/man/man8/slappasswd.8 index 3d2165d36d..50cacd8fe8 100644 --- a/doc/man/man8/slappasswd.8 +++ b/doc/man/man8/slappasswd.8 @@ -165,7 +165,7 @@ Possible generic options/values are: .LP .nf module\-path= (see `\fBmodulepath\fP' in slapd.conf(5)) - module\-load= (see `\fBmoduleload\fP' in slapd.conf(5)) + module\-load=" [...]" (see `\fBmoduleload\fP' in slapd.conf(5)) .in You can load a dynamically loadable password hash module by diff --git a/servers/slapd/slappasswd.c b/servers/slapd/slappasswd.c index 2028db4fa1..99105ba582 100644 --- a/servers/slapd/slappasswd.c +++ b/servers/slapd/slappasswd.c @@ -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; }