From: Timo Sirainen Date: Fri, 20 Jan 2023 20:15:22 +0000 (+0200) Subject: lib-storage, global: Move settings expansion out of mail_user_init() X-Git-Tag: 2.4.0~2271 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1357d10f8993973347e5373e3764605fac1c0d1b;p=thirdparty%2Fdovecot%2Fcore.git lib-storage, global: Move settings expansion out of mail_user_init() master_service_settings_parser_get() calls can now decide whether to expand settings or not. --- diff --git a/src/imap-urlauth/imap-urlauth-worker.c b/src/imap-urlauth/imap-urlauth-worker.c index dbe3dd23e6..d0c8159141 100644 --- a/src/imap-urlauth/imap-urlauth-worker.c +++ b/src/imap-urlauth/imap-urlauth-worker.c @@ -561,8 +561,7 @@ client_handle_user_command(struct client *client, const char *cmd, if (master_service_settings_parser_get(client->event, mail_user->set_parser, - &imap_urlauth_worker_setting_parser_info, - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, + &imap_urlauth_worker_setting_parser_info, 0, &set, &error) < 0) { e_error(client->event, "user %s: %s", input.username, error); client_abort(client, "Session aborted: Failed to get settings"); diff --git a/src/imap/main.c b/src/imap/main.c index 53398aa240..95ccc3e687 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -282,15 +282,11 @@ int client_create_from_input(const struct mail_storage_service_input *input, restrict_access_allow_coredumps(TRUE); if (master_service_settings_parser_get(mail_user->event, - mail_user->set_parser, - &smtp_submit_setting_parser_info, - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, - &smtp_set, error_r) < 0 || + mail_user->set_parser, &smtp_submit_setting_parser_info, + 0, &smtp_set, error_r) < 0 || master_service_settings_parser_get(mail_user->event, - mail_user->set_parser, - &imap_setting_parser_info, - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, - &imap_set, error_r) < 0) { + mail_user->set_parser, &imap_setting_parser_info, + 0, &imap_set, error_r) < 0) { master_service_settings_free(smtp_set); mail_user_deinit(&mail_user); event_unref(&event); diff --git a/src/lda/main.c b/src/lda/main.c index a25058fe2b..b0c89c9609 100644 --- a/src/lda/main.c +++ b/src/lda/main.c @@ -291,13 +291,12 @@ lda_deliver(struct mail_deliver_input *dinput, int ret; if (master_service_settings_parser_get(dinput->rcpt_user->event, - dinput->rcpt_user->set_parser, &lda_setting_parser_info, - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, + dinput->rcpt_user->set_parser, + &lda_setting_parser_info, 0, &dinput->set, &error) < 0 || master_service_settings_parser_get(dinput->rcpt_user->event, dinput->rcpt_user->set_parser, - &smtp_submit_setting_parser_info, - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, + &smtp_submit_setting_parser_info, 0, &dinput->smtp_set, &error) < 0) i_fatal("%s", error); diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage.c b/src/lib-storage/index/dbox-multi/mdbox-storage.c index 8bcdb00f4b..75a5999208 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c @@ -49,8 +49,7 @@ int mdbox_storage_create(struct mail_storage *_storage, if (master_service_settings_parser_get(_storage->event, _storage->user->set_parser, - mdbox_get_setting_parser_info(), - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, + mdbox_get_setting_parser_info(), 0, &storage->set, error_r) < 0) return -1; diff --git a/src/lib-storage/index/imapc/imapc-storage.c b/src/lib-storage/index/imapc/imapc-storage.c index 489b921745..8d8b87da30 100644 --- a/src/lib-storage/index/imapc/imapc-storage.c +++ b/src/lib-storage/index/imapc/imapc-storage.c @@ -318,8 +318,7 @@ int imapc_storage_client_create(struct mail_namespace *ns, if (master_service_settings_parser_get(ns->user->event, ns->user->set_parser, imapc_get_setting_parser_info(), - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, - &imapc_set, error_r) < 0) + 0, &imapc_set, error_r) < 0) return -1; i_zero(&set); diff --git a/src/lib-storage/index/maildir/maildir-storage.c b/src/lib-storage/index/maildir/maildir-storage.c index 5f3feb901b..bb0b104c63 100644 --- a/src/lib-storage/index/maildir/maildir-storage.c +++ b/src/lib-storage/index/maildir/maildir-storage.c @@ -59,8 +59,7 @@ maildir_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, if (master_service_settings_parser_get(_storage->event, _storage->user->set_parser, - maildir_get_setting_parser_info(), - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, + maildir_get_setting_parser_info(), 0, &storage->set, error_r) < 0) return -1; diff --git a/src/lib-storage/index/mbox/mbox-storage.c b/src/lib-storage/index/mbox/mbox-storage.c index 444ace27fd..7b2a3b98c9 100644 --- a/src/lib-storage/index/mbox/mbox-storage.c +++ b/src/lib-storage/index/mbox/mbox-storage.c @@ -187,8 +187,7 @@ mbox_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, if (master_service_settings_parser_get(_storage->event, _storage->user->set_parser, - mbox_get_setting_parser_info(), - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, + mbox_get_setting_parser_info(), 0, &storage->set, error_r) < 0) return -1; diff --git a/src/lib-storage/index/pop3c/pop3c-storage.c b/src/lib-storage/index/pop3c/pop3c-storage.c index 2a3822616b..bc0961611e 100644 --- a/src/lib-storage/index/pop3c/pop3c-storage.c +++ b/src/lib-storage/index/pop3c/pop3c-storage.c @@ -44,8 +44,7 @@ pop3c_storage_create(struct mail_storage *_storage, if (master_service_settings_parser_get(_storage->event, _storage->user->set_parser, - pop3c_get_setting_parser_info(), - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, + pop3c_get_setting_parser_info(), 0, &storage->set, error_r) < 0) return -1; diff --git a/src/lib-storage/mail-user.c b/src/lib-storage/mail-user.c index 85aa5fa9c1..67816e94aa 100644 --- a/src/lib-storage/mail-user.c +++ b/src/lib-storage/mail-user.c @@ -163,31 +163,7 @@ int mail_user_init(struct mail_user *user, const char **error_r) &mail_storage_setting_parser_info, 0, &user->_mail_set, &error) < 0) user->error = p_strdup(user->pool, error); - - struct mail_storage_service_ctx *service_ctx = - mail_storage_service_user_get_service_ctx(user->service_user); - const struct setting_parser_info *const *set_roots = - mail_storage_service_get_set_roots(service_ctx); - for (unsigned int i = 0; set_roots[i] != NULL; i++) { - if (user->error != NULL) - break; - - void *set = settings_parser_get_root_set(user->set_parser, set_roots[i]); - /* check settings so that the duplicated structure will again - contain the parsed fields */ - if (!settings_check(set_roots[i], user->pool, set, &error)) { - user->error = p_strdup_printf(user->pool, - "Settings check unexpectedly failed: %s", error); - break; - } - if (mail_user_var_expand(user, set_roots[i], set, &error) <= 0) { - user->error = p_strdup_printf(user->pool, - "Failed to expand settings: %s", error); - break; - } - } - - if (user->error == NULL) + else mail_user_expand_plugins_envs(user, user->_mail_set); user->ssl_set = p_new(user->pool, struct ssl_iostream_settings, 1); diff --git a/src/lmtp/lmtp-local.c b/src/lmtp/lmtp-local.c index d066a48336..ecbd89d2f8 100644 --- a/src/lmtp/lmtp-local.c +++ b/src/lmtp/lmtp-local.c @@ -498,8 +498,8 @@ lmtp_local_deliver(struct lmtp_local *local, lldctx.rcpt_user = rcpt_user; if (master_service_settings_parser_get(rcpt_user->event, - rcpt_user->set_parser, &smtp_submit_setting_parser_info, - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, + rcpt_user->set_parser, + &smtp_submit_setting_parser_info, 0, &lldctx.smtp_set, &error) < 0) { e_error(rcpt->event, "%s", error); smtp_server_recipient_reply(rcpt, 451, "4.3.0", diff --git a/src/pop3/main.c b/src/pop3/main.c index ee538d30c1..5cead70802 100644 --- a/src/pop3/main.c +++ b/src/pop3/main.c @@ -148,9 +148,8 @@ client_create_from_input(const struct mail_storage_service_input *input, restrict_access_allow_coredumps(TRUE); if (master_service_settings_parser_get(mail_user->event, - mail_user->set_parser, &pop3_setting_parser_info, - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, - &set, error_r) < 0) { + mail_user->set_parser, + &pop3_setting_parser_info, 0, &set, error_r) < 0) { if (write(fd_out, lookup_error_str, strlen(lookup_error_str)) < 0) { /* ignored */ } diff --git a/src/submission/main.c b/src/submission/main.c index 65b6e66140..b7e36d9737 100644 --- a/src/submission/main.c +++ b/src/submission/main.c @@ -193,8 +193,7 @@ client_create_from_input(const struct mail_storage_service_input *input, if (master_service_settings_parser_get(mail_user->event, mail_user->set_parser, &submission_setting_parser_info, - MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND, - &set, error_r) < 0) { + 0, &set, error_r) < 0) { send_error(fd_out, event, my_hostname, "4.7.0", MAIL_ERRSTR_CRITICAL_MSG); mail_user_deinit(&mail_user);