main.c revision 9137c55411aa39d41c1e705ddc34d5bd26c65021
/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "ioloop.h"
#include "randgen.h"
#include "restrict-access.h"
#include "restrict-process-size.h"
#include "process-title.h"
#include "master-auth.h"
#include "master-service.h"
#include "master-interface.h"
#include "client-common.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;
bool closing_down;
int anvil_fd = -1;
const struct login_settings *global_login_settings;
static bool ssl_connections = FALSE;
{
const struct login_settings *set;
unsigned int local_port;
int fd_ssl;
local_port = 0;
}
} else {
if (fd_ssl == -1) {
pool_unref(&pool);
return;
}
}
}
{
if (connected)
}
static int anvil_connect(void)
{
#define ANVIL_HANDSHAKE "VERSION\tanvil\t1\t0\n"
int i = 0, fd;
i_fatal("net_connect_unix(anvil) failed: %m");
sleep(1);
}
i_fatal("write(anvil) failed: %m");
return fd;
}
static void main_preinit(void)
{
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)
*/
anvil_fd = anvil_connect();
}
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)
if (anvil_fd != -1) {
i_error("close(anvil) failed: %m");
}
}
{
const char *getopt_str;
int c;
//FIXME:is_inetd = getenv("DOVECOT_MASTER") == NULL;
switch (c) {
case 'D':
break;
case 'S':
break;
default:
c, optarg))
break;
}
}
#if 0
if (is_inetd) {
/* running from inetd. create master process before
dropping privileges. */
}
#endif
/* main_preinit() needs to know the client limit, which is set by
this. so call it first. */
main_preinit();
main_init();
main_deinit();
return 0;
}