client.c revision 61ebb73ab16c1f8411f84a3f2826d9635e818677
/* Copyright (c) 2002-2009 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 "master-service.h"
#include "master-auth.h"
#include "client.h"
#include "client-authenticate.h"
#include "auth-client.h"
#include "ssl-proxy.h"
#include "pop3-proxy.h"
#include "hostpid.h"
/* 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 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 *login_process_name = "pop3-login";
{
const char *addr;
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;
}
{
return TRUE;
}
const char *args)
{
return FALSE;
}
{
case -2:
/* buffer full */
return FALSE;
case -1:
/* disconnected */
return FALSE;
case 0:
/* nothing new read */
return TRUE;
default:
/* something was read */
return TRUE;
}
}
{
if (!client_read(client))
return;
/* if a command starts an authentication, stop processing further
commands until the authentication is finished. */
*args++ = '\0';
client->bad_counter = 0;
"Disconnected: Too many bad commands");
}
}
if (client_unref(client))
}
void client_destroy_oldest(void)
{
unsigned int max_connections =
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,
}
{
}
const struct login_settings *set,
{
struct pop3_client *client;
/* reached max. users count, kill few of the
oldest connections */
}
/* always use nonblocking I/O */
if (client->auth_connected)
}
{
}
{
return;
NULL);
}
} else {
}
}
}
}
}
{
"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)
{
}