mail-storage-service.c revision 20dca965f48c1d7600a268d380c0b5fb5f1011d5
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */
8b5c520883aa37bb55646286d375fdbae294d710Timo Sirainen/* If time moves backwards more than this, kill ourself instead of sleeping. */
b63e20ea9bc84f1aa90a551f217d01385e070b73Timo Sirainen "Invalid user settings. Refer to server log for more information."
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi const char *home;
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi const char *chroot;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen const char *set_cache_module, *set_cache_service;
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen struct master_service_settings_cache *set_cache;
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen const char *const **userdb_next_fieldsp;
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen const char *system_groups_user, *uid_source, *gid_source;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainenstruct module *mail_storage_service_modules = NULL;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenmail_user_set_get_mail_debug(const struct setting_parser_info *user_info,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen mail_set = mail_user_set_get_driver_settings(user_info, user_set,
a3fe8c0c54d87822f4b4f8f0d10caac611861b2bTimo Sirainenstatic void set_keyval(struct mail_storage_service_ctx *ctx,
9b0f6b90ff8d1d6efd718b0d7cbe01b2454e9fd6Timo Sirainen struct setting_parser_context *set_parser = user->set_parser;
9b0f6b90ff8d1d6efd718b0d7cbe01b2454e9fd6Timo Sirainen const char *str;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen if (master_service_set_has_config_override(ctx->service, key)) {
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen /* this setting was already overridden with -o parameter */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen if (mail_user_set_get_mail_debug(user->user_info,
d6b3cfd855c0eebed68be50d3111de1b5a6afeb0Timo Sirainen i_debug("Ignoring overridden (-o) userdb setting: %s",
8a0a8c982a6ffc75a4b1c8717b6180a811655794Timo Sirainen if (settings_parse_line(set_parser, str) < 0) {
d5eb47a791ec56149fd711cd8e44efc8babeaae5Timo Sirainenstatic int set_line(struct mail_storage_service_ctx *ctx,
e0740628f6ca05f4bc79a9d8a90b650f4d38d4d0Timo Sirainen struct setting_parser_context *set_parser = user->set_parser;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen const char *key, *orig_key, *append_value = NULL;
3f603ef00e35fca21605afa0ad8d76e94fee2b96Timo Sirainen unsigned int len;
3f603ef00e35fca21605afa0ad8d76e94fee2b96Timo Sirainen mail_debug = mail_user_set_get_mail_debug(user->user_info,
ccf50662cc02b5e703039a4ff7f91a4470e25b71Timo Sirainen /* key+=value */
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen if (!settings_parse_is_valid_key(set_parser, key)) {
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen /* assume it's a plugin setting */
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen if (master_service_set_has_config_override(ctx->service, key)) {
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen /* this setting was already overridden with -o parameter */
1ffb2afe6d7e8860a2231a4827078cf2ef9c22cdTimo Sirainen i_debug("Ignoring overridden (-o) userdb setting: %s",
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen value = settings_parse_get_value(set_parser, key, &type);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen "'+' can only be used for strings.", orig_key);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen /* possibly a password field (e.g. imapc_password).
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen hide the value. */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen "Unknown userdb setting: %s" :
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenstatic bool validate_chroot(const struct mail_user_settings *user_set,
275385a2ecc58e41dc7df3ce3cd943caaa58c4d1Timo Sirainen const char *dir)
275385a2ecc58e41dc7df3ce3cd943caaa58c4d1Timo Sirainen const char *const *chroot_dirs;
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen chroot_dirs = t_strsplit(user_set->valid_chroot_dirs, ":");
db693bf6fcae96d834567f1782257517b7207655Timo Sirainen strncmp(dir, *chroot_dirs, strlen(*chroot_dirs)) == 0)
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenuser_reply_handle(struct mail_storage_service_ctx *ctx,
f158d9a303bb15a6848ca276c9391c7ca52e452bTimo Sirainen const char **error_r)
6303f32ad4af9cb08794561e6324df1c6c5fb637Timo Sirainen unsigned int i, count;
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)
static void mail_storage_service_seteuid_root(void)
if (seteuid(0) < 0) {
&error)) {
if (disallow_root &&
if (keep_setuid_root) {
if (current_euid != 0) {
if (!setenv_only) {
const char **error_r)
T_BEGIN {
} T_END;
user);
if (diff > 0) {
diff++;
struct mail_storage_service_ctx *
const char *version;
unsigned int count;
geteuid() != 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)
void **sets;
geteuid() != 0) {
&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;
void **sets;
&error) < 0)
const char **username_r)
const struct mail_storage_settings *
const struct mail_storage_service_input *
struct setting_parser_context *
T_BEGIN {
} T_END;
return set;