[dovecot-cvs] dovecot/src/auth passdb-passwd-file.c,1.28,1.29

cras at dovecot.org cras at dovecot.org
Sat Jun 24 22:02:44 EEST 2006


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv12454

Modified Files:
	passdb-passwd-file.c 
Log Message:
When using non-plaintext authentication with passdb passwd-file we didn't   
support extra_fields and we crashed if password scheme wasn't explicitly
specified in the passwd-file.



Index: passdb-passwd-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-passwd-file.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- passdb-passwd-file.c	20 Feb 2006 16:31:46 -0000	1.28
+++ passdb-passwd-file.c	24 Jun 2006 19:02:40 -0000	1.29
@@ -20,34 +20,25 @@
 	struct db_passwd_file *pwf;
 };
 
-static void
-passwd_file_verify_plain(struct auth_request *request, const char *password,
-			 verify_plain_callback_t *callback)
+static void passwd_file_save_results(struct auth_request *request,
+				     const struct passwd_user *pu,
+				     const char **crypted_pass_r,
+				     const char **scheme_r)
 {
-	struct passdb_module *_module = request->passdb->passdb;
-	struct passwd_file_passdb_module *module =
-		(struct passwd_file_passdb_module *)_module;
-	struct passwd_user *pu;
         const struct var_expand_table *table;
-	const char *scheme, *crypted_pass, *key, *value;
+	const char *key, *value;
 	string_t *str;
 	char **p;
-        int ret;
 
-	pu = db_passwd_file_lookup(module->pwf, request);
-	if (pu == NULL) {
-		callback(PASSDB_RESULT_USER_UNKNOWN, request);
-		return;
-	}
-
-	crypted_pass = pu->password;
-	scheme = password_get_scheme(&crypted_pass);
-	if (scheme == NULL) scheme = _module->default_pass_scheme;
+	*crypted_pass_r = pu->password;
+	*scheme_r = password_get_scheme(crypted_pass_r);
+	if (*scheme_r == NULL)
+		*scheme_r = request->passdb->passdb->default_pass_scheme;
 
 	/* save the password so cache can use it */
-	if (crypted_pass != NULL) {
+	if (*crypted_pass_r != NULL) {
 		auth_request_set_field(request, "password",
-				       crypted_pass, scheme);
+				       *crypted_pass_r, *scheme_r);
         }
 
 	if (pu->extra_fields != NULL) {
@@ -70,6 +61,26 @@
 		}
 		t_pop();
 	}
+}
+
+static void
+passwd_file_verify_plain(struct auth_request *request, const char *password,
+			 verify_plain_callback_t *callback)
+{
+	struct passdb_module *_module = request->passdb->passdb;
+	struct passwd_file_passdb_module *module =
+		(struct passwd_file_passdb_module *)_module;
+	struct passwd_user *pu;
+	const char *scheme, *crypted_pass;
+        int ret;
+
+	pu = db_passwd_file_lookup(module->pwf, request);
+	if (pu == NULL) {
+		callback(PASSDB_RESULT_USER_UNKNOWN, request);
+		return;
+	}
+
+	passwd_file_save_results(request, pu, &crypted_pass, &scheme);
 
 	ret = auth_request_password_verify(request, password, crypted_pass,
 					   scheme, "passwd-file");
@@ -94,8 +105,7 @@
 		return;
 	}
 
-	crypted_pass = pu->password;
-	scheme = password_get_scheme(&crypted_pass);
+	passwd_file_save_results(request, pu, &crypted_pass, &scheme);
 
 	passdb_handle_credentials(PASSDB_RESULT_OK, crypted_pass, scheme,
 				  callback, request);



More information about the dovecot-cvs mailing list