master-settings.c revision 0a409928c0b7172ad3a3cc029e3725e6637fc7d6
/* 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;
struct socket_settings *socket;
struct auth_socket_settings *auth_socket;
struct auth_passdb_settings *auth_passdb;
struct auth_userdb_settings *auth_userdb;
struct namespace_settings *namespace;
int level;
};
static struct setting_def setting_defs[] = {
/* common */
/* general */
/* login */
/* mail */
/* imap */
/* pop3 */
{ 0, NULL, 0 }
};
static struct setting_def auth_setting_defs[] = {
{ 0, NULL, 0 }
};
static struct setting_def socket_setting_defs[] = {
{ 0, NULL, 0 }
};
static struct setting_def auth_socket_setting_defs[] = {
{ 0, NULL, 0 }
};
static struct setting_def auth_passdb_setting_defs[] = {
{ 0, NULL, 0 }
};
static struct setting_def auth_userdb_setting_defs[] = {
{ 0, NULL, 0 }
};
static struct setting_def namespace_setting_defs[] = {
{ 0, NULL, 0 }
};
struct settings default_settings = {
/* common */
/* general */
/* login */
/* mail */
MEMBER(last_valid_uid) 0,
MEMBER(last_valid_gid) 0,
#ifdef MMAP_CONFLICTS_WRITE
#else
#endif
/* imap */
/* pop3 */
/* .. */
};
struct auth_settings default_auth_settings = {
MEMBER(cache_size) 0,
/* .. */
};
{
}
}
{
return FALSE;
}
i_error("All login process users must belong to same group "
return FALSE;
}
return TRUE;
}
{
return FALSE;
}
i_error("login_user %s (uid %s) must not be same as auth_user",
return FALSE;
}
i_error("Can't use auth executable %s: %m",
return FALSE;
}
i_error("Can't access auth chroot directory %s: %m",
return FALSE;
}
if (auth->ssl_require_client_cert) {
/* if we require valid cert, make sure we also ask for it */
}
return TRUE;
}
{
const char *name;
i_error("Namespace '%s': "
"Hierarchy separator must be only one character long",
name);
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;
}
{
struct auth_settings *auth;
struct server_settings *server;
return TRUE;
}
}
return FALSE;
}
{
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_fatal("Can't use SSL CA file %s: %m",
set->ssl_ca_file);
}
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;
}
}
#else
if (!set->ssl_disable) {
i_error("SSL support not compiled in but ssl_disable=no");
return FALSE;
}
#endif
/* fix relative paths */
deleted. */
i_warning("Corrected permissions for base directory %s",
}
if (!settings_have_connect_sockets(set)) {
/* 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_error("unlink_directory() failed for %s: %m",
return FALSE;
}
i_warning("Corrected permissions for login directory "
}
}
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;
}
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;
}
}
}
static struct auth_passdb_settings *
{
return as;
}
static struct auth_userdb_settings *
{
return as;
}
static struct auth_socket_settings *
{
return as;
}
static struct auth_socket_settings *
const char **errormsg)
{
*errormsg = "Unknown auth socket type";
return NULL;
}
*errormsg = "With connect auth socket no other sockets "
"can be used in same auth section";
return NULL;
}
}
static struct namespace_settings *
{
return ns;
}
static struct namespace_settings *
const char **errormsg)
{
*errormsg = "Unknown namespace type";
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;
return parse_setting_from_defs(settings_pool,
}
return error;
case SETTINGS_TYPE_AUTH:
key += 5;
return parse_setting_from_defs(settings_pool,
return parse_setting_from_defs(settings_pool,
return parse_setting_from_defs(settings_pool,
case SETTINGS_TYPE_NAMESPACE:
return parse_setting_from_defs(settings_pool,
case SETTINGS_TYPE_SOCKET:
return parse_setting_from_defs(settings_pool,
}
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 */
break;
default:
break;
}
} 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;
}
}
}
return TRUE;
}
return TRUE;
}
return TRUE;
}
return TRUE;
}
}
*errormsg = "Namespace section not allowed here";
return FALSE;
}
errormsg);
}
*errormsg = "Unknown section type";
return FALSE;
}
{
struct settings_parse_ctx ctx;
struct auth_settings *auth;
struct namespace_settings *ns;
create_new_server("default",
return FALSE;
i_error("Missing '}'");
return FALSE;
}
/* If server sections were defined, skip the root */
i_error("No protocols given in configuration file");
return FALSE;
}
else {
return FALSE;
}
else {
return FALSE;
}
else
} else {
i_error("Missing auth section for server %s",
return FALSE;
}
if (!nochecks) {
if (!auth_settings_verify(auth))
return FALSE;
}
if (!namespace_settings_verify(ns))
return FALSE;
}
}
}
}
/* settings ok, swap them */
return TRUE;
}
void master_settings_init(void)
{
}
void master_settings_deinit(void)
{
}