main.c revision a9d103504e67fe02abfc726fa68ebe384284a90e
/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "ioloop.h"
#include "file-lock.h"
#include "network.h"
#include "lib-signals.h"
#include "restrict-access.h"
#include "fd-close-on-exec.h"
#include "base64.h"
#include "buffer.h"
#include "istream.h"
#include "process-title.h"
#include "module-dir.h"
#include "var-expand.h"
#include "dict.h"
#include "mail-storage.h"
#include "mail-namespace.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;
};
static 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 :) */
}
{
/* the log fd is closed, don't die when trying to log later */
}
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;
}
else {
/* quite a long user name, cut it */
}
}
} else {
/* log to file or stderr */
}
}
static void drop_privileges(void)
{
const char *version;
i_fatal("Dovecot version mismatch: "
"(if you don't care, set version_ignore=yes)", version);
}
/* Log file or syslog opening probably requires roots */
open_logfile();
/* Load the plugins before chrooting. Their init() is called later. */
if (plugin_dir == NULL)
}
}
static bool main_init(void)
{
const char *str;
i_fatal("USER environment missing");
const char *home;
i_info("Effective uid=%s, gid=%s, home=%s",
}
/* If master dies, the log fd gets closed and we'll quit */
}
clients_init();
uidl_format = "%08Xu%08Xv";
if (logout_format == NULL)
logout_format = "top=%t/%p, retr=%r/%b, del=%d/%m, size=%s";
if (uidl_keymask == 0)
i_fatal("pop3_uidl_format setting doesn't contain any "
"%% variables.");
if (mail_namespaces_init(user) < 0)
i_fatal("Namespace initialization failed");
return FALSE;
if (!IS_STANDALONE())
i_panic("Couldn't add client input to stream");
}
} T_END;
return ret;
}
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();
ioloop = io_loop_create();
if (main_init())
main_deinit();
lib_deinit();
return 0;
}