main.c revision a7024a121041f5498d35f36ef56078acbf7a0677
/* 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 "auth.h"
#include "cookie.h"
#include "login-connection.h"
#include "userinfo.h"
#include "master.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)
{
auth_init();
cookies_init();
/* initialize master last - it sends the "we're ok" notification */
master_init();
}
static void main_deinit(void)
{
if (lib_signal_kill != 0)
auth_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;
}