if (client->userdb_fields != NULL) {
string_t *userdb_fields = t_str_new(256);
unsigned int i;
+ bool have_auth_token_session_pid = FALSE;
for (i = 0; client->userdb_fields[i] != NULL; i++) {
if (i > 0)
str_append_c(userdb_fields, '\t');
+ if (str_begins_with(client->userdb_fields[i],
+ "auth_token_session_pid="))
+ have_auth_token_session_pid = TRUE;
str_append_tabescaped(userdb_fields, client->userdb_fields[i]);
}
+ if (!have_auth_token_session_pid) {
+ if (i > 0)
+ str_append_c(userdb_fields, '\t');
+ /* This is picked up by mail-storage-service when
+ unhibernating. */
+ str_printfa(userdb_fields, "auth_token_session_pid=%s",
+ dec2str(client->user->auth_token_session_pid));
+ }
str_append(cmd, "\tuserdb_fields=");
str_append_tabescaped(cmd, str_c(userdb_fields));
}
}
str_append(cmd, "\tauth_token=");
str_append_tabescaped(cmd, user->auth_token);
- str_printfa(cmd, "\tsession_pid=%s", my_pid);
+ str_printfa(cmd, "\tsession_pid=%s",
+ dec2str(user->auth_token_session_pid));
str_append(cmd, "\tstats=");
str_append_tabescaped(cmd, client_stats(client));
if (client->command_queue != NULL &&
"(session_pid=%s auth_token=%s)",
client->mailbox == NULL ? "<none>" :
mailbox_get_vname(client->mailbox),
- my_pid, client->user->auth_token);
+ dec2str(client->user->auth_token_session_pid),
+ client->user->auth_token);
client->disconnected = TRUE;
client->hibernated = TRUE;
client_destroy(client, NULL);
#endif
} else if (strcmp(key, "auth_mech") == 0) {
user->auth_mech = p_strdup(user->pool, value);
+ } else if (strcmp(key, "auth_token_session_pid") == 0) {
+ if (str_to_pid(value, &user->auth_token_session_pid) < 0 ||
+ user->auth_token_session_pid == 0) {
+ e_error(user->event,
+ "userdb returned invalid auth_token_session_pid value %s",
+ value);
+ }
} else if (strcmp(key, "auth_token") == 0) {
user->auth_token = p_strdup(user->pool, value);
} else if (strcmp(key, "auth_user") == 0) {
set_keyvalue(user, key, value);
}
}
+ if (user->auth_token != NULL && user->auth_token_session_pid == 0)
+ user->auth_token_session_pid = getpid();
return 0;
}
mail_user->service;
mail_user->auth_mech = p_strdup(mail_user->pool, user->auth_mech);
mail_user->auth_token = p_strdup(mail_user->pool, user->auth_token);
+ mail_user->auth_token_session_pid = user->auth_token_session_pid;
mail_user->auth_user = p_strdup(mail_user->pool, user->auth_user);
if (user->input.session_create_time != 0) {
mail_user->session_create_time =
user2->protocol = p_strdup(user2->pool, user->protocol);
user2->auth_mech = p_strdup(user2->pool, user->auth_mech);
user2->auth_token = p_strdup(user2->pool, user->auth_token);
+ user2->auth_token_session_pid = user->auth_token_session_pid;
user2->auth_user = p_strdup(user2->pool, user->auth_user);
user2->session_id = p_strdup(user2->pool, user->session_id);
user2->session_create_time = user->session_create_time;