master-settings.c revision 54a6d29d96e243cd5c84892384c18c9830359ada
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "istream.h"
#include "safe-mkdir.h"
#include "unlink-directory.h"
#include "settings.h"
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <pwd.h>
enum settings_type {
};
struct settings_parse_ctx {
enum mail_protocol protocol;
struct auth_settings *auth;
int level;
};
static struct setting_def setting_defs[] = {
/* common */
/* general */
/* login */
/* mail */
/* imap */
{ 0, NULL, 0 }
};
static struct setting_def auth_setting_defs[] = {
{ 0, NULL, 0 }
};
struct settings default_settings = {
/* common */
/* general */
/* login */
/* mail */
MEMBER(last_valid_uid) 0,
MEMBER(last_valid_gid) 0,
/* imap */
/* .. */
};
struct auth_settings default_auth_settings = {
};
{
}
}
{
return FALSE;
}
i_error("All login process users must belong to same group "
return FALSE;
}
return TRUE;
}
{
return FALSE;
}
i_error("Can't access auth chroot directory %s: %m",
return FALSE;
}
return TRUE;
}
static const char *get_directory(const char *path)
{
char *str, *p;
if (p == NULL)
return ".";
else {
*p = '\0';
return str;
}
}
{
return FALSE;
} else {
return FALSE;
}
return TRUE;
}
{
const char *const *str;
const char *dir;
if (!get_login_uid(set))
return FALSE;
i_error("Can't use mail executable %s: %m",
return FALSE;
}
#ifdef HAVE_MODULES
if (set->mail_use_modules &&
i_error("Can't access mail module directory: %s: %m",
set->mail_modules);
return FALSE;
}
#else
if (set->mail_use_modules) {
i_warning("Module support wasn't built into Dovecot, "
"ignoring mail_use_modules setting");
}
#endif
return FALSE;
}
}
i_error("Can't write to info log directory %s: %m",
dir);
return FALSE;
}
}
#ifdef HAVE_SSL
if (!set->ssl_disable) {
i_error("Can't use SSL certificate %s: %m",
set->ssl_cert_file);
return FALSE;
}
i_error("Can't use SSL key file %s: %m",
set->ssl_key_file);
return FALSE;
}
}
#endif
/* fix relative paths */
deleted. */
i_warning("Corrected permissions for base directory %s",
}
/* wipe out contents of login directory, if it exists */
return FALSE;
}
i_warning("Corrected permissions for login directory %s",
}
i_error("max_mail_processes must be at least 1");
return FALSE;
}
if (set->last_valid_uid != 0 &&
i_error("first_valid_uid can't be larger than last_valid_uid");
return FALSE;
}
if (set->last_valid_gid != 0 &&
i_error("first_valid_gid can't be larger than last_valid_gid");
return FALSE;
}
dotlock_got = TRUE;
else {
return FALSE;
}
}
#ifndef HAVE_FLOCK
i_error("mbox_locks: Only flock selected, "
"and flock() isn't supported in this system");
return FALSE;
}
#endif
i_error("mbox_locks: No mbox locking methods selected");
return FALSE;
}
i_warning("mbox_locks: Only dotlock selected, forcing "
"mbox_read_dotlock = yes to avoid corruption.");
}
i_error("Can't use login executable %s: %m",
return FALSE;
}
i_error("login_processes_count must be at least 1");
return FALSE;
}
i_error("login_max_logging_users must be at least 1");
return FALSE;
}
return TRUE;
}
static struct auth_settings *
{
struct auth_settings *auth;
/* copy defaults */
return auth;
}
static struct auth_settings *
const char **errormsg)
{
struct auth_settings *auth;
*errormsg = "Authentication process name must not contain '/'";
return NULL;
}
*errormsg = "Authentication process already exists "
"with the same name";
return NULL;
}
}
}
void *context)
{
const char *error;
/* backwards compatibility */
}
i_warning("Ignoring deprecated 'login' section handling. "
"Some settings may have been read incorrectly.");
return NULL;
}
case SETTINGS_TYPE_ROOT:
case SETTINGS_TYPE_SERVER:
}
}
return NULL;
/* backwards compatibility */
return "Authentication process name "
"not defined yet";
}
return parse_setting_from_defs(settings_pool,
}
return error;
case SETTINGS_TYPE_AUTH:
}
i_unreached();
}
static struct server_settings *
create_new_server(const char *name,
struct settings *imap_defaults,
struct settings *pop3_defaults)
{
struct server_settings *server;
return server;
}
const char **errormsg)
{
struct server_settings *server;
/* section closing */
} else {
}
return TRUE;
}
*errormsg = "Server section not allowed here";
return FALSE;
}
return TRUE;
}
*errormsg = "Protocol section not allowed here";
return FALSE;
}
else {
*errormsg = "Unknown protocol name";
return FALSE;
}
return TRUE;
}
*errormsg = "Auth section not allowed here";
return FALSE;
}
}
*errormsg = "Unknown section type";
return FALSE;
}
int master_settings_read(const char *path)
{
struct settings_parse_ctx ctx;
struct auth_settings *auth;
create_new_server("default",
return FALSE;
i_error("Missing '}'");
return FALSE;
}
/* If server sections were defined, skip the root */
else {
return FALSE;
}
else {
return FALSE;
}
else
} else {
if (!auth_settings_verify(auth))
return FALSE;
}
}
}
/* settings ok, swap them */
return TRUE;
}
void master_settings_init(void)
{
}
void master_settings_deinit(void)
{
}