auth-client-connection.c revision 78ed6a99e980228a75fa59cff84327dc0ea82857
/* Copyright (C) 2002-2003 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "network.h"
#include "base64.h"
#include "buffer.h"
#include "hash.h"
#include "str.h"
#include "str-sanitize.h"
#include "safe-memset.h"
#include "auth-request.h"
#include "auth-client-connection.h"
#include "auth-master-connection.h"
#include <stdlib.h>
/* Used only for string sanitization. */
#define MAX_MECH_NAME_LEN 64
static void
const char *fmt, ...)
{
t_push();
i_warning("Authentication client %u: "
}
t_pop();
}
{
const char **fields;
return NULL;
/* we only wish to remove all fields prefixed with "userdb_" */
return request->extra_fields;
}
}
enum auth_client_result result,
{
const char *fields;
t_push();
switch (result) {
break;
if (reply_size > 0) {
}
t_push();
}
t_pop();
break;
if (request->internal_failure)
t_push();
}
t_pop();
break;
}
if (ret < 0)
i_warning("Authentication client %u: "
"Transmit buffer full, killing it",
}
t_pop();
}
struct auth_client_connection *
unsigned int pid)
{
struct auth_client_connection *conn;
return conn;
}
return NULL;
}
static int
{
struct auth_client_connection *old;
unsigned int pid;
i_error("BUG: Authentication client re-handshaking");
return FALSE;
}
if (pid == 0) {
i_error("BUG: Authentication client said it's PID 0");
return FALSE;
}
/* already exists. it's possible that it just reconnected,
see if the old connection is still there. */
}
}
i_error("BUG: Authentication client gave a PID "
"%u of existing connection", pid);
return FALSE;
}
return TRUE;
}
static int
{
struct mech_module *mech;
struct auth_request *request;
const void *initial_resp_data;
unsigned int id;
int valid_client_cert;
i_error("BUG: Authentication client %u didn't send handshake",
return FALSE;
}
/* <id> <mechanism> [...] */
i_error("BUG: Authentication client %u "
return FALSE;
}
/* unsupported mechanism */
i_error("BUG: Authentication client %u requested unsupported "
return FALSE;
}
return TRUE;
/* parse optional parameters */
initial_resp = NULL;
arg = "";
} else {
arg++;
}
initial_resp = arg;
}
i_error("BUG: Authentication client %u "
return FALSE;
}
/* we fail without valid certificate */
"Client didn't present valid SSL certificate");
return TRUE;
}
if (initial_resp == NULL) {
initial_resp_len = 0;
} else {
"Invalid base64 data in initial response");
"reason=Invalid base64 data in initial "
"response", id);
return TRUE;
}
}
/* connection is referenced only until auth_callback is called. */
return TRUE;
}
static int
{
struct auth_request *request;
const char *data;
unsigned int id;
i_error("BUG: Authentication client %u "
return FALSE;
}
/* timeouted */
return TRUE;
}
if (!request->accept_input) {
"\treason=Unexpected continuation", id);
return TRUE;
}
"Invalid base64 data in continued response");
"in continued response", id);
return TRUE;
}
return TRUE;
}
static void auth_client_input(void *context)
{
char *line;
int ret;
case 0:
return;
case -1:
/* disconnected */
return;
case -2:
/* buffer full */
i_error("BUG: Auth client %u sent us more than %d bytes",
return;
}
if (!conn->version_received) {
return;
/* make sure the major version matches */
i_error("Authentication client %u "
"not compatible with this server "
return;
}
}
t_push();
else {
/* ignore unknown command */
}
t_pop();
if (!ret) {
break;
}
}
}
struct auth_client_connection *
{
static unsigned int connect_uid_counter = 0;
struct auth_client_connection *conn;
FALSE);
FALSE);
}
return conn;
}
{
struct auth_client_connection **pos;
return;
break;
}
}
}
}
static void
{
}
}
{
struct hash_iterate_context *iter;
return;
}
}
static void
{
struct hash_iterate_context *iter;
unsigned int secs;
if (conn->delayed_destroy) {
return;
}
secs = (unsigned int) (ioloop_time -
i_warning("Login process has too old (%us) requests, "
"killing it.", secs);
break;
}
}
if (destroy)
}
{
}
}
{
}
{
struct auth_client_connection *next;
}
}