]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Support %{userdb:*} variables in mail_home and mail_chroot settings.
authorTimo Sirainen <tss@iki.fi>
Mon, 9 Nov 2015 11:16:50 +0000 (13:16 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 9 Nov 2015 11:16:50 +0000 (13:16 +0200)
src/lib-storage/mail-storage-service.c
src/lib-storage/mail-user.c

index 390193cc2a0bcdb9cfeb944492b9c71bb829399f..d01a62e995232dbc0daaa32c99363c0f757a361c 100644 (file)
@@ -88,6 +88,13 @@ struct mail_storage_service_user {
 
 struct module *mail_storage_service_modules = NULL;
 
+static void
+mail_storage_service_var_expand(struct mail_storage_service_ctx *ctx,
+                               string_t *str, const char *format,
+                               struct mail_storage_service_user *user,
+                               const struct mail_storage_service_input *input,
+                               const struct mail_storage_service_privileges *priv);
+
 static bool
 mail_user_set_get_mail_debug(const struct setting_parser_info *user_info,
                             const struct mail_user_settings *user_set)
@@ -443,7 +450,7 @@ mail_storage_service_get_var_expand_table(struct mail_storage_service_ctx *ctx,
 }
 
 static const char *
-user_expand_varstr(struct master_service *service,
+user_expand_varstr(struct mail_storage_service_ctx *ctx,
                   struct mail_storage_service_user *user,
                   struct mail_storage_service_privileges *priv,
                   const char *str)
@@ -456,8 +463,7 @@ user_expand_varstr(struct master_service *service,
        i_assert(*str == SETTING_STRVAR_UNEXPANDED[0]);
 
        ret = t_str_new(256);
-       var_expand(ret, str + 1,
-                  get_var_expand_table(service, user, &user->input, priv));
+       mail_storage_service_var_expand(ctx, ret, str + 1, user, &user->input, priv);
        return str_c(ret);
 }
 
@@ -512,9 +518,9 @@ service_parse_privileges(struct mail_storage_service_ctx *ctx,
 
        /* variable strings are expanded in mail_user_init(),
           but we need the home and chroot sooner so do them separately here. */
-       priv_r->home = user_expand_varstr(ctx->service, user, priv_r,
+       priv_r->home = user_expand_varstr(ctx, user, priv_r,
                                          user->user_set->mail_home);
-       priv_r->chroot = user_expand_varstr(ctx->service, user, priv_r,
+       priv_r->chroot = user_expand_varstr(ctx, user, priv_r,
                                            user->user_set->mail_chroot);
        return 0;
 }
index 34b75afedb83e21a25d0db30a206f80371b5692c..dc37285a93d02281f67bad5bad7063e4de5a4070 100644 (file)
@@ -377,7 +377,9 @@ static void mail_user_get_mail_home(struct mail_user *user)
                return;
 
        str = t_str_new(128);
-       var_expand(str, home, mail_user_var_expand_table(user));
+       var_expand_with_funcs(str, home,
+                             mail_user_var_expand_table(user),
+                             mail_user_var_expand_func_table, user);
        user->_home = p_strdup(user->pool, str_c(str));
 }