]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Use mail_user_var_expand() where possible
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sun, 27 Feb 2022 19:26:16 +0000 (20:26 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 23 Nov 2022 10:15:37 +0000 (10:15 +0000)
This makes it possible to use %variable functions (e.g. %{userdb:*}) for
these settings.

src/imap-urlauth/imap-urlauth-worker.c
src/imap/main.c
src/lda/main.c
src/lib-storage/mail-user.c
src/lmtp/lmtp-local.c
src/pop3/main.c
src/submission/main.c

index 04bcf4b29659d921b691cd75fb0144777aeb637e..096a3a854e6dc9fd791f5bc726f4be45d308db66 100644 (file)
@@ -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));
index 48f33ed7bb3c06a5e48ec02654b639b82c01622a..14473e461967134186de0160836cdeeee4807780 100644 (file)
@@ -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);
index 95cf54d4f508dd1797248ee63429c16eed146b82..0b6b7875263701e410e96e61a39aa085566f03f9 100644 (file)
@@ -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);
index b7eae3e3c81345d8f1f699e093d831b4374aa06b..709b8e34e38187a9ad2c025de0980575b9d5c1f4 100644 (file)
@@ -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);
        }
index a3cba1492feb0ce098d9224cc11b182094facb5d..1c4eb47b516ed950547c047f028e3fa82a6e62aa 100644 (file)
@@ -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);
index 57da7616adfeb2c774f2843ef64e62770f06e10a..c665a10ff1045af7f8c4d64ead7abcaad1354606 100644 (file)
@@ -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);
index f7889c5c80d607fe72d2e8987527539c2fad3f5d..8fa41f06ed0860ae4b24cb2ba0f85a74c68f10c9 100644 (file)
@@ -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);