[dovecot-cvs] dovecot/src/login client.c,1.14,1.15 client.h,1.5,1.6 common.h,1.3,1.4 main.c,1.9,1.10

cras at procontrol.fi cras at procontrol.fi
Tue Dec 3 02:13:19 EET 2002


Update of /home/cvs/dovecot/src/login
In directory danu:/tmp/cvs-serv6582/src/login

Modified Files:
	client.c client.h common.h main.c 
Log Message:
Login process now changes it's name if verbose_proctitle = yes, and we're
running BSD. This is also possible with Linux with a pretty ugly hack, which
you can enable by modifying lib/process-title.c if you _really_ want to.

And a nasty bugfix - login_process_per_connection setting didn't work with
imaps port connections which is exactly where it was mostly wanted.



Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/client.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- client.c	20 Nov 2002 19:49:11 -0000	1.14
+++ client.c	3 Dec 2002 00:13:17 -0000	1.15
@@ -5,6 +5,7 @@
 #include "ioloop.h"
 #include "ibuffer.h"
 #include "obuffer.h"
+#include "process-title.h"
 #include "client.h"
 #include "client-authenticate.h"
 #include "ssl-proxy.h"
@@ -22,6 +23,20 @@
 static HashTable *clients;
 static Timeout to_idle;
 
+static void client_set_title(Client *client)
+{
+	char host[MAX_IP_LEN];
+
+	if (!verbose_proctitle || !process_per_connection)
+		return;
+
+	if (net_ip2host(&client->ip, host) < 0)
+		strcpy(host, "??");
+
+	process_title_set(t_strdup_printf(client->tls ? "[%s TLS]" : "[%s]",
+					  host));
+}
+
 static int cmd_capability(Client *client)
 {
 	const char *capability;
@@ -63,6 +78,8 @@
 	fd_ssl = ssl_proxy_new(client->fd);
 	if (fd_ssl != -1) {
 		client->tls = TRUE;
+                client_set_title(client);
+
 		client->fd = fd_ssl;
 
 		i_buffer_unref(client->inbuf);
@@ -247,7 +264,7 @@
 	}
 }
 
-Client *client_create(int fd, IPADDR *ip)
+Client *client_create(int fd, IPADDR *ip, int imaps)
 {
 	Client *client;
 
@@ -264,6 +281,7 @@
 	client = i_new(Client, 1);
 	client->created = ioloop_time;
 	client->refcount = 1;
+	client->tls = imaps;
 
 	memcpy(&client->ip, ip, sizeof(IPADDR));
 	client->fd = fd;
@@ -277,6 +295,7 @@
 	main_ref();
 
 	client_send_line(client, "* OK " PACKAGE " ready.");
+	client_set_title(client);
 	return client;
 }
 

Index: client.h
===================================================================
RCS file: /home/cvs/dovecot/src/login/client.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- client.h	16 Nov 2002 05:21:21 -0000	1.5
+++ client.h	3 Dec 2002 00:13:17 -0000	1.6
@@ -24,7 +24,7 @@
 	unsigned int tls:1;
 };
 
-Client *client_create(int fd, IPADDR *ip);
+Client *client_create(int fd, IPADDR *ip, int imaps);
 void client_destroy(Client *client, const char *reason);
 
 void client_ref(Client *client);

Index: common.h
===================================================================
RCS file: /home/cvs/dovecot/src/login/common.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- common.h	20 Nov 2002 19:45:32 -0000	1.3
+++ common.h	3 Dec 2002 00:13:17 -0000	1.4
@@ -7,7 +7,7 @@
 typedef struct _Client Client;
 typedef struct _AuthRequest AuthRequest;
 
-extern int disable_plaintext_auth;
+extern int disable_plaintext_auth, process_per_connection, verbose_proctitle;
 extern unsigned int max_logging_users;
 
 void main_ref(void);

Index: main.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/main.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- main.c	1 Dec 2002 15:39:20 -0000	1.9
+++ main.c	3 Dec 2002 00:13:17 -0000	1.10
@@ -4,6 +4,7 @@
 #include "ioloop.h"
 #include "lib-signals.h"
 #include "restrict-access.h"
+#include "process-title.h"
 #include "fd-close-on-exec.h"
 #include "auth-connection.h"
 #include "master.h"
@@ -14,13 +15,13 @@
 #include <unistd.h>
 #include <syslog.h>
 
-int disable_plaintext_auth;
+int disable_plaintext_auth, process_per_connection, verbose_proctitle;
 unsigned int max_logging_users;
 
 static IOLoop ioloop;
 static IO io_imap, io_imaps;
 static int main_refcount;
-static int process_per_connection, closing_down;
+static int closing_down;
 
 void main_ref(void)
 {
@@ -72,10 +73,10 @@
 static void login_accept(void *context __attr_unused__, int listen_fd,
 			 IO io __attr_unused__)
 {
-	IPADDR addr;
+	IPADDR ip;
 	int fd;
 
-	fd = net_accept(listen_fd, &addr, NULL);
+	fd = net_accept(listen_fd, &ip, NULL);
 	if (fd < 0) {
 		if (fd < -1)
 			i_fatal("accept() failed: %m");
@@ -85,7 +86,7 @@
 	if (process_per_connection)
 		main_close_listen();
 
-	(void)client_create(fd, &addr);
+	(void)client_create(fd, &ip, FALSE);
 }
 
 static void login_accept_ssl(void *context __attr_unused__, int listen_fd,
@@ -102,11 +103,14 @@
 		return;
 	}
 
+	if (process_per_connection)
+		main_close_listen();
+
 	fd_ssl = ssl_proxy_new(fd);
 	if (fd_ssl == -1)
 		net_disconnect(fd);
 	else {
-		client = client_create(fd_ssl, &addr);
+		client = client_create(fd_ssl, &addr, TRUE);
 		client->tls = TRUE;
 	}
 }
@@ -134,7 +138,8 @@
 	}
 
 	disable_plaintext_auth = getenv("DISABLE_PLAINTEXT_AUTH") != NULL;
-        process_per_connection = getenv("PROCESS_PER_CONNECTION") != NULL;
+	process_per_connection = getenv("PROCESS_PER_CONNECTION") != NULL;
+        verbose_proctitle = getenv("VERBOSE_PROCTITLE") != NULL;
 
 	value = getenv("MAX_LOGGING_USERS");
 	max_logging_users = value == NULL ? 0 : strtoul(value, NULL, 10);
@@ -191,7 +196,7 @@
 	closelog();
 }
 
-int main(int argc __attr_unused__, char *argv[] __attr_unused__)
+int main(int argc __attr_unused__, char *argv[], char *envp[])
 {
 #ifdef DEBUG
         fd_debug_verify_leaks(3, 1024);
@@ -199,6 +204,7 @@
 	/* NOTE: we start rooted, so keep the code minimal until
 	   restrict_access_by_env() is called */
 	lib_init();
+        process_title_init(argv, envp);
 	ioloop = io_loop_create(system_pool);
 
 	main_init();




More information about the dovecot-cvs mailing list