auth-server-connection.c revision 2767104d81e97a109f0aa9758792bfa1da325a97
/* Copyright (C) 2003 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "hash.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "network.h"
#include "auth-client.h"
#include "auth-server-connection.h"
#include "auth-server-request.h"
#include <unistd.h>
/* Maximum size for an auth reply. 50kB should be more than enough. */
#define MAX_OUTBUF_SIZE \
(sizeof(struct auth_client_request_continue) + \
{
const struct auth_mech_desc *mech;
struct auth_mech_desc *new_mech;
unsigned int i;
for (i = 0; i < conn->available_auth_mechs_count; i++) {
}
}
}
struct auth_client_handshake_reply *handshake,
const unsigned char *data)
{
struct auth_mech_desc mech_desc;
unsigned int i;
i_error("BUG: Auth server sent corrupted handshake");
return;
}
for (i = 0; i < handshake->mech_count; i++) {
data + sizeof(handshake_mech_desc) * i,
sizeof(handshake_mech_desc));
i_error("BUG: Auth server sent corrupted handshake");
return;
}
}
}
}
static void auth_client_input(void *context)
{
struct auth_client_handshake_reply handshake;
const unsigned char *data;
case 0:
return;
case -1:
/* disconnected */
return;
case -2:
/* buffer full - can't happen unless auth is buggy */
i_error("BUG: Auth server sent us more than %d bytes of data",
return;
}
if (!conn->handshake_received) {
return;
return;
return;
}
if (!conn->reply_received) {
return;
}
return;
/* we've got a full reply */
}
struct auth_server_connection *
{
struct auth_server_connection *conn;
int fd;
if (fd == -1) {
return NULL;
}
/* use blocking connection since we depend on auth server -
if it's slow, just wait */
else {
conn->ext_input_io =
}
FALSE);
FALSE);
/* send our handshake */
i_warning("Error sending handshake to auth server: %m");
return NULL;
}
return conn;
}
int reconnect)
{
struct auth_server_connection **pos;
return;
break;
}
}
if (!conn->handshake_received)
}
}
i_error("close(auth) failed: %m");
if (reconnect)
}
}
{
return;
}
struct auth_server_connection *
{
struct auth_server_connection *conn;
return conn;
}
return NULL;
}
struct auth_server_connection *
{
struct auth_server_connection *conn;
const struct auth_mech_desc *mech;
unsigned int i;
for (i = 0; i < conn->available_auth_mechs_count; i++) {
return conn;
}
}
*error_r = "Unsupported authentication mechanism";
else {
*error_r = "Authentication server isn't connected, "
"try again later..";
}
return NULL;
}