diff src/auth/auth-request.c @ 11466:5ae4a5c14f5b HEAD

auth: Added %{login_user}, %{login_username} and %{login_domain} variables that are set for master logins.
author Timo Sirainen <tss@iki.fi>
date Wed, 02 Jun 2010 19:52:32 +0100
parents 1e890076c4e9
children 48ac56ad4768
line wrap: on
line diff
--- a/src/auth/auth-request.c	Wed Jun 02 19:24:07 2010 +0100
+++ b/src/auth/auth-request.c	Wed Jun 02 19:52:32 2010 +0100
@@ -1496,6 +1496,9 @@
 		{ 'a', NULL, "lport" },
 		{ 'b', NULL, "rport" },
 		{ 'k', NULL, "cert" },
+		{ '\0', NULL, "login_user" },
+		{ '\0', NULL, "login_username" },
+		{ '\0', NULL, "login_domain" },
 		{ '\0', NULL, NULL }
 	};
 	struct var_expand_table *tab;
@@ -1536,6 +1539,19 @@
 	tab[12].value = dec2str(auth_request->local_port);
 	tab[13].value = dec2str(auth_request->remote_port);
 	tab[14].value = auth_request->valid_client_cert ? "valid" : "";
+
+	if (auth_request->requested_login_user != NULL) {
+		const char *login_user = auth_request->requested_login_user;
+
+		tab[15].value = escape_func(login_user, auth_request);
+		tab[16].value = escape_func(t_strcut(login_user, '@'),
+					    auth_request);
+		tab[17].value = strchr(login_user, '@');
+		if (tab[17].value != NULL) {
+			tab[17].value = escape_func(tab[17].value+1,
+						    auth_request);
+		}
+	}
 	return tab;
 }