auth-connection.c revision c0435c854a0e7246373b9752d163095cc4fbe985
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "hash.h"
#include "ioloop.h"
#include "network.h"
#include "istream.h"
#include "ostream.h"
#include "auth-connection.h"
#include <unistd.h>
#include <dirent.h>
#define MAX_OUTBUF_SIZE \
(sizeof(struct auth_continued_request_data) + \
struct auth_connection {
struct auth_connection *next;
char *path;
int fd;
unsigned int auth_process;
struct auth_reply_data in_reply;
struct hash_table *requests;
unsigned int init_received:1;
unsigned int in_reply_received:1;
};
static int auth_reconnect;
static unsigned int request_id_counter;
static struct auth_connection *auth_connections;
static void auth_connect_missing(void);
{
struct auth_connection *conn;
return conn;
}
return NULL;
}
{
struct auth_connection *conn;
struct client_auth_init_data init_data;
int fd;
if (fd == -1) {
return NULL;
}
FALSE);
/* send our handshake */
return NULL;
}
return conn;
}
{
}
{
(const unsigned char *) "Authentication process died",
}
void *context __attr_unused__)
{
}
{
struct auth_connection **pos;
break;
}
}
i_error("close(imap-auth) failed: %m");
}
static struct auth_connection *
{
struct auth_connection *conn;
int found;
return conn;
}
}
if (!found) {
if ((available_auth_methods & method) == 0)
*error = "Unsupported authentication method";
else {
*error = "Authentication server isn't connected, "
"try again later..";
}
} else {
*error = "Authentication servers are busy, wait..";
i_warning("Authentication servers are busy");
}
return NULL;
}
static void update_available_auth_methods(void)
{
struct auth_connection *conn;
}
struct auth_init_data *init_data)
{
}
struct auth_reply_data *reply_data,
const unsigned char *data)
{
struct auth_request *request;
i_error("BUG: imap-auth sent us reply with unknown ID %u",
reply_data->id);
return;
}
/* save the returned cookie */
t_push();
t_pop();
}
{
struct auth_init_data init_data;
const unsigned char *data;
case 0:
return;
case -1:
/* disconnected */
return;
case -2:
/* buffer full - can't happen unless imap-auth is buggy */
i_error("BUG: imap-auth sent us more than %d bytes of data",
return;
}
if (!conn->init_received) {
if (size == sizeof(struct auth_init_data)) {
sizeof(struct auth_init_data));
} else if (size > sizeof(struct auth_init_data)) {
i_error("BUG: imap-auth sent us too much "
sizeof(struct auth_init_data));
}
return;
}
if (!conn->in_reply_received) {
if (size < sizeof(struct auth_reply_data))
return;
data += sizeof(struct auth_reply_data);
size -= sizeof(struct auth_reply_data);
}
return;
/* we've got a full reply */
}
{
struct auth_connection *conn;
struct auth_request *request;
struct auth_init_request_data request_data;
if (auth_reconnect)
return FALSE;
/* create internal request structure */
/* send request to auth */
sizeof(request_data)) < 0)
return TRUE;
}
{
/* send continued request to auth */
sizeof(request_data)) < 0)
}
static void auth_connect_missing(void)
{
/* we're chrooted into */
i_error("opendir(\".\") failed when trying to get list of "
"authentication servers: %m");
return;
}
continue;
/* already connected */
continue;
}
}
}
}
static void
{
if (auth_reconnect)
}
void auth_connection_init(void)
{
request_id_counter = 0;
}
void auth_connection_deinit(void)
{
struct auth_connection *next;
while (auth_connections != NULL) {
}
}