main.c revision 0b56ba659328b7186b74c764702ecbe403c98839
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "network.h"
#include "lib-signals.h"
#include "restrict-access.h"
#include "fd-close-on-exec.h"
#include "randgen.h"
#include "mech.h"
#include "userdb.h"
#include "passdb.h"
#include "master-connection.h"
#include "login-connection.h"
#include <stdlib.h>
#include <syslog.h>
{
}
{
int fd;
if (fd < 0) {
if (fd < -1)
i_fatal("accept() failed: %m");
} else {
(void)login_connection_create(fd);
}
}
static void open_logfile(void)
{
else {
/* log to file or stderr */
}
}
static void drop_privileges(void)
{
/* Log file or syslog opening probably requires roots */
open_logfile();
random_init();
/* Password lookups etc. may require roots, allow it. */
}
static void main_init(void)
{
mech_init();
userdb_init();
passdb_init();
/* initialize master last - it sends the "we're ok" notification */
}
static void main_deinit(void)
{
if (lib_signal_kill != 0)
mech_deinit();
closelog();
}
{
#ifdef DEBUG
#endif
/* NOTE: we start rooted, so keep the code minimal until
restrict_access_by_env() is called */
lib_init();
main_init();
main_deinit();
lib_deinit();
return 0;
}