From: Timo Sirainen Date: Mon, 12 Aug 2013 16:02:07 +0000 (+0300) Subject: auth: Added %{domain_first} and %{domain_last} variables. X-Git-Tag: 2.2.6~134 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f2bb07096ed9be01d1b759f9de1a00ecac7008f0;p=thirdparty%2Fdovecot%2Fcore.git auth: Added %{domain_first} and %{domain_last} variables. They are both equal to %d normally, but differ when there are multiple '@' characters in the domain. --- diff --git a/src/auth/auth-request.c b/src/auth/auth-request.c index 9ce62fc3ad..8f31452380 100644 --- a/src/auth/auth-request.c +++ b/src/auth/auth-request.c @@ -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; } diff --git a/src/auth/auth-request.h b/src/auth/auth-request.h index 08d98576fa..ba477109c3 100644 --- a/src/auth/auth-request.h +++ b/src/auth/auth-request.h @@ -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 *