]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Added %{domain_first} and %{domain_last} variables.
authorTimo Sirainen <tss@iki.fi>
Mon, 12 Aug 2013 16:02:07 +0000 (19:02 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 12 Aug 2013 16:02:07 +0000 (19:02 +0300)
They are both equal to %d normally, but differ when there are multiple '@'
characters in the domain.

src/auth/auth-request.c
src/auth/auth-request.h

index 9ce62fc3ad8ed1a7008a5f8518a8b0a36e182971..8f31452380a40db6cb669461acbfd7bc2f971b3e 100644 (file)
@@ -1915,6 +1915,9 @@ const struct var_expand_table auth_request_var_expand_static_tab[] = {
        { '\0', NULL, "real_rip" },
        { '\0', NULL, "real_lport" },
        { '\0', NULL, "real_rport" },
+       { '\0', NULL, "domain_first" },
+       { '\0', NULL, "domain_last" },
+       /* be sure to update AUTH_REQUEST_VAR_TAB_COUNT */
        { '\0', NULL, NULL }
 };
 
@@ -1991,6 +1994,14 @@ auth_request_get_var_expand_table_full(const struct auth_request *auth_request,
                tab[20].value = net_ip2addr(&auth_request->real_remote_ip);
        tab[21].value = dec2str(auth_request->real_local_port);
        tab[22].value = dec2str(auth_request->real_remote_port);
+       tab[23].value = strchr(auth_request->user, '@');
+       if (tab[23].value != NULL) {
+               tab[23].value = escape_func(t_strcut(tab[23].value+1, '@'),
+                                           auth_request);
+       }
+       tab[24].value = strrchr(auth_request->user, '@');
+       if (tab[24].value != NULL)
+               tab[24].value = escape_func(tab[24].value+1, auth_request);
        return ret_tab;
 }
 
index 08d98576fa08aa1bd0819cfff6be068c32ae430a..ba477109c319ca0c46d83c925d7d7dbeba992451 100644 (file)
@@ -143,7 +143,7 @@ extern unsigned int auth_request_state_count[AUTH_REQUEST_STATE_MAX];
 #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 23
+#define AUTH_REQUEST_VAR_TAB_COUNT 25
 extern const struct var_expand_table auth_request_var_expand_static_tab[];
 
 struct auth_request *