dovecot: Send local/remote ports to dovecot-auth. They're now in...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jul 3 04:40:22 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/40ce533c88f9
changeset: 5882:40ce533c88f9
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jul 03 04:40:18 2007 +0300
description:
Send local/remote ports to dovecot-auth. They're now in %a and %b variables.

diffstat:

6 files changed, 27 insertions(+)
doc/auth-protocol.txt              |    2 ++
src/auth/auth-request.c            |   16 ++++++++++++++++
src/auth/auth-request.h            |    1 +
src/lib-auth/auth-client.h         |    1 +
src/lib-auth/auth-server-request.c |    5 +++++
src/login-common/sasl-server.c     |    2 ++

diffs (115 lines):

diff -r 7b7ce27f2b13 -r 40ce533c88f9 doc/auth-protocol.txt
--- 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 @@ AUTH parameters are:
 
  - 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.
diff -r 7b7ce27f2b13 -r 40ce533c88f9 src/auth/auth-request.c
--- 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 @@ void auth_request_export(struct auth_req
 		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 @@ bool auth_request_import(struct auth_req
 		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 @@ auth_request_get_var_expand_table(const 
 		{ '!', NULL },
 		{ 'm', NULL },
 		{ 'c', NULL },
+		{ 'a', NULL },
+		{ 'b', NULL },
 		{ '\0', NULL }
 	};
 	struct var_expand_table *tab;
@@ -1291,6 +1305,8 @@ auth_request_get_var_expand_table(const 
 	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;
 }
 
diff -r 7b7ce27f2b13 -r 40ce533c88f9 src/auth/auth-request.h
--- 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 @@ struct auth_request {
 
 	const char *service;
 	struct ip_addr local_ip, remote_ip;
+	unsigned int local_port, remote_port;
 
 	union {
 		verify_plain_callback_t *verify_plain;
diff -r 7b7ce27f2b13 -r 40ce533c88f9 src/lib-auth/auth-client.h
--- 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 @@ struct auth_request_info {
 	enum auth_request_flags flags;
 
 	struct ip_addr local_ip, remote_ip;
+	unsigned int local_port, remote_port;
 
 	const char *initial_resp_base64;
 };
diff -r 7b7ce27f2b13 -r 40ce533c88f9 src/lib-auth/auth-server-request.c
--- 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 @@ struct auth_request {
 	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 @@ static int auth_server_send_new_request(
 		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();
diff -r 7b7ce27f2b13 -r 40ce533c88f9 src/login-common/sasl-server.c
--- 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 @@ void sasl_server_auth_begin(struct clien
 	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 =


More information about the dovecot-cvs mailing list