mail-storage-service.c revision 57316ab705807ac3a433e2ec9b8b6ff5d090c3d7
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen/* If time moves backwards more than this, kill ourself instead of sleeping. */
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen "Invalid user settings. Refer to server log for more information."
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen struct auth_master_connection *conn, *iter_conn;
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen const char *set_cache_module, *set_cache_service;
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen struct master_service_settings_cache *set_cache;
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen const char *const **userdb_next_fieldsp;
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen const char *log_prefix, *auth_token, *auth_user;
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen const char *system_groups_user, *uid_source, *gid_source;
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainenstruct module *mail_storage_service_modules = NULL;
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainenmail_storage_service_var_expand(struct mail_storage_service_ctx *ctx,
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen const struct mail_storage_service_input *input,
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen const struct mail_storage_service_privileges *priv,
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen const char **error_r);
2c50ccaa9adb7df8cb49a240909fce732da57bedTimo Sirainenmail_user_set_get_mail_debug(const struct setting_parser_info *user_info,
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen mail_set = mail_user_set_get_driver_settings(user_info, user_set,
2c50ccaa9adb7df8cb49a240909fce732da57bedTimo Sirainenstatic void set_keyval(struct mail_storage_service_ctx *ctx,
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen struct setting_parser_context *set_parser = user->set_parser;
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen if (master_service_set_has_config_override(ctx->service, key)) {
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen /* this setting was already overridden with -o parameter */
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen if (mail_user_set_get_mail_debug(user->user_info,
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen i_debug("Ignoring overridden (-o) userdb setting: %s",
fc40a9a002458e372ff4b9f6f4e15239520c0bcdTimo Sirainen if (settings_parse_keyvalue(set_parser, key, value) < 0) {
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen i_fatal("Invalid userdb input %s=%s: %s", key, value,
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainenstatic int set_line(struct mail_storage_service_ctx *ctx,
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen struct setting_parser_context *set_parser = user->set_parser;
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen const char *key, *orig_key, *append_value = NULL;
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen mail_debug = mail_user_set_get_mail_debug(user->user_info,
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen /* key+=value */
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen if (!settings_parse_is_valid_key(set_parser, key)) {
e8762c2b4914db7997fa9eb644a91586952d1876Timo Sirainen /* assume it's a plugin setting */
if (mail_debug) {
key);
const void *value;
return ret;
const char *dir)
const char *const *chroot_dirs;
return FALSE;
return FALSE;
return TRUE;
chroot_dirs++;
return FALSE;
const char **error_r)
unsigned int i, count;
int ret = 0;
for (i = 0; i < count; i++) {
#ifdef HAVE_SETPRIORITY
} else T_BEGIN {
} T_END;
if (ret < 0)
if (ret < 0) {
return ret;
const char *const **fields_r,
const char **error_r)
const char *new_username;
int ret;
if (ret > 0) {
} else if (ret == 0)
return ret;
return TRUE;
return FALSE;
return FALSE;
return TRUE;
return TRUE;
return FALSE;
return FALSE;
return TRUE;
static const struct var_expand_table *
return tab;
const struct var_expand_table *
int ret;
return TRUE;
return ret > 0;
const char **error_r)
const char *error;
static void mail_storage_service_seteuid_root(void)
if (seteuid(0) < 0) {
&error)) {
if (!allow_root &&
if (keep_setuid_root) {
if (current_euid != 0) {
if (!setenv_only) {
const char *session_id_suffix,
const char **error_r)
unsigned int i, count;
for (i = count; i > 0; i--)
if (p == NULL)
const char *const *fields)
const char **value_r,
const char **error_r)
const char *error;
T_BEGIN {
} T_END;
if (diff > 0) {
diff++;
struct mail_storage_service_ctx *
const char *version;
unsigned int count;
getuid() != 0) {
count = 0;
return ctx;
struct auth_master_connection *
static enum mail_storage_service_flags
return flags;
const char **error_r)
i_unreached();
const char **error_r)
const char *error;
bool update_log_prefix,
const char **error_r)
void **sets;
geteuid() != 0) {
error_r) < 0) {
if (update_log_prefix)
if (ret <= 0) {
return ret;
if (ret > 0) {
error_r) < 0) {
return ret;
const char **error_r)
bool update_log_prefix;
int ret;
const char *session_id =
return ret;
const char *session_id_suffix,
const char **error_r)
const char *error;
bool allow_root =
bool temp_priv_drop =
bool use_chroot;
if (use_chroot) {
user);
if (!temp_priv_drop ||
const char **error_r)
user,
NULL,
error_r);
const char *session_id_suffix,
const char **error_r)
int ret;
return ret;
const char *error;
const char **error_r)
int ret;
if (ret <= 0)
return ret;
if (ret < 0) {
return ret;
const char *error;
void **sets;
&error) < 0)
int ret = 0;
return ret;
const char *user_mask_hint)
flags);
const char **username_r)
const struct mail_storage_settings *
const struct mail_storage_service_input *
struct setting_parser_context *
struct mail_storage_service_ctx *
T_BEGIN {
} T_END;
return set;
const char *key,
const char *value,
const char **error_r)
return ret;