mail-storage-service.c revision 38dac3030bdd74acba0a60edd54b2db6d914fde2
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen/* Copyright (c) 2009-2016 Dovecot authors, see the included COPYING file */
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen/* If time moves backwards more than this, kill ourself instead of sleeping. */
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen "Invalid user settings. Refer to server log for more information."
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen struct auth_master_connection *conn, *iter_conn;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen const char *set_cache_module, *set_cache_service;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen struct master_service_settings_cache *set_cache;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen const char *const **userdb_next_fieldsp;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen const char *log_prefix, *auth_token, *auth_user;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen const char *system_groups_user, *uid_source, *gid_source;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainenstruct module *mail_storage_service_modules = NULL;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainenmail_storage_service_var_expand(struct mail_storage_service_ctx *ctx,
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen const struct mail_storage_service_input *input,
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen const struct mail_storage_service_privileges *priv);
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainenmail_user_set_get_mail_debug(const struct setting_parser_info *user_info,
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen mail_set = mail_user_set_get_driver_settings(user_info, user_set,
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainenstatic void set_keyval(struct mail_storage_service_ctx *ctx,
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen struct setting_parser_context *set_parser = user->set_parser;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen const char *str;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen if (master_service_set_has_config_override(ctx->service, key)) {
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen /* this setting was already overridden with -o parameter */
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen if (mail_user_set_get_mail_debug(user->user_info,
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen i_debug("Ignoring overridden (-o) userdb setting: %s",
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen if (settings_parse_line(set_parser, str) < 0) {
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainenstatic int set_line(struct mail_storage_service_ctx *ctx,
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen struct setting_parser_context *set_parser = user->set_parser;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen const char *key, *orig_key, *append_value = NULL;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen unsigned int len;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen mail_debug = mail_user_set_get_mail_debug(user->user_info,
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen /* key+=value */
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen if (!settings_parse_is_valid_key(set_parser, key)) {
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen /* assume it's a plugin setting */
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen if (master_service_set_has_config_override(ctx->service, key)) {
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen /* this setting was already overridden with -o parameter */
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen i_debug("Ignoring overridden (-o) userdb setting: %s",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen value = settings_parse_get_value(set_parser, key, &type);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "'+' can only be used for strings.", orig_key);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* possibly a password field (e.g. imapc_password).
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen hide the value. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "Unknown userdb setting: %s" :
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainenstatic bool validate_chroot(const struct mail_user_settings *user_set,
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen const char *dir)
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen const char *const *chroot_dirs;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen chroot_dirs = t_strsplit(user_set->valid_chroot_dirs, ":");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen strncmp(dir, *chroot_dirs, strlen(*chroot_dirs)) == 0)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenuser_reply_handle(struct mail_storage_service_ctx *ctx,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char **error_r)
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen unsigned int i, count;
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen set_keyval(ctx, user, "mail_uid", dec2str(reply->uid));
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen set_keyval(ctx, user, "mail_gid", dec2str(reply->gid));
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* wu-ftpd like <chroot>/./<home> - check only if there's even
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen a possibility of using them (non-empty valid_chroot_dirs) */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (!validate_chroot(user->user_set, chroot)) {
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen "userdb returned invalid chroot directory: %s "
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen str = array_get(&reply->extra_fields, &count);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen for (i = 0; i < count; i++) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (strncmp(line, "system_groups_user=", 19) == 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen i_error("userdb returned invalid nice value %s",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen } else if (n != 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen } else if (strncmp(line, "auth_token=", 11) == 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen user->auth_token = p_strdup(user->pool, line+11);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen } else if (strncmp(line, "auth_user=", 10) == 0) {
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen user->auth_user = p_strdup(user->pool, line+10);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen user->admin = line[6] == 'y' || line[6] == 'Y' ||
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *error_r = t_strdup_printf("Invalid userdb input '%s': %s",
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen str[i], settings_parser_get_error(user->set_parser));
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenservice_auth_userdb_lookup(struct mail_storage_service_ctx *ctx,
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen const struct mail_storage_service_input *input,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *const **fields_r,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char **error_r)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen info.service = input->service != NULL ? input->service :
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ret = auth_master_user_lookup(ctx->conn, *user, &info, pool,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen i_debug("changed username to %s", new_username);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen } else if (ret == 0)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic bool parse_uid(const char *str, uid_t *uid_r, const char **error_r)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *error_r = t_strdup_printf("getpwnam(%s) failed: %m", str);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *error_r = t_strconcat("Unknown UNIX UID user: ", str, NULL);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic bool parse_gid(const char *str, gid_t *gid_r, const char **error_r)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *error_r = t_strdup_printf("getgrnam(%s) failed: %m", str);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *error_r = t_strconcat("Unknown UNIX GID group: ", str, NULL);
641f0c0900ee6e7cf9667f4b40ed95cec7d0cdcaTimo Sirainenstatic const struct var_expand_table *
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenget_var_expand_table(struct master_service *service,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const struct mail_storage_service_input *input,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const struct mail_storage_service_privileges *priv)
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen static struct var_expand_table static_tab[] = {
641f0c0900ee6e7cf9667f4b40ed95cec7d0cdcaTimo Sirainen tab[1].value = t_strcut(input->username, '@');
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen tab[5].value = net_ip2addr(&input->remote_ip);
641f0c0900ee6e7cf9667f4b40ed95cec7d0cdcaTimo Sirainen dec2str(priv->uid == (uid_t)-1 ? geteuid() : priv->uid);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen dec2str(priv->gid == (gid_t)-1 ? getegid() : priv->gid);
641f0c0900ee6e7cf9667f4b40ed95cec7d0cdcaTimo Sirainen if (user == NULL || user->auth_user == NULL) {
641f0c0900ee6e7cf9667f4b40ed95cec7d0cdcaTimo Sirainen tab[11].value = t_strcut(user->auth_user, '@');
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenmail_storage_service_get_var_expand_table(struct mail_storage_service_ctx *ctx,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen return get_var_expand_table(ctx->service, NULL, input, &priv);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic const char *
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenuser_expand_varstr(struct mail_storage_service_ctx *ctx,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *str)
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen i_assert(*str == SETTING_STRVAR_UNEXPANDED[0]);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_storage_service_var_expand(ctx, ret, str + 1, user, &user->input, priv);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenservice_parse_privileges(struct mail_storage_service_ctx *ctx,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen struct mail_storage_service_privileges *priv_r,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char **error_r)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const struct mail_user_settings *set = user->user_set;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (!parse_uid(set->mail_uid, &uid, error_r)) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *error_r = t_strdup_printf("%s (from %s)", *error_r,
0c17af9d3f9323136a94e66605776ed4462a172dTimo Sirainen "Mail access for users with UID %s not permitted "
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "(see first_valid_uid in config file, uid from %s).",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (!parse_gid(set->mail_gid, &gid, error_r)) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *error_r = t_strdup_printf("%s (from %s)", *error_r,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "Mail access for users with GID %s not permitted "
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "(see first_valid_gid in config file, gid from %s).",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* variable strings are expanded in mail_user_init(),
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen but we need the home and chroot sooner so do them separately here. */
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen priv_r->home = user_expand_varstr(ctx, user, priv_r,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen priv_r->chroot = user_expand_varstr(ctx, user, priv_r,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic void mail_storage_service_seteuid_root(void)
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen if (seteuid(0) < 0) {
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen "Failed to restore temporarily dropped root privileges: "
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "seteuid(0) failed: %m");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenservice_drop_privileges(struct mail_storage_service_user *user,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const struct mail_user_settings *set = user->user_set;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *error_r = "User is missing UID (see mail_uid setting)";
d67f54632110cfb6aafe2d7cd1f99b031c0b208aTimo Sirainen } else if (rset.gid == (gid_t)-1 && disallow_root &&
d67f54632110cfb6aafe2d7cd1f99b031c0b208aTimo Sirainen *error_r = "User is missing GID (see mail_gid setting)";
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (!parse_gid(set->mail_privileged_group, &rset.privileged_gid,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "%s (in mail_privileged_group setting)", error);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen rset.extra_groups = t_strconcat(set->mail_access_groups, ",",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen rset.chroot_dir = *priv->chroot == '\0' ? NULL : priv->chroot;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen rset.system_groups_user = user->system_groups_user;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen cur_chroot = restrict_access_get_current_chroot();
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* we're already chrooted. make sure the chroots are equal. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "can't un-chroot for this user";
685393de106e55b61f754d420e378d05bd462ebbTimo Sirainen if (strcmp(rset.chroot_dir, cur_chroot) != 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "Process is already chrooted to %s, "
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "can't chroot to %s", cur_chroot, priv->chroot);
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen /* chrooting to same directory where we're already chrooted */
d8b77aef97e89f1ccc5cbdaef77be9052279e35fTimo Sirainen (rset.uid == 0 || (rset.uid == (uid_t)-1 && current_euid == 0))) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen *error_r = "Mail access not allowed for root";
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* we're changing the UID,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen switch back to root first */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen restrict_access(&rset, *priv->home == '\0' ? NULL : priv->home,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen i_fatal("mail-storage-service: seteuid(%s) failed: %m",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenmail_storage_service_init_post(struct mail_storage_service_ctx *ctx,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char **error_r)
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen /* NOTE: if more user initialization is added, add it also to
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_user_dup() */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_user = mail_user_alloc(user->input.username, user->user_info,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_user_set_home(mail_user, *home == '\0' ? NULL : home);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_user_set_vars(mail_user, ctx->service->name,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen &user->input.local_ip, &user->input.remote_ip);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_user->uid = priv->uid == (uid_t)-1 ? geteuid() : priv->uid;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_user->gid = priv->gid == (gid_t)-1 ? getegid() : priv->gid;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_user->auth_token = p_strdup(mail_user->pool, user->auth_token);
641f0c0900ee6e7cf9667f4b40ed95cec7d0cdcaTimo Sirainen mail_user->auth_user = p_strdup(mail_user->pool, user->auth_user);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen p_strdup(mail_user->pool, user->input.session_id);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_user->userdb_fields = user->input.userdb_fields == NULL ? NULL :
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen p_strarray_dup(mail_user->pool, user->input.userdb_fields);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen (user->flags & MAIL_STORAGE_SERVICE_FLAG_AUTOEXPUNGE) != 0;
641f0c0900ee6e7cf9667f4b40ed95cec7d0cdcaTimo Sirainen mail_set = mail_user_set_get_storage_set(mail_user);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen str_printfa(str, "Effective uid=%s, gid=%s, home=%s",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen dec2str(geteuid()), dec2str(getegid()), home);
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen str_printfa(str, ", chroot=%s", priv->chroot);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP) != 0 &&
d67f54632110cfb6aafe2d7cd1f99b031c0b208aTimo Sirainen (user->flags & MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS) == 0) {
d67f54632110cfb6aafe2d7cd1f99b031c0b208aTimo Sirainen /* we don't want to write core files to any users' home
d67f54632110cfb6aafe2d7cd1f99b031c0b208aTimo Sirainen directories since they could contain information about other
d67f54632110cfb6aafe2d7cd1f99b031c0b208aTimo Sirainen users' mails as well. so do no chdiring to home. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen (user->flags & MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR) == 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* If possible chdir to home directory, so that core file
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen could be written in case we crash. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_NO_NAMESPACES) == 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (mail_namespaces_init(mail_user, error_r) < 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_storage_service_io_activate_user(struct mail_storage_service_user *user)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_storage_service_io_deactivate_user(struct mail_storage_service_user *user)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen i_set_failure_prefix("%s", user->service_ctx->default_log_prefix);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_storage_service_io_deactivate(struct mail_storage_service_ctx *ctx)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen i_set_failure_prefix("%s", ctx->default_log_prefix);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic const char *field_get_default(const char *data)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *p;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* default value given */
const char *const *fields)
unsigned int i, field_name_len;
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)
bool update_log_prefix,
const char **error_r)
void **sets;
geteuid() != 0) {
&error) < 0) {
if (update_log_prefix)
error_r);
if (ret <= 0) {
return ret;
if (ret > 0) {
&error) < 0) {
return ret;
const char **error_r)
bool update_log_prefix;
int ret;
const char *session_id =
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 ||
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;
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;