/* Copyright (c) 2005-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "event-filter.h"
#include "path-util.h"
#include "istream.h"
#include "write-full.h"
#include "str.h"
#include "strescape.h"
#include "syslog-util.h"
#include "eacces-error.h"
#include "env-util.h"
#include "execv-const.h"
#include "settings-parser.h"
#include "stats-client.h"
#include "master-service-private.h"
#include "master-service-ssl-settings.h"
#include "master-service-settings.h"
#include <stddef.h>
#include <unistd.h>
#include <time.h>
static bool
};
/* <settings checks> */
#ifdef HAVE_SYSTEMD
#else
#endif
#ifdef DEBUG
#else
#endif
/* </settings checks> */
.base_dir = PKG_RUNDIR,
.log_path = "syslog",
.info_log_path = "",
.debug_log_path = "",
.log_debug = "",
.syslog_facility = "mail",
.stats_writer_socket_path = "stats-writer",
.version_ignore = FALSE,
.shutdown_clients = TRUE,
.haproxy_trusted_networks = "",
.haproxy_timeout = 3
};
.module_name = "master",
.struct_size = sizeof(struct master_service_settings),
};
/* <settings checks> */
const char **error_r)
{
};
/* FIXME: we should support more complicated filters */
categories[0] = args[i];
}
return 0;
}
static bool
const char **error_r)
{
int facility;
/* default to syslog logging */
}
return FALSE;
}
const char *error;
return FALSE;
}
#ifndef CONFIG_BINARY
#endif
return TRUE;
}
/* </settings checks> */
static void ATTR_NORETURN
const struct master_service_settings_input *input)
{
unsigned int i, argv_max_count;
}
if (input->preserve_home)
master_service_import_environment("HOME");
if (input->preserve_user)
master_service_import_environment("USER");
master_service_import_environment("LOG_STDERR_TIMESTAMP");
/* doveconf empties the environment before exec()ing us back
if DOVECOT_PRESERVE_ENVS is set, so make sure it is. */
} else {
/* make sure doveconf doesn't remove any environment */
}
if (input->use_sysexits)
env_put("USE_SYSEXITS=1");
/* @UNSAFE */
i = 0;
conf_argv[i++] = DOVECOT_CONFIG_BIN_PATH;
conf_argv[i++] = "-f";
}
conf_argv[i++] = "-c";
conf_argv[i++] = "-m";
if (service->want_ssl_settings) {
conf_argv[i++] = "-m";
conf_argv[i++] = "ssl";
}
}
if (input->parse_full_config)
conf_argv[i++] = "-p";
conf_argv[i++] = "-e";
conf_argv[i++] = binary_path;
i_assert(i < argv_max_count);
}
static void
const struct master_service_settings_input *input)
{
const char *path;
if (input->never_exec)
return;
}
errno = saved_errno;
}
static int
const struct master_service_settings_input *input,
{
const char *path;
int fd;
/* use the already opened config socket */
return fd;
}
if (!service->config_path_from_master &&
/* first try to connect to the default config socket.
configuration may contain secrets, so in default config
this fails because the socket is 0600. it's useful for
developers though. :) */
if (fd >= 0) {
return fd;
}
/* fallback to executing doveconf */
}
return -1;
}
/* it's not an UNIX socket, don't even try to connect */
fd = -1;
} else {
}
if (fd < 0) {
path);
return -1;
}
return fd;
}
static void
const struct master_service_settings_input *input)
{
if (service->want_ssl_settings)
}
}
static int
const struct master_service_settings_input *input,
{
int ret;
T_BEGIN {
} T_END;
if (ret < 0) {
return -1;
}
return 0;
}
static int
struct setting_parser_context *parser,
const char **error_r)
{
const char *const *overrides;
unsigned int i, count;
for (i = 0; i < count; i++) {
"Invalid -o parameter %s: %s", overrides[i],
return -1;
}
}
return 0;
}
static int
const struct master_service_settings_input *input,
struct master_service_settings_output *output_r,
const char **error_r)
{
const char *line;
break;
}
if (ret <= 0) {
if (ret == 0)
return 1;
return -1;
}
T_BEGIN {
}
}
}
} T_END;
return 0;
}
{
int fd;
/* we'll get here before command line parameters have been parsed,
so -O, -c and -i parameters haven't been handled yet at this point.
this means we could end up opening config socket connection
unnecessarily, but this isn't a problem. we'll just have to
ignore it later on. (unfortunately there isn't a master_service_*()
call where this function would be better called.) */
return;
if (fd != -1)
}
const struct master_service_settings_input *input,
struct master_service_settings_output *output_r,
const char **error_r)
{
void **sets;
unsigned int i;
for (;;) {
if (fd == -1) {
return -1;
}
break;
i_close_fd(&fd);
if (!retry) {
return -1;
}
/* config process died, retry connecting */
}
}
} else {
}
if (service->want_ssl_settings) {
}
}
if (fd != -1) {
do {
if (ret == 0) {
istream);
if (ret < 0)
}
alarm(0);
if (ret <= 0)
break;
/* most likely timed out, but just in case some other
signal was delivered early check if we need to
continue */
if (ret != 0) {
if (ret > 0) {
"Timeout reading config from %s", path);
}
i_close_fd(&fd);
return -1;
}
else
i_close_fd(&fd);
} else {
}
if (settings_parse_environ(parser) < 0) {
return -1;
}
}
error_r) < 0) {
return -1;
}
}
return -1;
}
/* running standalone. we want to ignore plugin versions. */
}
/* When running standalone (e.g. doveadm) try to connect to the
stats socket, but don't log an error if it's not running.
It may be intentional. */
bool silent_notfound_errors =
}
/* if we change any settings afterwards, they're in expanded form.
especially all settings from userdb are already expanded. */
return 0;
}
const struct setting_parser_info **roots,
const char **error_r)
{
}
{
return pool;
}
const struct master_service_settings *
{
void **sets;
return sets[0];
}
{
}
const struct setting_parser_context *set_parser)
{
}
struct setting_parser_context *
{
return service->set_parser;
}
{
}
const char *key)
{
bool ret;
return FALSE;
T_BEGIN {
okey);
} T_END;
if (ret)
return TRUE;
}
return FALSE;
}