/* Copyright (c) 2005-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "hash-format.h"
#include "var-expand.h"
#include "unichar.h"
#include "hostpid.h"
#include "settings-parser.h"
#include "message-address.h"
#include "mail-index.h"
#include "mail-user.h"
#include "mail-namespace.h"
#include "mail-storage-private.h"
#include "mail-storage-settings.h"
#include <stddef.h>
static bool mail_storage_settings_expand_check(void *_set, pool_t pool ATTR_UNUSED, const char **error_r);
};
.mail_location = "",
.mail_attachment_fs = "sis posix",
.mail_attachment_dir = "",
.mail_attachment_hash = "%{sha1}",
.mail_attribute_dict = "",
.mail_prefetch_count = 0,
.mail_cache_fields = "flags",
.mail_always_cache_fields = "",
.mail_never_cache_fields = "imap.envelope",
.mail_server_comment = "",
.mail_server_admin = "",
.mailbox_idle_check_interval = 30,
.mail_max_keyword_length = 50,
.mail_max_lock_timeout = 0,
.mail_sort_max_read_count = 0,
.mail_save_crlf = FALSE,
.mail_fsync = "optimized:never:always",
.mmap_disable = FALSE,
.dotlock_use_excl = TRUE,
.mail_nfs_index = FALSE,
.mail_debug = FALSE,
.lock_method = "fcntl:flock:dotlock",
.pop3_uidl_format = "%08Xu%08Xv",
.postmaster_address = "postmaster@%d",
.hostname = "",
.recipient_delimiter = "+",
.ssl_client_ca_dir = "",
.ssl_client_ca_file = "",
.ssl_crypto_device = ""
};
.module_name = "mail",
.struct_size = sizeof(struct mail_storage_settings),
#ifndef CONFIG_BINARY
#endif
};
};
.name = "",
.special_use = "",
.driver = "",
.comment = "",
.autoexpunge = 0,
};
.struct_size = sizeof(struct mailbox_settings),
};
{ SET_DEFLIST_UNIQUE, name, \
};
.name = "",
.type = "private:shared:public",
.separator = "",
.prefix = "",
.location = "",
.list = "yes:no:children",
.subscriptions = TRUE,
.order = 0,
};
.struct_size = sizeof(struct mail_namespace_settings),
};
{ SET_DEFLIST_UNIQUE, name, \
};
.base_dir = PKG_RUNDIR,
.auth_socket_path = "auth-userdb",
.mail_temp_dir = "/tmp",
.mail_uid = "",
.mail_gid = "",
.mail_home = "",
.mail_chroot = "",
.mail_access_groups = "",
.mail_privileged_group = "",
.valid_chroot_dirs = "",
.first_valid_uid = 500,
.last_valid_uid = 0,
.first_valid_gid = 1,
.last_valid_gid = 0,
.mail_plugins = "",
.mail_log_prefix = "%s(%u)<%{pid}><%{session}>: ",
.namespaces = ARRAY_INIT,
};
.module_name = "mail",
.struct_size = sizeof(struct mail_user_settings),
};
const void *
const struct mail_user_settings *set,
const char *driver)
{
const void *dset;
i_panic("Default settings not found for storage driver %s",
driver);
}
return dset;
}
const struct mail_storage_settings *
{
}
struct mail_storage *storage)
{
}
const struct dynamic_settings_parser *
{
unsigned int i, j, count;
for (i = 0, j = 1; i < count; i++) {
continue;
j++;
}
return parsers;
}
static void
{
}
/* <settings checks> */
const char **error_r)
{
const char *p, *error;
bool uidl_format_ok;
char c;
if (set->mailbox_idle_check_interval == 0) {
*error_r = "mailbox_idle_check_interval must not be 0";
return FALSE;
}
else {
set->mail_fsync);
return FALSE;
}
*error_r = "mail_nfs_index=yes requires mmap_disable=yes";
return FALSE;
}
if (set->mail_nfs_index &&
*error_r = "mail_nfs_index=yes requires mail_fsync=always";
return FALSE;
}
&set->parsed_lock_method)) {
set->lock_method);
return FALSE;
}
*error_r = "mail_cache_compress_delete_percentage can't be over 100";
return FALSE;
}
if (p[0] != '%' || p[1] == '\0')
continue;
c = var_get_key(++p);
switch (c) {
case 'v':
case 'u':
case 'm':
case 'f':
case 'g':
break;
case '%':
break;
default:
"Unknown pop3_uidl_format variable: %%%c", c);
return FALSE;
}
}
if (!uidl_format_ok) {
*error_r = "pop3_uidl_format setting doesn't contain any "
"%% variables.";
return FALSE;
}
*error_r = "mail_attachment_hash setting "
"must not contain '/' characters";
return FALSE;
}
return FALSE;
}
*error_r = "mail_attachment_hash setting "
"must not contain '-' characters";
return FALSE;
}
#ifndef CONFIG_BINARY
"ssl_client_ca_dir: access(%s) failed: %m",
return FALSE;
}
#endif
// FIXME: check set->mail_server_admin syntax (RFC 5464, Section 6.2.2)
#ifndef CONFIG_BINARY
/* check for valid looking fqdn in hostname */
*error_r = "postmaster_address setting not given";
return FALSE;
}
}
#endif
/* parse mail_attachment_indicator_options */
const char *const *options =
}
options++;
}
}
return TRUE;
}
#ifndef CONFIG_BINARY
const struct message_address **addr_r,
const char **error_r)
{
(const unsigned char *)address,
"invalid address `%s' specified for the "
"postmaster_address setting", address);
return FALSE;
}
*error_r = "more than one address specified for the "
"postmaster_address setting";
return FALSE;
}
return TRUE;
}
{
const char *error;
/* Parse if possible. Perform error handling later. */
&error);
return TRUE;
}
#endif
const char **error_r)
{
const char *name;
unsigned int i, count;
"Hierarchy separator must be only one character long",
name);
return FALSE;
}
if (!uni_utf8_str_is_valid(name)) {
name);
return FALSE;
}
&count);
} else {
namespaces = NULL;
count = 0;
}
for (i = 0; i < count; i++) {
break;
}
if (i == count) {
"Namespace '%s': alias_for points to "
return FALSE;
}
"Namespace '%s': alias_for chaining isn't "
namespaces[i]->alias_for);
return FALSE;
}
}
return TRUE;
}
{
if (name[0] != '\\')
return FALSE;
name++;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return FALSE;
}
static bool
const char **error_r)
{
unsigned int i;
if (!mailbox_special_use_exists(uses[i])) {
"mailbox %s: unknown special_use: %s",
return FALSE;
}
}
/* make sure there are no extra spaces */
return TRUE;
}
const char **error_r)
{
return FALSE;
}
return FALSE;
}
return TRUE;
}
const char **error_r ATTR_UNUSED)
{
#ifndef CONFIG_BINARY
#else
"mail_plugin_dir: access(%s) failed: %m",
return FALSE;
}
#endif
return TRUE;
}
/* </settings checks> */
const struct message_address **address_r,
const char **error_r)
{
return TRUE;
/* parsing failed - do it again to get the error */
i_panic("postmaster_address='%s' parsing succeeded unexpectedly after it had already failed",
return FALSE;
}