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");
{
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;
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");