mail-storage-service.c revision c56500d4363beba4ffa954069ab30f4401849156
bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */
402f9183489c1a75736b1e9068c33fe2741a366dTimo Sirainen/* If time moves backwards more than this, kill ourself instead of sleeping. */
686a3be710a464396cbfbc7b05eaa7fe16f3cd1cTimo Sirainen "Invalid user settings. Refer to server log for more information."
9bf221d642eba214b81346abd9ba2f9b9f2eb937Phil Carmody const char *home;
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen const char *set_cache_module, *set_cache_service;
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen struct master_service_settings_cache *set_cache;
51292e327a91a257b8baea83560b3a8323cac8c5Timo Sirainen const char *system_groups_user, *uid_source, *gid_source;
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainenstruct module *mail_storage_service_modules = NULL;
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainenmail_user_set_get_mail_debug(const struct setting_parser_info *user_info,
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen mail_set = mail_user_set_get_driver_settings(user_info, user_set,
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainenstatic void set_keyval(struct mail_storage_service_ctx *ctx,
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen struct setting_parser_context *set_parser = user->set_parser;
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen const char *str;
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen if (master_service_set_has_config_override(ctx->service, key)) {
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen /* this setting was already overridden with -o parameter */
4baf980b75800ad3595c39dc3b8d913f2686affdTimo Sirainen if (mail_user_set_get_mail_debug(user->user_info,
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen i_debug("Ignoring overridden (-o) userdb setting: %s",
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen if (settings_parse_line(set_parser, str) < 0) {
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainenstatic int set_line(struct mail_storage_service_ctx *ctx,
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen struct setting_parser_context *set_parser = user->set_parser;
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen const char *key, *orig_key, *append_value = NULL;
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen unsigned int len;
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen mail_debug = mail_user_set_get_mail_debug(user->user_info,
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen /* key+=value */
ebe00087d3c7f9706d4acb9017eaad912404516cTimo Sirainen if (!settings_parse_is_valid_key(set_parser, key)) {
ebe00087d3c7f9706d4acb9017eaad912404516cTimo Sirainen /* assume it's a plugin setting */
ebe00087d3c7f9706d4acb9017eaad912404516cTimo Sirainen if (master_service_set_has_config_override(ctx->service, key)) {
ebe00087d3c7f9706d4acb9017eaad912404516cTimo Sirainen /* this setting was already overridden with -o parameter */
c398eca6b0fc6583687bd6fe2ee2dbcca2ae9387Timo Sirainen i_debug("Ignoring overridden (-o) userdb setting: %s",
1dcf22e98ba8310e8daa8c9297936c6f3a645e7aPhil Carmody value = settings_parse_get_value(set_parser, key, &type);
5dd05e966ffd69181ab3067f6939b03ced68ebc3Timo Sirainen "'+' can only be used for strings.", orig_key);
5dd05e966ffd69181ab3067f6939b03ced68ebc3Timo Sirainen /* possibly a password field (e.g. imapc_password).
5dd05e966ffd69181ab3067f6939b03ced68ebc3Timo Sirainen hide the value. */
5dd05e966ffd69181ab3067f6939b03ced68ebc3Timo Sirainen "Unknown userdb setting: %s" :
5dd05e966ffd69181ab3067f6939b03ced68ebc3Timo Sirainenstatic bool validate_chroot(const struct mail_user_settings *user_set,
5dd05e966ffd69181ab3067f6939b03ced68ebc3Timo Sirainen const char *dir)
5dd05e966ffd69181ab3067f6939b03ced68ebc3Timo Sirainen 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 *
const char *str)
const char **error_r)
&error)) {
if (disallow_root &&
if (keep_setuid_root) {
if (current_euid != 0) {
if (seteuid(0) < 0)
if (!setenv_only) {
const char **error_r)
T_BEGIN {
} T_END;
user);
if (diff > 0) {
diff++;
struct mail_storage_service_ctx *
unsigned int count;
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)
&error) < 0) {
error_r);
if (ret <= 0) {
return ret;
if (ret > 0) {
return ret;
const char *error;
unsigned int len;
bool disallow_root =
bool temp_priv_drop =
bool use_chroot;
if (use_chroot) {
if (!temp_priv_drop ||
const char *error;
const char **error_r)
int ret;
if (ret <= 0)
return ret;
if (ret < 0) {
return ret;
const char *error;
&error) < 0)
const char **username_r)
const struct mail_storage_service_input *
struct setting_parser_context *
T_BEGIN {
} T_END;
return set;