master-login.c revision 47f1c273dfaea552c034ffbecdec096f7cbaef35
/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "ostream.h"
#include "fdpass.h"
#include "fd-close-on-exec.h"
#include "llist.h"
#include "master-service-private.h"
#include "master-login.h"
#include "master-login-auth.h"
#include <unistd.h>
struct master_login_connection {
struct master_login *login;
int fd;
};
struct master_login {
struct master_service *service;
struct master_login_connection *conns;
struct master_login_auth *auth;
};
struct master_login *
{
struct master_login *login;
return login;
}
{
}
}
static int
struct master_auth_request *req_r,
unsigned char data[MASTER_AUTH_MAX_DATA_SIZE],
int *client_fd_r)
{
*client_fd_r = -1;
if (ret == 0) {
/* disconnected */
} else if (ret > 0) {
/* request wasn't fully read */
i_error("fd_read() partial input (%d/%d)",
} else {
return 0;
i_error("fd_read() failed: %m");
}
return -1;
}
i_error("Too large auth data_size sent");
return -1;
}
/* @UNSAFE */
if (ret == 0) {
/* disconnected */
} else if (ret > 0) {
/* request wasn't fully read */
i_error("Data read partially %d/%u",
} else {
i_error("read(data) failed: %m");
}
return -1;
}
}
if (*client_fd_r == -1) {
i_error("Auth request missing a file descriptor");
return -1;
}
i_error("fstat(fd_read client) failed: %m");
return -1;
}
i_error("Auth request inode mismatch: %s != %s",
return -1;
}
return 1;
}
static void
{
struct master_auth_reply reply;
bool close_config;
i_error("close(fd_read client) failed: %m");
return;
}
if (close_config) {
/* we're dying as soon as this connection closes. */
}
}
{
struct master_auth_request req;
struct master_login_client *client;
unsigned char data[MASTER_AUTH_MAX_DATA_SIZE];
unsigned int request_count;
if (ret <= 0) {
if (ret < 0)
if (client_fd != -1) {
i_error("close(fd_read client) failed: %m");
}
return;
}
/* @UNSAFE: we have a request. do userdb lookup for it. */
}
{
struct master_login_connection *conn;
/* don't accept more connections. this is mainly a temporary
workaround.. */
}
{
i_error("close(master login) failed: %m");
}