changeset 5882:40ce533c88f9 HEAD

Send local/remote ports to dovecot-auth. They're now in %a and %b variables.
author Timo Sirainen <tss@iki.fi>
date Tue, 03 Jul 2007 04:40:18 +0300
parents 7b7ce27f2b13
children 526d1a860b13
files doc/auth-protocol.txt src/auth/auth-request.c src/auth/auth-request.h src/lib-auth/auth-client.h src/lib-auth/auth-server-request.c src/login-common/sasl-server.c
diffstat 6 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/auth-protocol.txt	Tue Jul 03 04:22:40 2007 +0300
+++ b/doc/auth-protocol.txt	Tue Jul 03 04:40:18 2007 +0300
@@ -100,6 +100,8 @@
 
  - lip=<local ip>    : Local IP  - in standard string format,
  - rip=<remote ip>   : Remote IP - ie. for IPv4 127.0.0.1 and for IPv6 ::1
+ - lport=<port>      : Local port number
+ - rport=<port>      : Remote port number
  - secured           : Remote user has secured transport to auth client
                        (eg. localhost, SSL, TLS)
  - valid-client-cert : Remote user has presented a valid SSL certificate.
--- a/src/auth/auth-request.c	Tue Jul 03 04:22:40 2007 +0300
+++ b/src/auth/auth-request.c	Tue Jul 03 04:40:18 2007 +0300
@@ -135,6 +135,14 @@
 		str_append(str, "\trip=");
 		str_append(str, net_ip2addr(&request->remote_ip));
 	}
+	if (request->local_port != 0) {
+		str_append(str, "\tlport=");
+		str_printfa(str, "%u", request->local_port);
+	}
+	if (request->remote_port != 0) {
+		str_append(str, "\trport=");
+		str_printfa(str, "%u", request->remote_port);
+	}
 	if (request->secured)
 		str_append(str, "\tsecured=1");
 }
@@ -159,6 +167,10 @@
 		net_addr2ip(value, &request->local_ip);
 	else if (strcmp(key, "rip") == 0)
 		net_addr2ip(value, &request->remote_ip);
+	else if (strcmp(key, "lport") == 0)
+		request->local_port = atoi(value);
+	else if (strcmp(key, "rport") == 0)
+		request->remote_port = atoi(value);
 	else if (strcmp(key, "secured") == 0)
 		request->secured = TRUE;
 	else
@@ -1254,6 +1266,8 @@
 		{ '!', NULL },
 		{ 'm', NULL },
 		{ 'c', NULL },
+		{ 'a', NULL },
+		{ 'b', NULL },
 		{ '\0', NULL }
 	};
 	struct var_expand_table *tab;
@@ -1291,6 +1305,8 @@
 	tab[10].value = auth_request->mech == NULL ? "" :
 		auth_request->mech->mech_name;
 	tab[11].value = auth_request->secured ? "secured" : "";
+	tab[12].value = dec2str(auth_request->local_port);
+	tab[13].value = dec2str(auth_request->remote_port);
 	return tab;
 }
 
--- a/src/auth/auth-request.h	Tue Jul 03 04:22:40 2007 +0300
+++ b/src/auth/auth-request.h	Tue Jul 03 04:40:18 2007 +0300
@@ -60,6 +60,7 @@
 
 	const char *service;
 	struct ip_addr local_ip, remote_ip;
+	unsigned int local_port, remote_port;
 
 	union {
 		verify_plain_callback_t *verify_plain;
--- a/src/lib-auth/auth-client.h	Tue Jul 03 04:22:40 2007 +0300
+++ b/src/lib-auth/auth-client.h	Tue Jul 03 04:40:18 2007 +0300
@@ -29,6 +29,7 @@
 	enum auth_request_flags flags;
 
 	struct ip_addr local_ip, remote_ip;
+	unsigned int local_port, remote_port;
 
 	const char *initial_resp_base64;
 };
--- a/src/lib-auth/auth-server-request.c	Tue Jul 03 04:22:40 2007 +0300
+++ b/src/lib-auth/auth-server-request.c	Tue Jul 03 04:40:18 2007 +0300
@@ -18,6 +18,7 @@
 	char *mech, *service, *cert_username;
         enum auth_request_flags flags;
 	struct ip_addr local_ip, remote_ip;
+	unsigned int local_port, remote_port;
 
 	char *initial_resp_base64;
 
@@ -112,6 +113,10 @@
 		str_printfa(str, "\tlip=%s", net_ip2addr(&request->local_ip));
 	if (request->remote_ip.family != 0)
 		str_printfa(str, "\trip=%s", net_ip2addr(&request->remote_ip));
+	if (request->local_port != 0)
+		str_printfa(str, "\tlport=%u", request->local_port);
+	if (request->remote_port != 0)
+		str_printfa(str, "\trport=%u", request->remote_port);
 	if (request->initial_resp_base64 != NULL) {
 		/*if (!is_valid_string(request->initial_resp_base64)) {
 			t_pop();
--- a/src/login-common/sasl-server.c	Tue Jul 03 04:22:40 2007 +0300
+++ b/src/login-common/sasl-server.c	Tue Jul 03 04:40:18 2007 +0300
@@ -163,6 +163,8 @@
 	info.flags = client_get_auth_flags(client);
 	info.local_ip = client->local_ip;
 	info.remote_ip = client->ip;
+	info.local_port = client->local_port;
+	info.remote_port = client->remote_port;
 	info.initial_resp_base64 = initial_resp_base64;
 
 	client->auth_request =