main.c revision b725e5503d72a29a3eb18f93c1cbe597c4c31dcd
/* Copyright (C) 2002-2003 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 "process-title.h"
#include "randgen.h"
#include "module-dir.h"
#include "var-expand.h"
#include "dict-client.h"
#include "mail-storage.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#define IS_STANDALONE() \
struct client_workaround_list {
const char *name;
enum client_workarounds num;
};
struct client_workaround_list client_workaround_list[] = {
{ "outlook-no-nuls", WORKAROUND_OUTLOOK_NO_NULS },
{ "oe-ns-eoh", WORKAROUND_OE_NS_EOH },
{ NULL, 0 }
};
enum client_workarounds client_workarounds = 0;
bool enable_last_command = FALSE;
bool no_flag_updates = FALSE;
bool reuse_xuidl = FALSE;
bool lock_session = FALSE;
const char *uidl_format, *logout_format;
enum uidl_keys uidl_keymask;
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
}
{
}
static void parse_workarounds(void)
{
struct client_workaround_list *list;
return;
break;
}
}
}
}
{
switch (var_get_key(++format)) {
case 'v':
mask |= UIDL_UIDVALIDITY;
break;
case 'u':
break;
case 'm':
break;
case 'f':
mask |= UIDL_FILE_NAME;
break;
}
}
}
return mask;
}
static void open_logfile(void)
{
const char *user;
return;
}
/* quite a long user name, cut it */
}
} else {
/* log to file or stderr */
}
}
static void drop_privileges(void)
{
/* Log file or syslog opening probably requires roots */
open_logfile();
chrooting. */
random_init();
}
static int main_init(void)
{
enum mail_storage_flags flags;
struct mail_storage *storage;
const char *mail;
i_fatal("USER environment missing");
i_info("Effective uid=%s, gid=%s",
}
/* If master dies, the log fd gets closed and we'll quit */
}
clients_init();
else {
i_fatal("MODULE_LIST given but MODULE_DIR was not");
}
/* support also maildir-specific environment */
}
i_fatal("pop3_uidl_format setting is missing from config file");
if (logout_format == NULL)
logout_format = "top=%t/%T, retr=%r/%R, del=%d/%m, size=%s";
if (uidl_keymask == 0)
i_fatal("pop3_uidl_format setting doesn't contain any "
"%% variables.");
flags, lock_method);
/* failed */
else {
const char *home;
i_fatal("MAIL environment missing and "
"autodetection failed (home %s)", home);
}
}
if (hook_mail_storage_created != NULL)
}
static void main_deinit(void)
{
closelog();
}
{
#ifdef DEBUG
#endif
if (IS_STANDALONE() && getuid() == 0 &&
printf("-ERR pop3 binary must not be started from "
"inetd, use pop3-login instead.\n");
return 1;
}
/* NOTE: we start rooted, so keep the code minimal until
restrict_access_by_env() is called */
lib_init();
if (main_init())
main_deinit();
lib_deinit();
return 0;
}