changeset 19607:de55cde023c4

doveadm: Add plugins support for doveadm pw This simply tries to load all the auth plugins. The ones that aren't password scheme plugins will most likely just fail. Hopefully this will work fine so we don't need to require any specific naming rules for the plugins. Signed-off-by: Alin Dobre <alin@dovecot.fi>
author Alin Dobre <alin@dovecot.fi>
date Fri, 22 Jan 2016 15:15:03 +0000
parents 487036a4b545
children 01e33753b08e
files src/doveadm/Makefile.am src/doveadm/doveadm-pw.c
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/Makefile.am	Fri Jan 22 17:14:37 2016 +0200
+++ b/src/doveadm/Makefile.am	Fri Jan 22 15:15:03 2016 +0000
@@ -21,6 +21,7 @@
 	-I$(top_srcdir)/src/lib-storage \
 	-I$(top_srcdir)/src/auth \
 	-DMODULEDIR=\""$(moduledir)"\" \
+	-DAUTH_MODULE_DIR=\""$(moduledir)/auth"\" \
 	-DDOVEADM_MODULEDIR=\""$(doveadm_moduledir)"\" \
 	-DPKG_RUNDIR=\""$(rundir)"\" \
 	-DPKG_STATEDIR=\""$(statedir)"\" \
--- a/src/doveadm/doveadm-pw.c	Fri Jan 22 17:14:37 2016 +0200
+++ b/src/doveadm/doveadm-pw.c	Fri Jan 22 15:15:03 2016 +0000
@@ -6,6 +6,7 @@
 #include "randgen.h"
 #include "doveadm.h"
 #include "askpass.h"
+#include "module-dir.h"
 
 #include <ctype.h>
 #include <fcntl.h>
@@ -14,6 +15,8 @@
 
 #define DEFAULT_SCHEME "CRAM-MD5"
 
+static struct module *modules = NULL;
+
 static void cmd_pw(int argc, char *argv[])
 {
 	const char *hash = NULL;
@@ -24,10 +27,19 @@
 	bool list_schemes = FALSE, reverse_verify = FALSE;
 	unsigned int rounds = 0;
 	int c;
+	struct module_dir_load_settings mod_set;
 
 	random_init();
 	password_schemes_init();
-	
+
+	memset(&mod_set, 0, sizeof(mod_set));
+	mod_set.abi_version = DOVECOT_ABI_VERSION;
+	mod_set.require_init_funcs = TRUE;
+	mod_set.ignore_dlopen_errors = TRUE;
+
+	modules = module_dir_load_missing(modules, AUTH_MODULE_DIR, NULL, &mod_set);
+	module_dir_init(modules);
+
 	while ((c = getopt(argc, argv, "lp:r:s:t:u:V")) > 0) {
 		switch (c) {
 		case 'l':
@@ -122,6 +134,7 @@
 		printf("{%s}%s\n", scheme, hash);
 	}
 
+	module_dir_unload(&modules);
 	password_schemes_deinit();
 	random_deinit();
 }