]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Fixed userdb changing username via auth-worker
authorTimo Sirainen <tss@iki.fi>
Fri, 23 Oct 2015 12:21:15 +0000 (15:21 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 23 Oct 2015 12:21:15 +0000 (15:21 +0300)
src/auth/auth-worker-client.c
src/auth/userdb-blocking.c

index db4ca528410d6c569574f830520758ddd607c078..bffe1c77a8f49f1dfe7852e9c3849db67d28ede7 100644 (file)
@@ -373,6 +373,8 @@ lookup_user_callback(enum userdb_result result,
                break;
        case USERDB_RESULT_OK:
                str_append(str, "OK\t");
+               str_append_tabescaped(str, auth_request->user);
+               str_append_c(str, '\t');
                auth_fields_append(auth_request->userdb_reply, str, 0, 0);
                if (auth_request->userdb_lookup_tempfailed)
                        str_append(str, "\ttempfail");
index ebb8f27bbfd546484badb73b23785c11d9bace5f..71592c39bc0ce437402e3bd6486bbd1cda919ed2 100644 (file)
@@ -18,7 +18,7 @@ static bool user_callback(const char *reply, void *context)
 {
        struct auth_request *request = context;
        enum userdb_result result;
-       const char *args;
+       const char *username, *args;
 
        if (strncmp(reply, "FAIL\t", 5) == 0) {
                result = USERDB_RESULT_INTERNAL_FAILURE;
@@ -28,7 +28,14 @@ static bool user_callback(const char *reply, void *context)
                args = reply + 9;
        } else if (strncmp(reply, "OK\t", 3) == 0) {
                result = USERDB_RESULT_OK;
-               args = reply + 3;
+               username = reply + 3;
+               args = strchr(username, '\t');
+               if (args == NULL)
+                       args = "";
+               else
+                       username = t_strdup_until(username, args++);
+               if (strcmp(request->user, username) != 0)
+                       request->user = p_strdup(request->pool, username);
        } else {
                result = USERDB_RESULT_INTERNAL_FAILURE;
                i_error("BUG: auth-worker sent invalid user reply");