[dovecot-cvs] dovecot/src/login-common client-common.c, 1.4.2.1, 1.4.2.2 client-common.h, 1.9.2.2, 1.9.2.3 main.c, 1.33.2.4, 1.33.2.5

tss at dovecot.org tss at dovecot.org
Sun Dec 3 13:50:45 UTC 2006


Update of /var/lib/cvs/dovecot/src/login-common
In directory talvi:/tmp/cvs-serv31061/src/login-common

Modified Files:
      Tag: branch_1_0
	client-common.c client-common.h main.c 
Log Message:
Added %a=local port and %b=remote port variables for
login_log_format_elements.



Index: client-common.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/client-common.c,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -d -r1.4.2.1 -r1.4.2.2
--- client-common.c	16 Aug 2006 12:16:24 -0000	1.4.2.1
+++ client-common.c	3 Dec 2006 13:50:42 -0000	1.4.2.2
@@ -23,6 +23,8 @@
 		{ 'r', NULL },
 		{ 'p', NULL },
 		{ 'm', NULL },
+		{ 'a', NULL },
+		{ 'b', NULL },
 		{ 'c', NULL },
 		{ '\0', NULL }
 	};
@@ -44,10 +46,12 @@
 	tab[7].value = my_pid;
 	tab[8].value = client->auth_mech_name == NULL ? NULL :
 		str_sanitize(client->auth_mech_name, MAX_MECH_NAME);
+	tab[9].value = dec2str(client->local_port);
+	tab[10].value = dec2str(client->remote_port);
 	if (!client->tls) {
-		tab[9].value = client->secured ? "secured" : NULL;
+		tab[11].value = client->secured ? "secured" : NULL;
 	} else {
-		tab[9].value = client->proxy != NULL &&
+		tab[11].value = client->proxy != NULL &&
 			ssl_proxy_is_handshaked(client->proxy) ? "TLS" :
 			"TLS handshake";
 	}

Index: client-common.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/client-common.h,v
retrieving revision 1.9.2.2
retrieving revision 1.9.2.3
diff -u -d -r1.9.2.2 -r1.9.2.3
--- client-common.h	7 Nov 2006 15:06:18 -0000	1.9.2.2
+++ client-common.h	3 Dec 2006 13:50:42 -0000	1.9.2.3
@@ -8,6 +8,7 @@
 struct client {
 	struct ip_addr local_ip;
 	struct ip_addr ip;
+	unsigned int local_port, remote_port;
 	struct ssl_proxy *proxy;
 
 	int fd;

Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/main.c,v
retrieving revision 1.33.2.4
retrieving revision 1.33.2.5
diff -u -d -r1.33.2.4 -r1.33.2.5
--- main.c	10 Aug 2006 21:14:52 -0000	1.33.2.4
+++ main.c	3 Dec 2006 13:50:42 -0000	1.33.2.5
@@ -61,20 +61,26 @@
 
 static void login_accept(void *context __attr_unused__)
 {
-	struct ip_addr ip, local_ip;
+	struct ip_addr remote_ip, local_ip;
+	unsigned int remote_port, local_port;
+	struct client *client;
 	int fd;
 
-	fd = net_accept(LOGIN_LISTEN_FD, &ip, NULL);
+	fd = net_accept(LOGIN_LISTEN_FD, &remote_ip, &remote_port);
 	if (fd < 0) {
 		if (fd < -1)
 			i_fatal("accept() failed: %m");
 		return;
 	}
 
-	if (net_getsockname(fd, &local_ip, NULL) < 0)
+	if (net_getsockname(fd, &local_ip, &local_port) < 0) {
 		memset(&local_ip, 0, sizeof(local_ip));
+		local_port = 0;
+	}
 
-	(void)client_create(fd, FALSE, &local_ip, &ip);
+	client = client_create(fd, FALSE, &local_ip, &remote_ip);
+	client->remote_port = remote_port;
+	client->local_port = local_port;
 
 	if (process_per_connection) {
 		closing_down = TRUE;
@@ -84,27 +90,32 @@
 
 static void login_accept_ssl(void *context __attr_unused__)
 {
-	struct ip_addr ip, local_ip;
+	struct ip_addr remote_ip, local_ip;
+	unsigned int remote_port, local_port;
 	struct client *client;
 	struct ssl_proxy *proxy;
 	int fd, fd_ssl;
 
-	fd = net_accept(LOGIN_SSL_LISTEN_FD, &ip, NULL);
+	fd = net_accept(LOGIN_SSL_LISTEN_FD, &remote_ip, &remote_port);
 	if (fd < 0) {
 		if (fd < -1)
 			i_fatal("accept() failed: %m");
 		return;
 	}
 
-	if (net_getsockname(fd, &local_ip, NULL) < 0)
+	if (net_getsockname(fd, &local_ip, &local_port) < 0) {
 		memset(&local_ip, 0, sizeof(local_ip));
+		local_port = 0;
+	}
 
-	fd_ssl = ssl_proxy_new(fd, &ip, &proxy);
+	fd_ssl = ssl_proxy_new(fd, &remote_ip, &proxy);
 	if (fd_ssl == -1)
 		net_disconnect(fd);
 	else {
-		client = client_create(fd_ssl, TRUE, &local_ip, &ip);
+		client = client_create(fd_ssl, TRUE, &local_ip, &remote_ip);
 		client->proxy = proxy;
+		client->remote_port = remote_port;
+		client->local_port = local_port;
 	}
 
 	if (process_per_connection) {
@@ -336,8 +347,8 @@
 int main(int argc __attr_unused__, char *argv[], char *envp[])
 {
 	const char *name, *group_name;
-	struct ip_addr ip, local_ip;
-	unsigned int local_port;
+	struct ip_addr remote_ip, local_ip;
+	unsigned int remote_port, local_port;
 	struct ssl_proxy *proxy = NULL;
 	struct client *client;
 	int i, fd = -1, master_fd = -1;
@@ -378,7 +389,7 @@
 	main_init();
 
 	if (is_inetd) {
-		if (net_getpeername(1, &ip, NULL) < 0) {
+		if (net_getpeername(1, &remote_ip, &remote_port) < 0) {
 			i_fatal("%s can be started only through dovecot "
 				"master process, inetd or equilevant", argv[0]);
 		}
@@ -398,7 +409,7 @@
 		/* hardcoded imaps and pop3s ports to be SSL by default */
 		if (local_port == 993 || local_port == 995 || ssl) {
 			ssl = TRUE;
-			fd = ssl_proxy_new(fd, &ip, &proxy);
+			fd = ssl_proxy_new(fd, &remote_ip, &proxy);
 			if (fd == -1)
 				return 1;
 		}
@@ -407,8 +418,10 @@
 		closing_down = TRUE;
 
 		if (fd != -1) {
-			client = client_create(fd, ssl, &local_ip, &ip);
+			client = client_create(fd, ssl, &local_ip, &remote_ip);
 			client->proxy = proxy;
+			client->remote_port = remote_port;
+			client->local_port = local_port;
 		}
 	}
 



More information about the dovecot-cvs mailing list