master-service.c revision 6d2b3ce2c6ef62334985ece4f0ab8b154e0e9560
/* Copyright (C) 2005-2009 Timo Sirainen */
#include "lib.h"
#include "lib-signals.h"
#include "ioloop.h"
#include "env-util.h"
#include "home-expand.h"
#include "restrict-access.h"
#include "fd-close-on-exec.h"
#include "syslog-util.h"
#include "master-service-private.h"
#include "master-service-settings.h"
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#define MASTER_CONFIG_FILE_ENV "CONFIG_FILE"
/* getenv(MASTER_DOVECOT_VERSION_ENV) provides master's version number */
#define MASTER_DOVECOT_VERSION_ENV "DOVECOT_VERSION"
const char *master_service_getopt_string(void)
{
return "c:Lk";
}
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
i_warning("Killed with signal %d (by pid=%s uid=%s code=%s)",
}
}
{
i_fatal("Dovecot version mismatch: "
"(if you don't care, set version_ignore=yes)",
}
}
struct master_service *
{
struct master_service *service;
/* NOTE: we start rooted, so keep the code minimal until
restrict_access_by_env() is called */
lib_init();
/* Set a logging prefix temporarily. This will be ignored once the log
is properly initialized */
if ((flags & MASTER_SERVICE_FLAG_STANDALONE) == 0)
else
/* set up some kind of logging until we know exactly how and where
we want to log */
} else {
}
/* set default signal handlers */
return service;
}
{
const char *path;
return;
}
/* logging via master process */
return;
}
/* log to syslog */
int facility;
&facility))
} else {
/* log to file or stderr */
}
if (*path != '\0')
}
{
switch (opt) {
case 'c':
break;
case 'k':
break;
case 'L':
break;
default:
return FALSE;
}
return TRUE;
}
void master_service_env_clean(bool preserve_home)
{
/* Note that if the original environment was set with env_put(), the
environment strings will be invalid after env_clean(). That's why
we t_strconcat() them above. */
env_clean();
}
{
return service->config_path;
}
{
return service->version_string;
}
{
}
{
}
{
lib_deinit();
}