[dovecot-cvs] dovecot/src/auth auth-cache.c, 1.22, 1.23 auth-cache.h, 1.8, 1.9 auth-request.c, 1.83, 1.84

tss at dovecot.org tss at dovecot.org
Thu Feb 15 11:06:39 UTC 2007


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

Modified Files:
	auth-cache.c auth-cache.h auth-request.c 
Log Message:
If user is changed with "user=x" in extra_fields, cache the entry with the
original username instead of with the changed username.



Index: auth-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-cache.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- auth-cache.c	21 Dec 2006 16:01:15 -0000	1.22
+++ auth-cache.c	15 Feb 2007 11:06:35 -0000	1.23
@@ -188,13 +188,20 @@
 	return node->data + strlen(node->data) + 1;
 }
 
-void auth_cache_insert(struct auth_cache *cache,
-		       const struct auth_request *request,
+void auth_cache_insert(struct auth_cache *cache, struct auth_request *request,
 		       const char *key, const char *value, bool last_success)
 {
 	string_t *str;
         struct auth_cache_node *node;
 	size_t data_size, alloc_size, value_len = strlen(value);
+	char *current_username;
+
+	/* store into cache using the original username, except if we're doing
+	   a master user login */
+	current_username = request->user;
+	if (request->original_username != NULL &&
+	    request->requested_login_user == NULL)
+		request->user = t_strdup_noconst(request->original_username);
 
 	/* %! is prepended automatically. it contains the db ID number. */
 	str = t_str_new(256);
@@ -203,6 +210,8 @@
 		   auth_request_get_var_expand_table(request,
 						     auth_request_str_escape));
 
+	request->user = current_username;
+
 	data_size = str_len(str) + 1 + value_len + 1;
 	alloc_size = sizeof(struct auth_cache_node) -
 		sizeof(node->data) + data_size;

Index: auth-cache.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-cache.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- auth-cache.h	8 Nov 2006 19:13:32 -0000	1.8
+++ auth-cache.h	15 Feb 2007 11:06:36 -0000	1.9
@@ -37,8 +37,7 @@
 		  const char *key, struct auth_cache_node **node_r,
 		  bool *expired_r);
 /* Insert key => value into cache. */
-void auth_cache_insert(struct auth_cache *cache,
-		       const struct auth_request *request,
+void auth_cache_insert(struct auth_cache *cache, struct auth_request *request,
 		       const char *key, const char *value, bool last_success);
 
 /* Remove key from cache */

Index: auth-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- auth-request.c	15 Feb 2007 10:48:08 -0000	1.83
+++ auth-request.c	15 Feb 2007 11:06:36 -0000	1.84
@@ -933,6 +933,12 @@
 	if (strcmp(name, "user") == 0) {
 		/* update username to be exactly as it's in database */
 		if (strcmp(request->user, value) != 0) {
+			/* remember the original username for cache */
+			if (request->original_username == NULL) {
+				request->original_username =
+					p_strdup(request->pool, request->user);
+			}
+
 			auth_request_log_debug(request, "auth",
 				"username changed %s -> %s",
 				request->user, value);



More information about the dovecot-cvs mailing list