master-settings.c revision 7ecd5a8ca528e7cf99f513c56be311b15a0bd988
/* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "array.h"
#include "env-util.h"
#include "istream.h"
#include "network.h"
#include "str.h"
#include "mkdir-parents.h"
#include "safe-mkdir.h"
#include "settings-parser.h"
#include "master-settings.h"
#include <stddef.h>
#include <dirent.h>
#include <unistd.h>
const char **error_r);
extern const struct setting_parser_info service_setting_parser_info;
static const struct setting_define file_listener_setting_defines[] = {
};
static const struct file_listener_settings file_listener_default_settings = {
.path = "",
.mode = 0600,
.user = "",
.group = "",
};
static const struct setting_parser_info file_listener_setting_parser_info = {
.struct_size = sizeof(struct file_listener_settings),
};
static const struct setting_define inet_listener_setting_defines[] = {
};
static const struct inet_listener_settings inet_listener_default_settings = {
.address = "",
.port = 0,
};
static const struct setting_parser_info inet_listener_setting_parser_info = {
.struct_size = sizeof(struct inet_listener_settings),
};
static const struct setting_define service_setting_defines[] = {
};
static const struct service_settings service_default_settings = {
.name = "",
.protocol = "",
.type = "",
.executable = "",
.user = "",
.group = "",
.privileged_group = "",
.extra_groups = "",
.chroot = "",
.process_min_avail = 0,
.process_limit = -1U,
.client_limit = 0,
.service_count = 0,
};
const struct setting_parser_info service_setting_parser_info = {
.struct_size = sizeof(struct service_settings),
};
static const struct setting_define master_setting_defines[] = {
};
static const struct master_settings master_default_settings = {
.base_dir = PKG_RUNDIR,
.protocols = "imap pop3 lmtp",
.listen = "*, ::",
.ssl = "yes:no:required",
.default_process_limit = 100,
.default_client_limit = 1000,
.version_ignore = FALSE,
.mail_debug = FALSE,
.auth_debug = FALSE,
.first_valid_uid = 500,
.last_valid_uid = 0,
.first_valid_gid = 1,
.last_valid_gid = 0,
#ifndef CONFIG_BINARY
#else
.services = { { &config_all_services_buf,
sizeof(struct service_settings *) } },
#endif
};
const struct setting_parser_info master_setting_parser_info = {
.module_name = "master",
.struct_size = sizeof(struct master_settings),
};
/* <settings checks> */
{
struct file_listener_settings *const *sets;
if (!array_is_created(l))
return;
array_foreach(l, sets) {
}
}
}
{
struct inet_listener_settings *const *sets;
const char *str;
if (!array_is_created(l))
return;
array_foreach(l, sets) {
}
}
const char **error_r)
{
else {
return FALSE;
}
return TRUE;
}
{
const char *p;
return;
}
static bool
{
struct service_settings *const *services;
const char *const *strings;
unsigned int i, j, count, process_limit;
if (set->last_valid_uid != 0 &&
*error_r = "first_valid_uid can't be larger than last_valid_uid";
return FALSE;
}
if (set->last_valid_gid != 0 &&
*error_r = "first_valid_gid can't be larger than last_valid_gid";
return FALSE;
}
/* check that we have at least one service. the actual service
structure validity is checked later while creating them. */
*error_r = "No services defined";
return FALSE;
}
for (i = 0; i < count; i++) {
"Service #%d is missing name", i);
return FALSE;
}
return FALSE;
for (j = 0; j < i; j++) {
"Duplicate service name: %s",
return FALSE;
}
}
}
for (i = 0; i < count; i++) {
}
}
if (service->drop_priv_before_exec &&
"drop_priv_before_exec=yes can't be "
return FALSE;
}
if (process_limit == 0)
"process_min_avail is higher than process_limit",
return FALSE;
}
}
/* check for duplicate listeners */
for (i = 1; i < count; i++) {
strings[i]);
return FALSE;
}
}
return TRUE;
}
/* </settings checks> */
static bool
{
struct service_settings *const *services;
const char *error;
if (service->login_dump_core)
}
}
return cores;
}
static bool
const char *dir)
{
struct service_settings *const *services;
struct file_listener_settings *const *uls;
struct file_listener_settings *u = *uls;
return TRUE;
}
}
}
return FALSE;
}
{
unsigned int prefix_len;
return;
}
continue;
continue;
str_truncate(str, 0);
continue;
}
continue;
/* try to avoid unlinking sockets if someone's already
listening in them. do this only at startup, because
when SIGHUPing a child process might catch the new
connection before it notices that it's supposed
to die. null_fd == -1 check is a bit kludgy, but works.. */
if (null_fd == -1) {
i_fatal("Dovecot is already running? "
"Socket already exists: %s",
}
}
}
}
{
deleted. */
return FALSE;
}
/* allow base_dir to be a symlink, so don't use lstat() */
return FALSE;
}
return FALSE;
}
/* FIXME: backwards compatibility: v1.2 was creating
base_dir with 0777 permissions.. */
i_warning("Fixing permissions of %s to be world-readable",
}
/* Make sure our permanent state directory exists */
return FALSE;
}
/* we are not using external authentication, so make sure the
login directory exists with correct permissions and it's
empty. with external auth we wouldn't want to delete
existing sockets or break the permissions required by the
auth server. */
i_warning("Corrected permissions for login directory "
"%s", login_dir);
}
} else {
/* still make sure that login directory exists */
return FALSE;
}
}
i_warning("Corrected permissions for empty directory "
"%s", empty_dir);
}
return TRUE;
}