main.c revision e59faf65ce864fe95dc00f5d52b8323cdbd0608a
/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
#include "login-common.h"
#include "ioloop.h"
#include "randgen.h"
#include "process-title.h"
#include "restrict-access.h"
#include "restrict-process-size.h"
#include "master-auth.h"
#include "master-service.h"
#include "master-interface.h"
#include "client-common.h"
#include "anvil-client.h"
#include "auth-client.h"
#include "ssl-proxy.h"
#include "login-proxy.h"
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
struct auth_client *auth_client;
struct master_auth *master_auth;
bool closing_down;
struct anvil_client *anvil;
const struct login_settings *global_login_settings;
void **global_other_settings;
static bool shutting_down = FALSE;
static bool ssl_connections = FALSE;
void login_refresh_proctitle(void)
{
const char *addr;
return;
if (clients_get_count() == 0) {
process_title_set("");
clients_get_count(), ssl_proxy_get_count()));
} else {
}
}
static void login_die(void)
{
/* we don't have auth client, and we might never get one */
}
}
{
const struct login_settings *set;
unsigned int local_port;
int fd_ssl;
void **other_sets;
local_port = 0;
}
} else {
&proxy);
if (fd_ssl == -1) {
pool_unref(&pool);
return;
}
}
}
{
if (connected)
else if (shutting_down)
}
static bool anvil_reconnect_callback(void)
{
return FALSE;
}
static void main_preinit(bool allow_core_dumps)
{
unsigned int max_fds;
random_init();
/* Initialize SSL proxy so it can read certificate and private
key file. */
/* set the number of fds we want to use. it may get increased or
decreased. leave a couple of extra fds for auth sockets and such.
worst case each connection can use:
- 1 for client
- 1 for login proxy
- 2 for client-side ssl proxy
- 2 for server-side ssl proxy (with login proxy)
*/
if (global_login_settings->mail_max_userip_connections > 0) {
i_fatal("Couldn't connect to anvil");
}
if (allow_core_dumps)
}
static void main_init(void)
{
/* make sure we can't fork() */
if (restrict_access_get_current_chroot() == NULL) {
if (chdir("login") < 0)
i_fatal("chdir(login) failed: %m");
}
clients_init();
}
static void main_deinit(void)
{
if (auth_client != NULL)
}
{
bool allow_core_dumps = FALSE;
int c;
while ((c = master_getopt(master_service)) > 0) {
switch (c) {
case 'D':
break;
case 'S':
break;
default:
return FATAL_DEFAULT;
}
}
/* main_preinit() needs to know the client limit, which is set by
this. so call it first. */
main_init();
main_deinit();
return 0;
}