[dovecot-cvs] dovecot/src/auth auth-request.c, 1.81, 1.82 auth-request.h, 1.31, 1.32

tss at dovecot.org tss at dovecot.org
Thu Feb 15 10:47:03 UTC 2007


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

Modified Files:
	auth-request.c auth-request.h 
Log Message:
Special extra_fields weren't saved to auth cache. This was especially
problematic for allow_nets which was ignored if the user was already in
cache.



Index: auth-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- auth-request.c	24 Jan 2007 16:37:43 -0000	1.81
+++ auth-request.c	15 Feb 2007 10:47:00 -0000	1.82
@@ -252,13 +252,17 @@
 		str_append(str, request->passdb_password);
 	}
 
-	if (extra_fields != NULL) {
+	if (extra_fields != NULL && *extra_fields != '\0') {
 		str_append_c(str, '\t');
 		str_append(str, extra_fields);
 	}
-	if (request->no_failure_delay) {
-		str_append_c(str, '\t');
-		str_append(str, "nodelay");
+	if (request->extra_cache_fields != NULL) {
+		extra_fields =
+			auth_stream_reply_export(request->extra_cache_fields);
+		if (*extra_fields != '\0') {
+			str_append_c(str, '\t');
+			str_append(str, extra_fields);
+		}
 	}
 	auth_cache_insert(passdb_cache, request, passdb->cache_key, str_c(str),
 			  result == PASSDB_RESULT_OK);
@@ -937,28 +941,16 @@
 				request->user, value);
 			request->user = p_strdup(request->pool, value);
 		}
-		return;
-	}
-
-	if (strcmp(name, "nodelay") == 0) {
+	} else if (strcmp(name, "nodelay") == 0) {
 		/* don't delay replying to client of the failure */
 		request->no_failure_delay = TRUE;
-		return;
-	}
-
-	if (strcmp(name, "nopassword") == 0) {
+	} else if (strcmp(name, "nopassword") == 0) {
 		/* NULL password - anything goes */
 		i_assert(request->passdb_password == NULL);
 		request->no_password = TRUE;
-		return;
-	}
-
-	if (strcmp(name, "allow_nets") == 0) {
+	} else if (strcmp(name, "allow_nets") == 0) {
 		auth_request_validate_networks(request, value);
-		return;
-	}
-
-	if (strcmp(name, "nologin") == 0) {
+	} else if (strcmp(name, "nologin") == 0) {
 		/* user can't actually login - don't keep this
 		   reply for master */
 		request->no_login = TRUE;
@@ -969,11 +961,22 @@
 		request->proxy = TRUE;
 		request->no_login = TRUE;
 		value = NULL;
+	} else {
+		if (request->extra_fields == NULL)
+			request->extra_fields = auth_stream_reply_init(request);
+		auth_stream_reply_add(request->extra_fields, name, value);
+		return;
 	}
 
-	if (request->extra_fields == NULL)
-		request->extra_fields = auth_stream_reply_init(request);
-	auth_stream_reply_add(request->extra_fields, name, value);
+	if (passdb_cache != NULL &&
+	    request->passdb->passdb->cache_key != NULL) {
+		/* we'll need to get this field stored into cache */
+		if (request->extra_cache_fields == NULL) {
+			request->extra_cache_fields =
+				auth_stream_reply_init(request);
+		}
+		auth_stream_reply_add(request->extra_cache_fields, name, value);
+	}
 }
 
 int auth_request_password_verify(struct auth_request *request,

Index: auth-request.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- auth-request.h	21 Dec 2006 16:01:15 -0000	1.31
+++ auth-request.h	15 Feb 2007 10:47:01 -0000	1.32
@@ -42,6 +42,9 @@
            with "userdb_" are skipped. If prefetch userdb is used, it uses
            the "userdb_" prefixed fields. */
         struct auth_stream_reply *extra_fields;
+	/* extra_fields that aren't supposed to be sent to the client, but
+	   are supposed to be stored to auth cache. */
+	struct auth_stream_reply *extra_cache_fields;
 
 	struct mech_module *mech;
 	struct auth *auth;



More information about the dovecot-cvs mailing list