dovecot-2.0: auth: Added lookup_credentials() support for passdb...

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 6 00:55:40 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/e92d2aaab3e4
changeset: 12245:e92d2aaab3e4
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Oct 05 22:55:37 2010 +0100
description:
auth: Added lookup_credentials() support for passdb static

diffstat:

 src/auth/passdb-static.c |  32 ++++++++++++++++++++++++++------
 1 files changed, 26 insertions(+), 6 deletions(-)

diffs (78 lines):

diff -r 73c6b077bcba -r e92d2aaab3e4 src/auth/passdb-static.c
--- a/src/auth/passdb-static.c	Tue Oct 05 22:53:58 2010 +0100
+++ b/src/auth/passdb-static.c	Tue Oct 05 22:55:37 2010 +0100
@@ -14,21 +14,20 @@
 };
 
 static void
-static_verify_plain(struct auth_request *request, const char *password,
-		    verify_plain_callback_t *callback)
+static_save_fields(struct auth_request *request, const char **password_r)
 {
 	struct static_passdb_module *module =
 		(struct static_passdb_module *)request->passdb->passdb;
         const struct var_expand_table *table;
-	const char *const *args, *static_password = "";
+	const char *const *args;
 	unsigned int i, count;
 	string_t *str = t_str_new(128);
-	int ret;
 
 	auth_request_log_debug(request, "static", "lookup");
 
 	table = auth_request_get_var_expand_table(request, NULL);
 
+	*password_r = "";
 	args = array_get(&module->tmpl, &count);
 	i_assert((count % 2) == 0);
 	for (i = 0; i < count; i += 2) {
@@ -42,12 +41,22 @@
 		}
 
 		if (strcmp(key, "password") == 0)
-			static_password = value;
+			*password_r = value;
 		else {
 			auth_request_set_field(request, key, value,
 					       STATIC_PASS_SCHEME);
 		}
 	}
+}
+
+static void
+static_verify_plain(struct auth_request *request, const char *password,
+		    verify_plain_callback_t *callback)
+{
+	const char *static_password;
+	int ret;
+
+	static_save_fields(request, &static_password);
 
 	ret = auth_request_password_verify(request, password, static_password,
 					   STATIC_PASS_SCHEME, "static");
@@ -59,6 +68,17 @@
 	callback(PASSDB_RESULT_OK, request);
 }
 
+static void
+static_lookup_credentials(struct auth_request *request,
+			  lookup_credentials_callback_t *callback)
+{
+	const char *static_password;
+
+	static_save_fields(request, &static_password);
+	passdb_handle_credentials(PASSDB_RESULT_OK, static_password,
+				  STATIC_PASS_SCHEME, callback, request);
+}
+
 static struct passdb_module *
 static_preinit(pool_t pool, const char *args)
 {
@@ -96,6 +116,6 @@
 	NULL,
 
 	static_verify_plain,
-	NULL,
+	static_lookup_credentials,
 	NULL
 };


More information about the dovecot-cvs mailing list