login-connection.c revision c0435c854a0e7246373b9752d163095cc4fbe985
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "network.h"
#include "safe-memset.h"
#include "cookie.h"
#include "login-connection.h"
#include <stdlib.h>
#include <syslog.h>
#define MAX_INBUF_SIZE \
(sizeof(struct auth_continued_request_data) + \
#define MAX_OUTBUF_SIZE \
struct login_connection {
struct login_connection *next;
int fd;
unsigned int pid;
enum auth_request_type type;
};
static struct auth_init_data auth_init_data;
static struct login_connection *connections;
{
}
}
{
struct login_connection *conn;
return conn;
}
return NULL;
}
{
struct client_auth_init_data rec;
unsigned char *data;
if (size < sizeof(struct client_auth_init_data))
return;
/* Don't just cast because of alignment issues. */
i_error("BUG: imap-login said it's PID 0");
/* well, it might have just reconnected very fast .. although
there's not much reason for it. */
i_error("BUG: imap-login gave a PID of existing connection");
} else {
}
}
{
unsigned char *data;
if (size < sizeof(enum auth_request_type))
return;
/* note that we can't directly cast the received data pointer into
structures, as it may not be aligned properly. */
/* get the request type */
}
struct auth_init_request_data request;
return;
/* we have a full init request */
struct auth_continued_request_data request;
return;
return;
/* we have a full continued request */
/* clear any sensitive data from memory */
} else {
/* unknown request */
i_error("BUG: imap-login sent us unknown request %u",
}
}
{
case 0:
return;
case -1:
/* disconnected */
return;
case -2:
/* buffer full */
i_error("BUG: imap-login sent us more than %d bytes of data",
(int)MAX_INBUF_SIZE);
return;
}
else
}
{
struct login_connection *conn;
FALSE);
connections = conn;
sizeof(auth_init_data)) < 0) {
}
return conn;
}
{
struct login_connection **pos;
break;
}
}
}
void login_connections_init(void)
{
const char *env;
i_fatal("AUTH_PROCESS environment is unset");
connections = NULL;
}
void login_connections_deinit(void)
{
struct login_connection *next;
while (connections != NULL) {
connections = next;
}
}