From: Timo Sirainen Date: Sun, 27 Feb 2022 19:26:16 +0000 (+0100) Subject: global: Use mail_user_var_expand() where possible X-Git-Tag: 2.4.0~3387 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe4103f95afa727582bfd26b56b28a88235ebf1e;p=thirdparty%2Fdovecot%2Fcore.git global: Use mail_user_var_expand() where possible This makes it possible to use %variable functions (e.g. %{userdb:*}) for these settings. --- diff --git a/src/imap-urlauth/imap-urlauth-worker.c b/src/imap-urlauth/imap-urlauth-worker.c index 04bcf4b296..096a3a854e 100644 --- a/src/imap-urlauth/imap-urlauth-worker.c +++ b/src/imap-urlauth/imap-urlauth-worker.c @@ -589,10 +589,8 @@ client_handle_user_command(struct client *client, const char *cmd, restrict_access_allow_coredumps(TRUE); set = mail_storage_service_user_get_set(user)[1]; - if (settings_var_expand(&imap_urlauth_worker_setting_parser_info, set, - mail_user->pool, - mail_user_var_expand_table(mail_user), - &error) <= 0) { + if (mail_user_var_expand(mail_user, &imap_urlauth_worker_setting_parser_info, + set, &error) <= 0) { client_send_line(client, "NO"); client_abort(client, t_strdup_printf( "Session aborted: Failed to expand settings: %s", error)); diff --git a/src/imap/main.c b/src/imap/main.c index 48f33ed7bb..14473e4619 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -283,12 +283,10 @@ int client_create_from_input(const struct mail_storage_service_input *input, if (imap_set->verbose_proctitle) verbose_proctitle = TRUE; - if (settings_var_expand(&smtp_submit_setting_parser_info, smtp_set, - mail_user->pool, mail_user_var_expand_table(mail_user), - &errstr) <= 0 || - settings_var_expand(&imap_setting_parser_info, imap_set, - mail_user->pool, mail_user_var_expand_table(mail_user), - &errstr) <= 0) { + if (mail_user_var_expand(mail_user, &smtp_submit_setting_parser_info, + smtp_set, &errstr) <= 0 || + mail_user_var_expand(mail_user, &imap_setting_parser_info, + imap_set, &errstr) <= 0) { *error_r = t_strdup_printf("Failed to expand settings: %s", errstr); mail_user_deinit(&mail_user); mail_storage_service_user_unref(&user); diff --git a/src/lda/main.c b/src/lda/main.c index 95cf54d4f5..0b6b787526 100644 --- a/src/lda/main.c +++ b/src/lda/main.c @@ -287,24 +287,19 @@ lda_deliver(struct mail_deliver_input *dinput, bool stderr_rejection) { struct mail_deliver_context ctx; - const struct var_expand_table *var_table; struct lda_settings *lda_set; struct smtp_submit_settings *smtp_set; const char *errstr; int ret; - var_table = mail_user_var_expand_table(dinput->rcpt_user); smtp_set = mail_storage_service_user_get_set(service_user)[1]; lda_set = mail_storage_service_user_get_set(service_user)[2]; - ret = settings_var_expand( - &lda_setting_parser_info, - lda_set, dinput->rcpt_user->pool, var_table, - &errstr); + ret = mail_user_var_expand(dinput->rcpt_user, &lda_setting_parser_info, + lda_set, &errstr); if (ret > 0) { - ret = settings_var_expand( + ret = mail_user_var_expand(dinput->rcpt_user, &smtp_submit_setting_parser_info, - smtp_set, dinput->rcpt_user->pool, var_table, - &errstr); + smtp_set, &errstr); } if (ret <= 0) i_fatal("Failed to expand settings: %s", errstr); diff --git a/src/lib-storage/mail-user.c b/src/lib-storage/mail-user.c index b7eae3e3c8..709b8e34e3 100644 --- a/src/lib-storage/mail-user.c +++ b/src/lib-storage/mail-user.c @@ -171,10 +171,8 @@ int mail_user_init(struct mail_user *user, const char **error_r) } /* expand settings after we can expand %h */ - if (settings_var_expand_with_funcs(user->set_info, user->set, - user->pool, mail_user_var_expand_table(user), - mail_user_var_expand_func_table, user, - &error) <= 0) { + if (mail_user_var_expand(user, user->set_info, user->set, + &error) <= 0) { user->error = p_strdup_printf(user->pool, "Failed to expand settings: %s", error); } diff --git a/src/lmtp/lmtp-local.c b/src/lmtp/lmtp-local.c index a3cba1492f..1c4eb47b51 100644 --- a/src/lmtp/lmtp-local.c +++ b/src/lmtp/lmtp-local.c @@ -423,7 +423,6 @@ lmtp_local_deliver(struct lmtp_local *local, struct lda_settings *lda_set; struct mail_namespace *ns; struct setting_parser_context *set_parser; - const struct var_expand_table *var_table; void **sets; const char *line, *error, *username; int ret; @@ -470,18 +469,13 @@ lmtp_local_deliver(struct lmtp_local *local, local->rcpt_user = rcpt_user; sets = mail_storage_service_user_get_set(service_user); - var_table = mail_user_var_expand_table(rcpt_user); smtp_set = sets[1]; lda_set = sets[2]; - ret = settings_var_expand( - &smtp_submit_setting_parser_info, - smtp_set, client->pool, var_table, - &error); + ret = mail_user_var_expand(rcpt_user, &smtp_submit_setting_parser_info, + smtp_set, &error); if (ret > 0) { - ret = settings_var_expand( - &lda_setting_parser_info, - lda_set, client->pool, var_table, - &error); + ret = mail_user_var_expand(rcpt_user, &lda_setting_parser_info, + lda_set, &error); } if (ret <= 0) { e_error(rcpt->event, "Failed to expand settings: %s", error); diff --git a/src/pop3/main.c b/src/pop3/main.c index 57da7616ad..c665a10ff1 100644 --- a/src/pop3/main.c +++ b/src/pop3/main.c @@ -152,9 +152,8 @@ client_create_from_input(const struct mail_storage_service_input *input, if (set->verbose_proctitle) verbose_proctitle = TRUE; - if (settings_var_expand(&pop3_setting_parser_info, set, - mail_user->pool, mail_user_var_expand_table(mail_user), - &errstr) <= 0) { + if (mail_user_var_expand(mail_user, &pop3_setting_parser_info, set, + &errstr) <= 0) { *error_r = t_strdup_printf("Failed to expand settings: %s", errstr); mail_user_deinit(&mail_user); mail_storage_service_user_unref(&user); diff --git a/src/submission/main.c b/src/submission/main.c index f7889c5c80..8fa41f06ed 100644 --- a/src/submission/main.c +++ b/src/submission/main.c @@ -196,9 +196,8 @@ client_create_from_input(const struct mail_storage_service_input *input, if (set->verbose_proctitle) verbose_proctitle = TRUE; - if (settings_var_expand(&submission_setting_parser_info, set, - mail_user->pool, mail_user_var_expand_table(mail_user), - &errstr) <= 0) { + if (mail_user_var_expand(mail_user, &submission_setting_parser_info, + set, &errstr) <= 0) { *error_r = t_strdup_printf("Failed to expand settings: %s", errstr); send_error(fd_out, event, set->hostname, "4.3.5", MAIL_ERRSTR_CRITICAL_MSG);