dovecot-2.2: auth: When auto-loading auth mechanisms from plugin...

dovecot at dovecot.org dovecot at dovecot.org
Tue Dec 18 18:57:13 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/4eebc8959849
changeset: 15489:4eebc8959849
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Dec 18 18:56:59 2012 +0200
description:
auth: When auto-loading auth mechanisms from plugins, generate the name better.

diffstat:

 src/auth/mech.c |  17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diffs (41 lines):

diff -r 57d552496340 -r 4eebc8959849 src/auth/mech.c
--- a/src/auth/mech.c	Tue Dec 18 18:55:00 2012 +0200
+++ b/src/auth/mech.c	Tue Dec 18 18:56:59 2012 +0200
@@ -7,6 +7,7 @@
 #include "passdb.h"
 
 #include <stdlib.h>
+#include <ctype.h>
 
 static struct mech_module_list *mech_modules;
 
@@ -112,6 +113,20 @@
 	reg->modules = list;
 }
 
+static const char *mech_get_plugin_name(const char *name)
+{
+	string_t *str = t_str_new(32);
+
+	str_append(str, "mech_");
+	for (; *name != '\0'; name++) {
+		if (*name == '-')
+			str_append_c(str, '_');
+		else
+			str_append_c(str, i_tolower(*name));
+	}
+	return str_c(str);
+}
+
 struct mechanisms_register *
 mech_register_init(const struct auth_settings *set)
 {
@@ -139,7 +154,7 @@
 		mech = mech_module_find(name);
 		if (mech == NULL) {
 			/* maybe it's a plugin. try to load it. */
-			auth_module_load(t_strconcat("mech_", name, NULL));
+			auth_module_load(mech_get_plugin_name(name));
 			mech = mech_module_find(name);
 		}
 		if (mech == NULL)


More information about the dovecot-cvs mailing list