auth-connection.c revision 66251e6ab31e5cc153fe5cae608e416dacafe9cd
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "hash.h"
#include "network.h"
#include "iobuffer.h"
#include "auth-connection.h"
#include <unistd.h>
#include <dirent.h>
#define MAX_INBUF_SIZE (AUTH_MAX_REQUEST_DATA_SIZE)
#define MAX_OUTBUF_SIZE \
(sizeof(AuthContinuedRequestData) + AUTH_MAX_REQUEST_DATA_SIZE)
struct _AuthConnection {
char *path;
int fd;
int auth_process;
unsigned int init_received:1;
unsigned int in_reply_received:1;
};
static int auth_connects_failed;
static int request_id_counter;
static AuthConnection *auth_connections;
static void auth_connect_missing(void);
{
int fd;
if (fd == -1) {
return NULL;
}
return conn;
}
{
}
{
}
void *user_data __attr_unused__)
{
}
{
char *path;
break;
}
}
if (reconnect) {
}
}
const char **error)
{
int found;
return conn;
}
}
if (!found)
*error = "Unsupported authentication method";
else {
*error = "Authentication servers are busy, wait..";
i_warning("Authentication servers are busy");
}
return NULL;
}
static void update_available_auth_methods(void)
{
}
{
}
unsigned char *data)
{
i_error("BUG: imap-auth sent us reply with unknown ID %u",
reply_data->id);
return;
}
/* save the returned cookie */
t_push();
t_pop();
}
{
unsigned char *data;
unsigned int size;
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(AuthInitData)) {
} else if (size > sizeof(AuthInitData)) {
i_error("BUG: imap-auth sent us too much "
"initialization data (%u vs %u)",
size, sizeof(AuthInitData));
}
return;
}
if (!conn->in_reply_received) {
if (size < sizeof(AuthReplyData))
return;
data += sizeof(AuthReplyData);
size -= sizeof(AuthReplyData);
}
return;
/* we've got a full reply */
}
{
if (auth_connects_failed)
return FALSE;
/* create internal request structure */
/* send request to auth */
sizeof(request_data)) < 0)
return TRUE;
}
unsigned int data_size)
{
/* 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;
}
}
}
void auth_connection_init(void)
{
request_id_counter = 0;
}
void auth_connection_deinit(void)
{
while (auth_connections != NULL) {
}
}