auth-master-connection.c revision 6f71a6a4ed759df963587302976d7315346d11f8
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "buffer.h"
#include "hash.h"
#include "str.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "network.h"
#include "userdb.h"
#include "auth-request-handler.h"
#include "auth-request-balancer.h"
#include "auth-master-interface.h"
#include "auth-client-connection.h"
#include "auth-master-connection.h"
#include <unistd.h>
#include <stdlib.h>
#define MAX_INBUF_SIZE 1024
struct auth_listener {
struct auth_master_connection *master;
enum listener_type type;
int fd;
char *path;
};
struct master_userdb_request {
struct auth_master_connection *conn;
unsigned int id;
struct auth_request *auth_request;
};
static int master_output(void *context);
static void auth_listener_destroy(struct auth_listener *l);
{
}
static int
{
struct auth_client_connection *client_conn;
const char *const *list;
/* <id> <client-pid> <client-id> */
i_error("BUG: Master sent broken REQUEST");
return FALSE;
}
if (client_conn == NULL) {
i_error("Master requested auth for nonexisting client %u",
} else {
}
return TRUE;
}
static int
{
return TRUE;
}
static void master_input(void *context)
{
char *line;
int ret;
case 0:
return;
case -1:
/* disconnected */
return;
case -2:
/* buffer full */
i_error("BUG: Master sent us more than %d bytes",
(int)MAX_INBUF_SIZE);
return;
}
if (!conn->version_received) {
return;
/* make sure the major version matches */
i_error("Master not compatible with this server "
"(mixed old and new binaries?)");
return;
}
}
t_push();
else {
/* ignore unknown command */
}
t_pop();
if (!ret) {
return;
}
}
}
static int master_output(void *context)
{
int ret;
/* transmit error, probably master died */
return 1;
}
/* allow input again */
}
return 1;
}
static void
{
}
struct auth_master_connection *
{
struct auth_master_connection *conn;
if (fd != -1)
return conn;
}
{
const char *line;
return;
}
{
if (!standalone)
i_error("close(): %m");
}
}
{
struct auth_listener **l;
return;
}
}
{
return TRUE;
return FALSE;
}
static void auth_accept(void *context)
{
struct auth_listener *l = context;
int fd;
if (fd < 0) {
if (fd < -1)
} else {
switch (l->type) {
case LISTENER_CLIENT:
break;
case LISTENER_MASTER:
/* we'll just replace the previous master.. */
break;
case LISTENER_BALANCER:
/* worker process connected to us */
break;
}
}
}
enum listener_type type)
{
struct auth_listener *l;
}
static void auth_listener_destroy(struct auth_listener *l)
{
struct auth_listener **lp;
for (i = 0; i < size; i++) {
if (lp[i] == l) {
i * sizeof(l), sizeof(l));
break;
}
}
net_disconnect(l->fd);
}
i_free(l);
}