main.c revision 11ee3b40320a31669bd717fecbe1e332dad4fd84
/* Copyright (c) 2010-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "restrict-access.h"
#include "process-title.h"
#include "master-interface.h"
#include "master-service.h"
#include "master-service-settings.h"
#include "auth-connection.h"
#include "doveadm-connection.h"
#include "login-connection.h"
#include "notify-connection.h"
#include "user-directory.h"
#include "director.h"
#include "director-host.h"
#include "director-connection.h"
#include "director-request.h"
#include "mail-host.h"
#include <stdio.h>
#include <unistd.h>
#define AUTH_SOCKET_PATH "auth-login"
#define AUTH_USERDB_SOCKET_PATH "auth-userdb"
enum director_socket_type {
};
static struct notify_connection *notify_conn;
static struct timeout *to_proctitle_refresh;
{
if (director->users_moving_count > 0)
}
static enum director_socket_type
director_socket_type_get_from_name(const char *path)
{
else
name++;
else
suffix++;
return DIRECTOR_SOCKET_TYPE_AUTH;
return DIRECTOR_SOCKET_TYPE_USERDB;
return DIRECTOR_SOCKET_TYPE_AUTHREPLY;
return DIRECTOR_SOCKET_TYPE_RING;
return DIRECTOR_SOCKET_TYPE_DOVEADM;
else
return DIRECTOR_SOCKET_TYPE_UNKNOWN;
}
static enum director_socket_type
{
local_port != 0) {
return DIRECTOR_SOCKET_TYPE_RING;
}
return DIRECTOR_SOCKET_TYPE_AUTH;
}
{
const char *name;
unsigned int i, socket_count;
enum director_socket_type type;
*listen_port_r = 0;
for (i = 0; i < socket_count; i++) {
int listen_fd = MASTER_LISTEN_FD_FIRST + i;
if (type == DIRECTOR_SOCKET_TYPE_UNKNOWN) {
/* mainly for backwards compatibility */
}
*listen_ip_r = ip;
*listen_port_r = port;
}
}
}
{
struct director_host *host;
i_warning("Connection from %s: Server not listed in "
return -1;
}
return 0;
}
{
struct auth_connection *auth;
const char *socket_path;
const enum director_socket_type *typep;
bool userdb;
if (notify_conn != NULL) {
i_error("Received another proxy-notify connection");
return;
}
return;
}
switch (*typep) {
i_unreached();
/* a) userdb connection, probably for lmtp proxy
b) login connection
Both of them are handled exactly the same, except for which
auth socket they connect to. */
if (auth_connection_connect(auth) < 0) {
break;
}
break;
break;
break;
break;
}
}
{
struct director_request *const *requestp;
bool ret;
return;
/* if there are any pending client requests, finish them now */
if (!ret) {
/* a) request for a user being killed
b) user is weak */
}
}
}
static void main_preinit(void)
{
const struct director_settings *set;
/* make sure we die with master even with shutdown_clients=no.
otherwise there will be two director processes and everything is
broken. it's only the login processes that need to stay alive. */
(void *)NULL);
}
i_fatal("No inet_listeners defined for director service "
"(for standalone keep director_servers empty)");
}
set->director_mail_servers) < 0)
i_fatal("Invalid value for director_mail_servers setting");
}
static void main_deinit(void)
{
if (to_proctitle_refresh != NULL)
if (notify_conn != NULL)
}
{
const struct setting_parser_info *set_roots[] = {
};
const enum master_service_flags service_flags =
const char *error;
int c;
while ((c = master_getopt(master_service)) > 0) {
switch (c) {
case 'D':
break;
case 't':
break;
default:
return FATAL_DEFAULT;
}
}
&error) < 0)
main_preinit();
/* we're testing, possibly writing to same log file.
make it clear which director we are. */
t_strdup_printf("director(%s): ",
}
main_deinit();
return 0;
}