changeset 4692:7728291a7f52 HEAD

If blocking passdb (ie. MySQL) didn't return any extra fields, we didn't notice username changes and we didn't cache the password.
author Timo Sirainen <tss@iki.fi>
date Sun, 15 Oct 2006 23:55:12 +0300
parents a6abe149c2a4
children c28892e80d6c
files src/auth/passdb-blocking.c
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/passdb-blocking.c	Sun Oct 15 23:30:06 2006 +0300
+++ b/src/auth/passdb-blocking.c	Sun Oct 15 23:55:12 2006 +0300
@@ -51,18 +51,24 @@
 
 	/* user \t {scheme}password [\t extra] */
 	p = strchr(reply, '\t');
-	p2 = p == NULL ? NULL : strchr(p + 1, '\t');
-	if (p2 == NULL) {
+
+	/* username may have changed, update it */
+	auth_request_set_field(request, "user", p == NULL ? reply :
+			       t_strdup_until(reply, p), NULL);
+	if (p == NULL) {
+		/* we didn't get a password. */
 		*password_r = NULL;
 		*scheme_r = NULL;
 		return 0;
 	}
-
-	/* username may have changed, update it */
-        auth_request_set_field(request, "user", t_strdup_until(reply, p), NULL);
-
-	*password_r = t_strdup_until(p + 1, p2);
-	reply = p2 + 1;
+	p2 = strchr(++p, '\t');
+	if (p2 == NULL) {
+		*password_r = p;
+		reply = "";
+	} else {
+		*password_r = t_strdup_until(p, p2);
+		reply = p2 + 1;
+	}
 
 	if (**password_r == '\0') {
 		*password_r = NULL;