diff src/auth/passdb-blocking.c @ 3183:16ea551957ed HEAD

Replaced userdb/passdb settings with blocks so it's possible to give multiple ones. Plaintext password mechanisms now support handling multiple passdbs, but others don't yet. Also fixed a few memory leaks.
author Timo Sirainen <tss@iki.fi>
date Mon, 07 Mar 2005 20:55:13 +0200
parents 8a3b57385eca
children 92c16e82b806
line wrap: on
line diff
--- a/src/auth/passdb-blocking.c	Mon Mar 07 11:42:54 2005 +0200
+++ b/src/auth/passdb-blocking.c	Mon Mar 07 20:55:13 2005 +0200
@@ -12,19 +12,35 @@
 static enum passdb_result
 check_failure(struct auth_request *request, const char **reply)
 {
+	enum passdb_result ret;
+	const char *p;
+
 	/* OK / FAIL */
 	if (strncmp(*reply, "OK\t", 3) == 0) {
 		*reply += 3;
 		return PASSDB_RESULT_OK;
 	}
 
-	/* FAIL \t result */
-	if (strncmp(*reply, "FAIL\t", 5) != 0) {
+	/* FAIL \t result \t password */
+	if (strncmp(*reply, "FAIL\t", 5) == 0) {
+		*reply += 5;
+		ret = atoi(t_strcut(*reply, '\t'));
+
+		p = strchr(*reply, '\t');
+		if (p == NULL)
+			*reply += strlen(*reply);
+		else
+			*reply = p + 1;
+		if (ret != PASSDB_RESULT_OK)
+			return ret;
+
+		auth_request_log_error(request, "blocking",
+			"Received invalid FAIL result from worker: %d", ret);
+		return PASSDB_RESULT_INTERNAL_FAILURE;
+	} else {
 		auth_request_log_error(request, "blocking",
 			"Received unknown reply from worker: %s", *reply);
 		return PASSDB_RESULT_INTERNAL_FAILURE;
-	} else {
-		return atoi(*reply + 5);
 	}
 }
 
@@ -90,7 +106,7 @@
 	i_assert(request->extra_fields == NULL);
 
 	str = t_str_new(64);
-	str_append(str, "PASSV\t");
+	str_printfa(str, "PASSV\t%u\t", request->passdb->num);
 	str_append(str, request->mech_password);
 	str_append_c(str, '\t');
 	auth_request_export(request, str);
@@ -123,7 +139,8 @@
 	i_assert(request->extra_fields == NULL);
 
 	str = t_str_new(64);
-	str_printfa(str, "PASSL\t%d\t", request->credentials);
+	str_printfa(str, "PASSL\t%u\t%d\t",
+		    request->passdb->num, request->credentials);
 	auth_request_export(request, str);
 
 	auth_worker_call(request, str_c(str), lookup_credentials_callback);