[dovecot-cvs] dovecot/src/auth auth-request.c, 1.58.2.20, 1.58.2.21 auth-request.h, 1.27.2.3, 1.27.2.4

tss at dovecot.org tss at dovecot.org
Thu Feb 15 10:46:59 UTC 2007


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

Modified Files:
      Tag: branch_1_0
	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.58.2.20
retrieving revision 1.58.2.21
diff -u -d -r1.58.2.20 -r1.58.2.21
--- auth-request.c	24 Jan 2007 16:37:41 -0000	1.58.2.20
+++ auth-request.c	15 Feb 2007 10:46:56 -0000	1.58.2.21
@@ -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);
@@ -909,28 +913,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;
@@ -941,11 +933,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.27.2.3
retrieving revision 1.27.2.4
diff -u -d -r1.27.2.3 -r1.27.2.4
--- auth-request.h	16 Jan 2007 13:23:26 -0000	1.27.2.3
+++ auth-request.h	15 Feb 2007 10:46:57 -0000	1.27.2.4
@@ -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