Skip to content

Commit

Permalink
doveadm: Add plugins support for doveadm pw
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
alindobre authored and sirainen committed Jan 22, 2016
1 parent 34a41fd commit 127d071
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/doveadm/Makefile.am
Expand Up @@ -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)"\" \
Expand Down
15 changes: 14 additions & 1 deletion src/doveadm/doveadm-pw.c
Expand Up @@ -6,6 +6,7 @@
#include "randgen.h"
#include "doveadm.h"
#include "askpass.h"
#include "module-dir.h"

#include <ctype.h>
#include <fcntl.h>
Expand All @@ -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;
Expand All @@ -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':
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 127d071

Please sign in to comment.