client-common.c revision 2dfd08e8aa16dfcc975d8a62bc8d20b2ef849d71
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen/* Copyright (c) 2002-2015 Dovecot authors, see the included COPYING file */
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainenstatic unsigned int clients_count = 0;
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainenstatic void client_idle_disconnect_timeout(struct client *client)
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen unsigned int secs;
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen user_reason = "Timeout while finishing login.";
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen "Timeout while finishing login (waited %u secs)", secs);
10b8040903b1d1591f1d44552ff466c8789b8814Timo Sirainen "Disconnected for inactivity during authentication.";
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen "Disconnected: Inactivity during authentication";
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen user_reason = "Timeout while finishing login.";
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen "proxy: Logging in to %s:%u timed out "
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen "(state=%u, duration=%us)",
885a3c2287ae3e5827aa580ea06b231de38abb47Timo Sirainen client_notify_disconnect(client, CLIENT_DISCONNECT_TIMEOUT, user_reason);
29f138b4b9bc037b21dfaa6b8e458943a99d5db2Timo Sirainenstatic void client_open_streams(struct client *client)
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen i_stream_create_fd(client->fd, LOGIN_MAX_INBUF_SIZE, FALSE);
23878bd03d1de531e3261a25598beec621351910Timo Sirainen o_stream_create_fd(client->fd, LOGIN_MAX_OUTBUF_SIZE, FALSE);
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen o_stream_set_no_error_handling(client->output, TRUE);
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen if (iostream_rawlog_create(login_rawlog_dir, &client->input,
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainenstatic bool client_is_trusted(struct client *client)
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen const char *const *net;
0f9a8663b0ff6fe30389d02284a2b002c40914ebTimo Sirainen unsigned int bits;
a9efdb661eb7a8a33aacfdcc3486dcc675a21543Timo Sirainen if (client->set->login_trusted_networks == NULL)
bd417d416988d11a6b555b9aa57779e7ed976951Timo Sirainen net = t_strsplit_spaces(client->set->login_trusted_networks, ", ");
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen if (net_parse_range(*net, &net_ip, &bits) < 0) {
5230375627245d0c7ceb636ad10b985f4444e49eTimo Sirainen if (net_is_in_network(&client->ip, &net_ip, bits))
97437f768d1a3e6134fed1971202803fd250eef2Timo Sirainen const struct master_service_ssl_settings *ssl_set,
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen client = login_binary->client_vfuncs->alloc(pool);
23878bd03d1de531e3261a25598beec621351910Timo Sirainen client->v.auth_send_challenge = client_auth_send_challenge;
23878bd03d1de531e3261a25598beec621351910Timo Sirainen client->v.auth_parse_response = client_auth_parse_response;
23878bd03d1de531e3261a25598beec621351910Timo Sirainen client->real_local_port = conn->real_local_port;
23878bd03d1de531e3261a25598beec621351910Timo Sirainen client->real_remote_ip = conn->real_remote_ip;
23878bd03d1de531e3261a25598beec621351910Timo Sirainen client->real_remote_port = conn->real_remote_port;
ecbbdf594f9329fc15a182bd6c7c4a7fb144ed74Timo Sirainen client->listener_name = p_strdup(client->pool, conn->name);
a6ab8f00351265e35b79f3a22b1f5a4978ae5c35Timo Sirainen net_ip_compare(&conn->real_remote_ip, &conn->real_local_ip);
return client;
return TRUE;
return FALSE;
void client_destroy_oldest(void)
void clients_destroy_all(void)
int fd_ssl;
int ret;
if (ret > 0) {
unsigned int clients_get_count(void)
return clients_count;
#ifdef HAVE_IPV6
static const struct var_expand_table *
sizeof(login_var_expand_empty_tab));
const char *ssl_state =
const char *ssl_error =
return tab;
char key;
str++;
return TRUE;
return FALSE;
unsigned int i, field_name_len;
return NULL;
field_name_len) == 0 &&
return NULL;
unsigned int pos;
if (have_username_key(*e)) {
T_BEGIN {
} T_END;
T_BEGIN {
} T_END;
T_BEGIN {
} T_END;
return t_strdup_printf(
const char *text)
return FALSE;
return FALSE;
return TRUE;
return TRUE;