From 127d0716d4aa14890e0462ff84020b5655812981 Mon Sep 17 00:00:00 2001 From: Alin Dobre Date: Fri, 22 Jan 2016 15:15:03 +0000 Subject: [PATCH] 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 --- src/doveadm/Makefile.am | 1 + src/doveadm/doveadm-pw.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/doveadm/Makefile.am b/src/doveadm/Makefile.am index ab51e0f8e4..0e0b2307d9 100644 --- a/src/doveadm/Makefile.am +++ b/src/doveadm/Makefile.am @@ -21,6 +21,7 @@ AM_CPPFLAGS = \ -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)"\" \ diff --git a/src/doveadm/doveadm-pw.c b/src/doveadm/doveadm-pw.c index f1bc573311..1723bdcc63 100644 --- a/src/doveadm/doveadm-pw.c +++ b/src/doveadm/doveadm-pw.c @@ -6,6 +6,7 @@ #include "randgen.h" #include "doveadm.h" #include "askpass.h" +#include "module-dir.h" #include #include @@ -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 @@ static void cmd_pw(int argc, char *argv[]) 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 @@ static void cmd_pw(int argc, char *argv[]) printf("{%s}%s\n", scheme, hash); } + module_dir_unload(&modules); password_schemes_deinit(); random_deinit(); }