client.c revision caea325346da6fb1cf503b35a619467a997acbfa
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "base64.h"
#include "buffer.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "randgen.h"
#include "process-title.h"
#include "safe-memset.h"
#include "strescape.h"
#include "client.h"
#include "client-authenticate.h"
#include "auth-client.h"
#include "ssl-proxy.h"
#include "pop3-proxy.h"
#include "hostpid.h"
/* max. length of input command line (spec says 512), or max reply length in
SASL authentication */
#define MAX_INBUF_SIZE 4096
/* max. size of output buffer. if it gets full, the client is disconnected.
SASL authentication gives the largest output. */
#define MAX_OUTBUF_SIZE 4096
/* Disconnect client after idling this many milliseconds */
/* Disconnect client when it sends too many bad commands */
#define CLIENT_MAX_BAD_COMMANDS 10
/* When max. number of simultaneous connections is reached, few of the
oldest connections are disconnected. Since we have to go through all of the
clients, it's faster if we disconnect multiple clients. */
#define CLIENT_DESTROY_OLDEST_COUNT 16
#endif
const char *login_protocol = "POP3";
{
const char *addr;
if (!verbose_proctitle || !process_per_connection)
return;
addr = "??";
}
{
}
{
int fd_ssl;
return;
if (fd_ssl == -1) {
"Disconnected: TLS initialization failed.");
return;
}
}
{
int ret;
return 1;
}
if (ret > 0) {
}
return 1;
}
{
return TRUE;
}
if (!ssl_initialized) {
return TRUE;
}
/* remove input handler, SSL proxy gives us a new fd. we also have to
remove it in case we have to wait for buffer to be flushed */
/* uncork the old fd */
/* the buffer has to be flushed */
} else {
}
return TRUE;
}
{
"(tried to use disabled plaintext authentication)");
} else {
"Aborted login (%u authentication attempts)",
}
return TRUE;
}
const char *args)
{
return FALSE;
}
{
case -2:
/* buffer full */
return FALSE;
case -1:
/* disconnected */
return FALSE;
default:
/* something was read */
return TRUE;
}
}
{
if (!client_read(client))
return;
*args++ = '\0';
client->bad_counter = 0;
"Disconnected: Too many bad commands");
}
}
if (client_unref(client))
}
void client_destroy_oldest(void)
{
unsigned int i, destroy_count;
/* find the oldest clients and put them to destroy-buffer */
for (i = 0; i < destroy_count; i++) {
if (destroy_buf[i] == NULL ||
/* @UNSAFE */
sizeof(destroy_buf) -
(i+1) * sizeof(struct pop3_client *));
destroy_buf[i] = pop3_client;
break;
}
}
}
/* then kill them */
for (i = 0; i < destroy_count; i++) {
if (destroy_buf[i] == NULL)
break;
"Disconnected: Connection queue full");
}
}
{
unsigned char buffer[16];
return NULL;
return i_strdup_printf("<%x.%x.%lx.%s@%s>",
(unsigned long)ioloop_time,
}
{
" " : NULL,
}
{
}
{
struct pop3_client *client;
/* always use nonblocking I/O */
main_ref();
if (client->auth_connected)
}
{
return;
} else {
}
}
}
}
}
main_unref();
}
{
"Refer to server log for more information.");
}
{
}
{
return TRUE;
return FALSE;
}
{
/* either disconnection or buffer full. in either case we
want this connection destroyed. however destroying it here
might break things if client is still tried to be accessed
without being referenced.. */
}
}
void clients_notify_auth_connected(void)
{
if (!pop3_client->auth_connected) {
}
}
}
void clients_destroy_all(void)
{
}
}
void clients_init(void)
{
/* Nothing to initialize for POP3 */
}
void clients_deinit(void)
{
}