client.c revision 76b43e4417bab52e913da39b5f5bc2a130d3f149
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen/* max. length of input command line (spec says 512), or max reply length in
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen SASL authentication */
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen/* max. size of output buffer. if it gets full, the client is disconnected.
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen SASL authentication gives the largest output. */
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen/* Disconnect client after idling this many seconds */
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen/* Disconnect client when it sends too many bad commands */
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen/* When max. number of simultaneous connections is reached, few of the
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen oldest connections are disconnected. Since we have to go through the whole
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen client hash, it's faster if we disconnect multiple clients. */
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen#if CLIENT_LOGIN_IDLE_TIMEOUT >= AUTH_REQUEST_TIMEOUT
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen# error client idle timeout must be smaller than authentication timeout
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainenstatic void client_set_title(struct pop3_client *client)
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen if (!verbose_proctitle || !process_per_connection)
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen process_title_set(t_strdup_printf(client->common.tls ?
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainenstatic void client_open_streams(struct pop3_client *client, int fd)
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen client->input = i_stream_create_fd(fd, MAX_INBUF_SIZE, FALSE);
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen client->output = o_stream_create_fd(fd, MAX_OUTBUF_SIZE, FALSE);
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainenstatic void client_start_tls(struct pop3_client *client)
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen if (!client_unref(client) || client->destroyed)
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen fd_ssl = ssl_proxy_new(client->common.fd, &client->common.ip,
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen client_send_line(client, "-ERR TLS initialization failed.");
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen "Disconnected: TLS initialization failed.");
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainen client->io = io_add(client->common.fd, IO_READ, client_input, client);
be6ad6e46ecb8c7126b421819046e7f4857a2babTimo Sirainenstatic int client_output_starttls(struct pop3_client *client)
int ret;
if (ret > 0) {
return TRUE;
if (!ssl_initialized) {
return TRUE;
return TRUE;
return TRUE;
const char *args)
return FALSE;
return FALSE;
return FALSE;
return TRUE;
void client_destroy_oldest(void)
unsigned int i, destroy_count;
for (i = 0; i < destroy_count; i++) {
sizeof(destroy_buf) -
for (i = 0; i < destroy_count; i++) {
return NULL;
(unsigned long)ioloop_time,
main_ref();
main_unref();
return TRUE;
return FALSE;
unsigned int clients_get_count(void)
void clients_notify_auth_connected(void)
void clients_destroy_all(void)
void clients_init(void)
void clients_deinit(void)