[dovecot-cvs] dovecot/src/auth auth-request.c, 1.16, 1.17 auth-worker-client.c, 1.7, 1.8 passdb-blocking.c, 1.3, 1.4 passdb-bsdauth.c, 1.8, 1.9 passdb-passwd-file.c, 1.16, 1.17 passdb-passwd.c, 1.11, 1.12 passdb-shadow.c, 1.12, 1.13 passdb-vpopmail.c, 1.16, 1.17

cras at dovecot.org cras at dovecot.org
Sun Apr 3 01:00:52 EEST 2005


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

Modified Files:
	auth-request.c auth-worker-client.c passdb-blocking.c 
	passdb-bsdauth.c passdb-passwd-file.c passdb-passwd.c 
	passdb-shadow.c passdb-vpopmail.c 
Log Message:
passdb can now change the username that was used to log in. This is mostly
useful to support case-insensitive username lookups.



Index: auth-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- auth-request.c	12 Mar 2005 18:20:09 -0000	1.16
+++ auth-request.c	2 Apr 2005 22:00:49 -0000	1.17
@@ -420,6 +420,12 @@
 		return;
 	}
 
+	if (strcmp(name, "user") == 0) {
+		/* update username to be exactly as it's in database */
+		request->user = p_strdup(request->pool, value);
+		return;
+	}
+
 	if (strcmp(name, "nodelay") == 0) {
 		/* don't delay replying to client of the failure */
 		request->no_failure_delay = TRUE;

Index: auth-worker-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-worker-client.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- auth-worker-client.c	2 Apr 2005 21:20:38 -0000	1.7
+++ auth-worker-client.c	2 Apr 2005 22:00:49 -0000	1.8
@@ -90,6 +90,8 @@
 		str_printfa(str, "FAIL\t%d", result);
 	else {
 		str_append(str, "OK\t");
+		str_append(str, request->user);
+		str_append_c(str, '\t');
 		if (request->passdb_password != NULL)
 			str_append(str, request->passdb_password);
 		str_append_c(str, '\t');
@@ -153,7 +155,7 @@
 	if (result != PASSDB_RESULT_OK)
 		str_printfa(str, "FAIL\t%d", result);
 	else {
-		str_printfa(str, "OK\t{%s}%s\t",
+		str_printfa(str, "OK\t%s\t{%s}%s\t", request->user,
 			    passdb_credentials_to_str(request->credentials),
 			    credentials);
 		if (request->extra_fields != NULL)

Index: passdb-blocking.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-blocking.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- passdb-blocking.c	7 Mar 2005 18:55:13 -0000	1.3
+++ passdb-blocking.c	2 Apr 2005 22:00:49 -0000	1.4
@@ -47,17 +47,22 @@
 static int get_pass_reply(struct auth_request *request, const char *reply,
 			  const char **password_r, const char **scheme_r)
 {
-	const char *p;
+	const char *p, *p2;
 
+	/* user \t {scheme}password [\t extra] */
 	p = strchr(reply, '\t');
-	if (p == NULL) {
+	p2 = p == NULL ? NULL : strchr(p + 1, '\t');
+	if (p2 == NULL) {
 		*password_r = NULL;
 		*scheme_r = NULL;
 		return 0;
 	}
 
-	*password_r = t_strdup_until(reply, p);
-	reply = p + 1;
+	/* username may have changed, update it */
+	request->user = p_strdup_until(request->pool, reply, p);
+
+	*password_r = t_strdup_until(p + 1, p2);
+	reply = p2 + 1;
 
 	if (**password_r == '\0') {
 		*password_r = NULL;

Index: passdb-bsdauth.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-bsdauth.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- passdb-bsdauth.c	28 Feb 2005 22:19:21 -0000	1.8
+++ passdb-bsdauth.c	2 Apr 2005 22:00:49 -0000	1.9
@@ -48,6 +48,9 @@
 		return;
 	}
 
+	/* make sure we're using the username exactly as it's in the database */
+	request->user = p_strdup(request->pool, pw->pw_name);
+
 	callback(PASSDB_RESULT_OK, request);
 }
 

Index: passdb-passwd-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-passwd-file.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- passdb-passwd-file.c	28 Feb 2005 22:19:21 -0000	1.16
+++ passdb-passwd-file.c	2 Apr 2005 22:00:49 -0000	1.17
@@ -26,6 +26,10 @@
 		return;
 	}
 
+	/* we use case-sensitive lookups. otherwise we'd have to update
+	   request->user to pu->user */
+	i_assert(strcmp(request->user, pu->user_realm) == 0);
+
 	crypted_pass = pu->password;
 	scheme = password_get_scheme(&crypted_pass);
 	if (scheme == NULL) scheme = "CRYPT";

Index: passdb-passwd.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-passwd.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- passdb-passwd.c	28 Feb 2005 22:19:21 -0000	1.11
+++ passdb-passwd.c	2 Apr 2005 22:00:49 -0000	1.12
@@ -45,6 +45,9 @@
 		return;
 	}
 
+	/* make sure we're using the username exactly as it's in the database */
+	request->user = p_strdup(request->pool, pw->pw_name);
+
 	callback(PASSDB_RESULT_OK, request);
 }
 

Index: passdb-shadow.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-shadow.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- passdb-shadow.c	28 Feb 2005 22:19:21 -0000	1.12
+++ passdb-shadow.c	2 Apr 2005 22:00:49 -0000	1.13
@@ -45,6 +45,9 @@
 		return;
 	}
 
+	/* make sure we're using the username exactly as it's in the database */
+	request->user = p_strdup(request->pool, spw->sp_namp);
+
 	callback(PASSDB_RESULT_OK, request);
 }
 

Index: passdb-vpopmail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-vpopmail.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- passdb-vpopmail.c	28 Feb 2005 22:19:21 -0000	1.16
+++ passdb-vpopmail.c	2 Apr 2005 22:00:49 -0000	1.17
@@ -88,6 +88,9 @@
 	}
 #endif
 
+	/* make sure we're using the username exactly as it's in the database */
+	request->user = p_strdup(request->pool, vpw->pw_name);
+
 	callback(PASSDB_RESULT_OK, request);
 }
 



More information about the dovecot-cvs mailing list