client-common.c revision 5a9e240ebf8d0daaf029973973b52e415148070b
/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
#include "login-common.h"
#include "hostpid.h"
#include "llist.h"
#include "istream.h"
#include "ostream.h"
#include "process-title.h"
#include "str.h"
#include "str-sanitize.h"
#include "safe-memset.h"
#include "var-expand.h"
#include "master-service.h"
#include "master-auth.h"
#include "auth-client.h"
#include "login-proxy.h"
#include "ssl-proxy.h"
#include "client-common.h"
#include <stdlib.h>
static unsigned int clients_count = 0;
{
"Disconnected for inactivity.");
}
{
}
struct client *
{
client->v = client_vfuncs;
if (last_client == NULL)
else
return client;
}
{
return;
}
if (last_client == client)
if (client->master_tag != 0) {
} else {
}
}
}
if (client_unref(&client) &&
/* as soon as this connection is done with proxying
(or whatever), the process will die. there's no need for
authentication anymore, so close the connection. */
}
}
{
}
{
"Internal login failure. "
"Refer to server log for more information.");
}
{
}
{
return TRUE;
i_assert(clients_count > 0);
return FALSE;
}
void client_destroy_oldest(void)
{
if (last_client == NULL) {
/* we have no clients */
return;
}
/* destroy the last client that hasn't successfully authenticated yet.
this is usually the last client, but don't kill it if it's just
waiting for master to finish its job. */
if (client->master_tag == 0)
break;
}
}
void clients_destroy_all(void)
{
}
}
{
int fd_ssl;
return;
if (fd_ssl == -1) {
"TLS initialization failed.");
"Disconnected: TLS initialization failed.");
return;
}
}
{
int ret;
return 1;
}
if (ret > 0) {
}
return 1;
}
{
"TLS is already active.");
return;
}
if (!ssl_initialized) {
"TLS support isn't enabled.");
return;
}
/* 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 */
"Begin TLS negotiation now.");
/* uncork the old fd */
/* the buffer has to be flushed */
} else {
}
}
unsigned int clients_get_count(void)
{
return clients_count;
}
static const struct var_expand_table *
{
static struct var_expand_table static_tab[] = {
};
struct var_expand_table *tab;
unsigned int i;
for (i = 0; i < 3; i++)
}
} else {
const char *ssl_state =
"TLS" : "TLS handshaking";
const char *ssl_error =
}
return tab;
}
{
char key;
unsigned int i;
}
}
return FALSE;
}
static const char *
{
};
const struct var_expand_table *var_expand_table;
struct var_expand_table *tab;
const char *p;
char *const *e;
for (p = *e; *p != '\0'; p++) {
if (*p != '%' || p[1] == '\0')
continue;
p++;
if (have_key(var_expand_table, p)) {
break;
}
}
}
str_truncate(str, 0);
}
{
T_BEGIN {
} T_END;
}
{
T_BEGIN {
} T_END;
}
{
const char *const *net;
unsigned int bits;
return FALSE;
i_error("login_trusted_networks: "
"Invalid network '%s'", *net);
break;
}
return TRUE;
}
return FALSE;
}
{
return "(client sent an invalid cert)";
return "(client didn't send a cert)";
}
if (client->auth_attempts == 0)
return "(no auth attempts)";
return "(tried to use disabled plaintext auth)";
return "(cert required, client didn't start TLS)";
return "(tried to use unsupported auth mechanism)";
return "(disconnected while authenticating)";
return "(aborted authentication)";
return t_strdup_printf("(auth failed, %u attempts)",
}
const char *text)
{
}
{
/* 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.. */
}
}
{
}
{
case -2:
/* buffer full */
"Input buffer full, aborting");
return FALSE;
case -1:
/* disconnected */
return FALSE;
case 0:
/* nothing new read */
return TRUE;
default:
/* something was read */
return TRUE;
}
}
{
}