[dovecot-cvs] dovecot/src/login-common client-common.h, 1.5, 1.6 main.c, 1.16, 1.17 master.c, 1.8, 1.9

cras at procontrol.fi cras at procontrol.fi
Mon May 31 21:04:49 EEST 2004


Update of /home/cvs/dovecot/src/login-common
In directory talvi:/tmp/cvs-serv4696/src/login-common

Modified Files:
	client-common.h main.c master.c 
Log Message:
Added %l, %r and %P variables and mail_log_prefix setting.



Index: client-common.h
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/client-common.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/client-common.h	17 May 2004 01:32:17 -0000	1.5
+++ b/client-common.h	31 May 2004 18:04:47 -0000	1.6
@@ -5,6 +5,7 @@
 #include "master.h"
 
 struct client {
+	struct ip_addr local_ip;
 	struct ip_addr ip;
 	struct ssl_proxy *proxy;
 
@@ -19,7 +20,8 @@
 	/* ... */
 };
 
-struct client *client_create(int fd, struct ip_addr *ip, int ssl);
+struct client *client_create(int fd, int ssl, const struct ip_addr *local_ip,
+			     const struct ip_addr *ip);
 
 unsigned int clients_get_count(void);
 void clients_notify_auth_connected(void);

Index: main.c
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/main.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- a/main.c	17 May 2004 01:32:17 -0000	1.16
+++ b/main.c	31 May 2004 18:04:47 -0000	1.17
@@ -76,7 +76,7 @@
 
 static void login_accept(void *context __attr_unused__)
 {
-	struct ip_addr ip;
+	struct ip_addr ip, local_ip;
 	int fd;
 
 	fd = net_accept(LOGIN_LISTEN_FD, &ip, NULL);
@@ -89,12 +89,15 @@
 	if (process_per_connection)
 		main_close_listen();
 
-	(void)client_create(fd, &ip, FALSE);
+	if (net_getsockname(fd, &local_ip, NULL) < 0)
+		memset(&local_ip, 0, sizeof(local_ip));
+
+	(void)client_create(fd, FALSE, &local_ip, &ip);
 }
 
 static void login_accept_ssl(void *context __attr_unused__)
 {
-	struct ip_addr ip;
+	struct ip_addr ip, local_ip;
 	struct client *client;
 	struct ssl_proxy *proxy;
 	int fd, fd_ssl;
@@ -108,12 +111,14 @@
 
 	if (process_per_connection)
 		main_close_listen();
+	if (net_getsockname(fd, &local_ip, NULL) < 0)
+		memset(&local_ip, 0, sizeof(local_ip));
 
 	fd_ssl = ssl_proxy_new(fd, &ip, &proxy);
 	if (fd_ssl == -1)
 		net_disconnect(fd);
 	else {
-		client = client_create(fd_ssl, &ip, TRUE);
+		client = client_create(fd_ssl, TRUE, &local_ip, &ip);
 		client->proxy = proxy;
 	}
 }
@@ -216,7 +221,7 @@
 int main(int argc __attr_unused__, char *argv[], char *envp[])
 {
 	const char *name, *group_name;
-	struct ip_addr ip;
+	struct ip_addr ip, local_ip;
 	struct ssl_proxy *proxy = NULL;
 	struct client *client;
 	int i, fd = -1, master_fd = -1;
@@ -256,10 +261,12 @@
 	main_init();
 
 	if (is_inetd) {
-		if (net_getsockname(1, &ip, NULL) < 0) {
+		if (net_getpeername(1, &ip, NULL) < 0) {
 			i_fatal("%s can be started only through dovecot "
 				"master process, inetd or equilevant", argv[0]);
 		}
+		if (net_getsockname(1, &local_ip, NULL) < 0)
+			memset(&local_ip, 0, sizeof(local_ip));
 
 		fd = 1;
 		for (i = 1; i < argc; i++) {
@@ -273,11 +280,11 @@
 
 		master_init(master_fd, FALSE);
 		closing_down = TRUE;
-	}
 
-	if (fd != -1) {
-		client = client_create(fd, &ip, TRUE);
-		client->proxy = proxy;
+		if (fd != -1) {
+			client = client_create(fd, TRUE, &local_ip, &ip);
+			client->proxy = proxy;
+		}
 	}
 
 	io_loop_run(ioloop);

Index: master.c
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/master.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- a/master.c	22 Aug 2003 03:34:04 -0000	1.8
+++ b/master.c	31 May 2004 18:04:47 -0000	1.9
@@ -49,7 +49,8 @@
 		req.tag = ++master_tag_counter;
 	req.auth_pid = auth_pid;
 	req.auth_id = auth_id;
-	req.ip = client->ip;
+	req.local_ip = client->local_ip;
+	req.remote_ip = client->ip;
 
 	if (fd_send(master_fd, client->fd, &req, sizeof(req)) != sizeof(req))
 		i_fatal("fd_send(%d) failed: %m", client->fd);



More information about the dovecot-cvs mailing list