dovecot-2.1: auth: Added %{domain_first} and %{domain_last} vari...

dovecot at dovecot.org dovecot at dovecot.org
Mon Aug 12 20:09:22 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.1/rev/3029df20febc
changeset: 14994:3029df20febc
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Aug 12 20:09:09 2013 +0300
description:
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.

diffstat:

 src/auth/auth-request.c |  11 +++++++++++
 src/auth/auth-request.h |   2 +-
 2 files changed, 12 insertions(+), 1 deletions(-)

diffs (40 lines):

diff -r c7832e75d2a8 -r 3029df20febc src/auth/auth-request.c
--- a/src/auth/auth-request.c	Wed Jun 12 22:03:07 2013 +0300
+++ b/src/auth/auth-request.c	Mon Aug 12 20:09:09 2013 +0300
@@ -1831,6 +1831,9 @@
 	{ '\0', NULL, "login_username" },
 	{ '\0', NULL, "login_domain" },
 	{ '\0', NULL, "session" },
+	{ '\0', NULL, "domain_first" },
+	{ '\0', NULL, "domain_last" },
+	/* be sure to update AUTH_REQUEST_VAR_TAB_COUNT */
 	{ '\0', NULL, NULL }
 };
 
@@ -1901,6 +1904,14 @@
 	}
 	tab[18].value = auth_request->session_id == NULL ? NULL :
 		escape_func(auth_request->session_id, auth_request);
+	tab[19].value = strchr(auth_request->user, '@');
+	if (tab[19].value != NULL) {
+		tab[19].value = escape_func(t_strcut(tab[19].value+1, '@'),
+					    auth_request);
+	}
+	tab[20].value = strrchr(auth_request->user, '@');
+	if (tab[20].value != NULL)
+		tab[20].value = escape_func(tab[20].value+1, auth_request);
 	return ret_tab;
 }
 
diff -r c7832e75d2a8 -r 3029df20febc src/auth/auth-request.h
--- a/src/auth/auth-request.h	Wed Jun 12 22:03:07 2013 +0300
+++ b/src/auth/auth-request.h	Mon Aug 12 20:09:09 2013 +0300
@@ -128,7 +128,7 @@
 #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 19
+#define AUTH_REQUEST_VAR_TAB_COUNT 21
 extern const struct var_expand_table auth_request_var_expand_static_tab[];
 
 struct auth_request *


More information about the dovecot-cvs mailing list