Added %e log format element for it.
--HG--
branch : HEAD
{ 'a', NULL },
{ 'b', NULL },
{ 'c', NULL },
+ { 'e', NULL },
{ '\0', NULL }
};
struct var_expand_table *tab;
tab[11].value = ssl_error == NULL ? ssl_state :
t_strdup_printf("%s: %s", ssl_state, ssl_error);
}
+ tab[12].value = dec2str(client->mail_pid);
return tab;
}
sasl_server_callback_t *sasl_callback;
unsigned int auth_attempts;
+ pid_t mail_pid;
char *virtual_user;
unsigned int tls:1;
static struct client destroyed_client;
static void client_call_master_callback(struct client *client,
- enum master_login_status status)
+ const struct master_login_reply *reply)
{
master_callback_t *master_callback;
client->master_tag = 0;
client->master_callback = NULL;
- master_callback(client, status);
+ master_callback(client, reply);
}
static void request_handle(struct master_login_reply *reply)
hash_remove(master_requests, POINTER_CAST(reply->tag));
if (client != &destroyed_client) {
- client_call_master_callback(client, reply->status);
+ client_call_master_callback(client, reply);
/* NOTE: client may be destroyed now */
}
}
void master_request_abort(struct client *client)
{
+ struct master_login_reply reply;
+
/* we're still going to get the reply from the master, so just
remember that we want to ignore it */
hash_update(master_requests, POINTER_CAST(client->master_tag),
&destroyed_client);
- client_call_master_callback(client, FALSE);
+ memset(&reply, 0, sizeof(reply));
+ reply.status = MASTER_LOGIN_STATUS_INTERNAL_ERROR;
+ client_call_master_callback(client, &reply);
}
void master_notify_state_change(enum master_login_state state)
#include "../master/master-login-interface.h"
typedef void master_callback_t(struct client *client,
- enum master_login_status status);
+ const struct master_login_reply *reply);
void master_request_login(struct client *client, master_callback_t *callback,
unsigned int auth_pid, unsigned int auth_id);
}
static void
-master_callback(struct client *client, enum master_login_status status)
+master_callback(struct client *client, const struct master_login_reply *reply)
{
- enum sasl_server_reply reply = SASL_SERVER_REPLY_MASTER_FAILED;
+ enum sasl_server_reply sasl_reply = SASL_SERVER_REPLY_MASTER_FAILED;
const char *data = NULL;
client->authenticating = FALSE;
- switch (status) {
+ switch (reply->status) {
case MASTER_LOGIN_STATUS_OK:
- reply = SASL_SERVER_REPLY_SUCCESS;
+ sasl_reply = SASL_SERVER_REPLY_SUCCESS;
break;
case MASTER_LOGIN_STATUS_INTERNAL_ERROR:
break;
data = "Maximum number of connections from user+IP exceeded";
break;
}
- call_client_callback(client, reply, data, NULL);
+ client->mail_pid = reply->mail_pid;
+ call_client_callback(client, sasl_reply, data, NULL);
}
static void authenticate_callback(struct auth_request *request, int status,
master_reply.status =
create_mail_process(group->mail_process_type,
group->set, &request->mail_request,
- user, args, request->data, FALSE);
+ user, args, request->data, FALSE,
+ &master_reply.mail_pid);
} T_END;
/* reply to login */
create_mail_process(enum process_type process_type, struct settings *set,
const struct mail_login_request *request,
const char *user, const char *const *args,
- const unsigned char *data, bool dump_capability)
+ const unsigned char *data, bool dump_capability,
+ pid_t *pid_r)
{
const struct var_expand_table *var_expand_table;
const char *p, *addr, *mail, *chroot_dir, *home_dir, *full_home_dir;
mail_process_group_add(process_group, pid);
}
(void)close(log_fd);
+ *pid_r = pid;
return MASTER_LOGIN_STATUS_OK;
}
create_mail_process(enum process_type process_type, struct settings *set,
const struct mail_login_request *request,
const char *user, const char *const *args,
- const unsigned char *data, bool dump_capability);
+ const unsigned char *data, bool dump_capability,
+ pid_t *pid_r);
void mail_processes_init(void);
void mail_processes_deinit(void);
struct master_login_reply {
unsigned int tag;
enum master_login_status status;
+ /* PID of the post-login mail process handling this connection */
+ pid_t mail_pid;
};
#endif
ssize_t ret;
unsigned int pos;
uid_t uid;
+ pid_t pid;
if (generated_capability != NULL) {
/* Reloading configuration. Don't try to execute the imap
memset(&request, 0, sizeof(request));
request.fd = fd[1];
login_status = create_mail_process(PROCESS_TYPE_IMAP, set, &request,
- "dump-capability", args, NULL, TRUE);
+ "dump-capability", args, NULL, TRUE,
+ &pid);
if (login_status != MASTER_LOGIN_STATUS_OK) {
(void)close(fd[0]);
(void)close(fd[1]);
alarm(5);
if (wait(&status) == -1)
- i_fatal("imap dump-capability process got stuck");
+ i_fatal("imap dump-capability process %d got stuck", (int)pid);
alarm(0);
if (status != 0) {