master-service-settings.c revision 3c296d819c54e21ce05c3d2eeeedc79be42ac593
/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "abspath.h"
#include "istream.h"
#include "write-full.h"
#include "str.h"
#include "eacces-error.h"
#include "env-util.h"
#include "execv-const.h"
#include "settings-parser.h"
#include "master-service-private.h"
#include "master-service-settings.h"
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#define CONFIG_READ_TIMEOUT_SECS 10
#define CONFIG_HANDSHAKE "VERSION\tconfig\t2\t0\n"
static bool
static const struct setting_define master_service_setting_defines[] = {
};
static const struct master_service_settings master_service_default_settings = {
.log_path = "syslog",
.info_log_path = "",
.debug_log_path = "",
.syslog_facility = "mail",
.version_ignore = FALSE,
.shutdown_clients = TRUE,
};
const struct setting_parser_info master_service_setting_parser_info = {
.module_name = "master",
.struct_size = sizeof(struct master_service_settings),
};
/* <settings checks> */
static bool
const char **error_r ATTR_UNUSED)
{
/* default to syslog logging */
}
return TRUE;
}
/* </settings checks> */
static void ATTR_NORETURN
const struct master_service_settings_input *input)
{
unsigned int i, argv_max_count;
(void)t_binary_abspath(&binary_path);
if (input->preserve_home)
if (input->preserve_user)
}
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 (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;
}
}
static int
const struct master_service_settings_input *input,
{
const char *path;
int fd;
/* use the already opened config socket */
return fd;
}
/* 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)
{
}
static int
{
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 {
}
}
(void)array_append_space(&services);
}
} T_END;
return 0;
}
const struct master_service_settings_input *input,
struct master_service_settings_output *output_r,
const char **error_r)
{
const struct setting_parser_info *tmp_root;
struct setting_parser_context *parser;
void **sets;
unsigned int i;
if (fd == -1)
return -1;
return -1;
}
}
} else {
}
}
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);
}
return -1;
}
else
}
if (settings_parse_environ(parser) < 0) {
return -1;
}
}
error_r) < 0)
return -1;
}
return -1;
}
/* running standalone. we want to ignore plugin versions. */
}
/* 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)
{
struct master_service_settings_input input;
struct master_service_settings_output output;
}
{
return pool;
}
const struct master_service_settings *
{
void **sets;
return sets[0];
}
{
}
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;
}