]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Added %{auth_user/username/domain} variables
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 2 May 2016 07:14:20 +0000 (10:14 +0300)
committerGitLab <gitlab@git.dovecot.net>
Mon, 2 May 2016 08:43:01 +0000 (11:43 +0300)
src/auth/auth-request-var-expand.c
src/auth/auth-request-var-expand.h

index 964bbf33b6946fd94aef5ee21ae43723eaa99ef1..f1f041e473b99270a2cb9580bb5c732761dc4e56 100644 (file)
@@ -42,6 +42,9 @@ auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT+1] = {
        { '\0', NULL, "orig_user" },
        { '\0', NULL, "orig_username" },
        { '\0', NULL, "orig_domain" },
+       { '\0', NULL, "auth_user" },
+       { '\0', NULL, "auth_username" },
+       { '\0', NULL, "auth_domain" },
        /* be sure to update AUTH_REQUEST_VAR_TAB_COUNT */
        { '\0', NULL, NULL }
 };
@@ -68,7 +71,7 @@ auth_request_get_var_expand_table_full(const struct auth_request *auth_request,
        const unsigned int auth_count =
                N_ELEMENTS(auth_request_var_expand_static_tab);
        struct var_expand_table *tab, *ret_tab;
-       const char *orig_user;
+       const char *orig_user, *auth_user;
 
        if (escape_func == NULL)
                escape_func = escape_none;
@@ -154,6 +157,16 @@ auth_request_get_var_expand_table_full(const struct auth_request *auth_request,
        tab[29].value = strchr(orig_user, '@');
        if (tab[29].value != NULL)
                tab[29].value = escape_func(tab[29].value+1, auth_request);
+
+       if (auth_request->master_user != NULL)
+               auth_user = auth_request->master_user;
+       else
+               auth_user = orig_user;
+       tab[30].value = escape_func(auth_user, auth_request);
+       tab[31].value = escape_func(t_strcut(auth_user, '@'), auth_request);
+       tab[32].value = strchr(auth_user, '@');
+       if (tab[32].value != NULL)
+               tab[32].value = escape_func(tab[32].value+1, auth_request);
        return ret_tab;
 }
 
index 180454a46963f046b1adcf894e978acab594a611..1362ec3f861df95de34a71337309b9a3da2c80df 100644 (file)
@@ -8,7 +8,7 @@ auth_request_escape_func_t(const char *string,
 #define AUTH_REQUEST_VAR_TAB_USER_IDX 0
 #define AUTH_REQUEST_VAR_TAB_USERNAME_IDX 1
 #define AUTH_REQUEST_VAR_TAB_DOMAIN_IDX 2
-#define AUTH_REQUEST_VAR_TAB_COUNT 30
+#define AUTH_REQUEST_VAR_TAB_COUNT 33
 extern const struct var_expand_table
 auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT+1];