client-common.c revision baebb412a9a5a44b1756e01cfa3b99f5d8a846b6
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Copyright (c) 2002-2011 Dovecot authors, see the included COPYING file */
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainenstruct client *clients = NULL, *last_client = NULL;
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainenstatic unsigned int clients_count = 0;
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainenstatic void client_idle_disconnect_timeout(struct client *client)
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainen client_send_line(client, CLIENT_CMD_REPLY_BYE,
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainen "Disconnected for inactivity.");
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainen client_destroy(client, "Disconnected: Inactivity");
af1f4b17a92ca7b2661737e65c7849df289d3070Timo Sirainenstatic void client_open_streams(struct client *client)
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen i_stream_create_fd(client->fd, LOGIN_MAX_INBUF_SIZE, FALSE);
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen o_stream_create_fd(client->fd, LOGIN_MAX_OUTBUF_SIZE, FALSE);
992a13add4eea0810e4db0f042a595dddf85536aTimo Sirainen if (iostream_rawlog_create(login_rawlog_dir, &client->input,
d30da25fb6be1f1c667d93767c9194000194b618Timo Sirainen const struct login_settings *set, void **other_sets,
d30da25fb6be1f1c667d93767c9194000194b618Timo Sirainen const struct ip_addr *local_ip, const struct ip_addr *remote_ip)
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen client = login_binary->client_vfuncs->alloc(pool);
597dce34068d603fb759b4dff404b34049213e51Timo Sirainen client->v.auth_send_challenge = client_auth_send_challenge;
597dce34068d603fb759b4dff404b34049213e51Timo Sirainen client->v.auth_parse_response = client_auth_parse_response;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenvoid client_destroy(struct client *client, const char *reason)
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen if (!client->login_success && reason != NULL) {
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen client_get_extra_disconnect_reason(client), NULL);
992a13add4eea0810e4db0f042a595dddf85536aTimo Sirainen master_auth_request_abort(master_auth, client->master_tag);
d67fde1a8ebc1d85704c5986d8f93aae97eccef3Timo Sirainen master_service_get_service_count(master_service) == 1) {
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen /* as soon as this connection is done with proxying
d67fde1a8ebc1d85704c5986d8f93aae97eccef3Timo Sirainen (or whatever), the process will die. there's no need for
d67fde1a8ebc1d85704c5986d8f93aae97eccef3Timo Sirainen authentication anymore, so close the connection. */
d67fde1a8ebc1d85704c5986d8f93aae97eccef3Timo Sirainenvoid client_destroy_success(struct client *client, const char *reason)
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenvoid client_destroy_internal_failure(struct client *client)
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen client_send_line(client, CLIENT_CMD_REPLY_AUTH_FAIL_TEMP,
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen "Internal login failure. "
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen "Refer to server log for more information.");
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen "Internal login failure (pid=%s id=%u)",
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen master_service_client_connection_destroyed(master_service);
void client_destroy_oldest(void)
void clients_destroy_all(void)
int fd_ssl;
int ret;
if (ret > 0) {
if (!ssl_initialized) {
unsigned int clients_get_count(void)
return clients_count;
static const struct var_expand_table *
const char *ssl_state =
const char *ssl_error =
return tab;
char key;
return FALSE;
T_BEGIN {
} T_END;
T_BEGIN {
} T_END;
const char *const *net;
unsigned int bits;
return FALSE;
return TRUE;
return FALSE;
const char *text)
return FALSE;
return FALSE;
return TRUE;
return TRUE;