[dovecot-cvs] dovecot/src/master common.h,1.3,1.4 imap-process.c,1.5,1.6 login-process.c,1.6,1.7 master-interface.h,1.1.1.1,1.2 settings.c,1.11,1.12 settings.h,1.5,1.6

cras at procontrol.fi cras at procontrol.fi
Wed Nov 6 16:20:53 EET 2002


Update of /home/cvs/dovecot/src/master
In directory danu:/tmp/cvs-serv6413/src/master

Modified Files:
	common.h imap-process.c login-process.c master-interface.h 
	settings.c settings.h 
Log Message:
Added verbose_proctitle setting: Show more verbose process titles (in ps).
Currently shows user name and IP address. Useful for seeing who are actually
using the IMAP processes (eg. shared mailboxes or if same uid is used for
multiple accounts).



Index: common.h
===================================================================
RCS file: /home/cvs/dovecot/src/master/common.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- common.h	29 Sep 2002 17:54:47 -0000	1.3
+++ common.h	6 Nov 2002 14:20:50 -0000	1.4
@@ -32,9 +32,9 @@
 
 void clean_child_process(void);
 
-MasterReplyResult
-create_imap_process(int socket, const char *user, uid_t uid, gid_t gid,
-		    const char *home, int chroot, const char *env[]);
+MasterReplyResult create_imap_process(int socket, IPADDR *ip, const char *user,
+				      uid_t uid, gid_t gid, const char *home,
+				      int chroot, const char *env[]);
 void imap_process_destroyed(pid_t pid);
 
 /* misc */

Index: imap-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/imap-process.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- imap-process.c	21 Oct 2002 00:09:29 -0000	1.5
+++ imap-process.c	6 Nov 2002 14:20:50 -0000	1.6
@@ -60,11 +60,12 @@
 	return FALSE;
 }
 
-MasterReplyResult
-create_imap_process(int socket, const char *user, uid_t uid, gid_t gid,
-		    const char *home, int chroot, const char *env[])
+MasterReplyResult create_imap_process(int socket, IPADDR *ip, const char *user,
+				      uid_t uid, gid_t gid, const char *home,
+				      int chroot, const char *env[])
 {
-	static char *argv[] = { NULL, "-s", NULL };
+	static char *argv[] = { NULL, "-s", NULL, NULL };
+	char host[MAX_IP_LEN], title[1024];
 	pid_t pid;
 	int i, j, err;
 
@@ -129,6 +130,11 @@
 		putenv("OVERWRITE_INCOMPATIBLE_INDEX=1");
 	if (umask(set_umask) != set_umask)
 		i_fatal("Invalid umask: %o", set_umask);
+
+	if (set_verbose_proctitle && net_ip2host(ip, host) == 0) {
+		i_snprintf(title, sizeof(title), "[%s %s]", user, host);
+		argv[2] = title;
+	}
 
 	/* setup access environment - needs to be done after
 	   clean_child_process() since it clears environment */

Index: login-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/login-process.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- login-process.c	28 Oct 2002 04:18:26 -0000	1.6
+++ login-process.c	6 Nov 2002 14:20:50 -0000	1.7
@@ -30,6 +30,7 @@
 	int auth_id;
 	int fd;
 
+	IPADDR ip;
 	char login_tag[LOGIN_TAG_SIZE];
 } LoginAuthRequest;
 
@@ -58,6 +59,7 @@
 		reply.result = MASTER_RESULT_FAILURE;
 	else {
 		reply.result = create_imap_process(request->fd,
+						   &request->ip,
 						   cookie_reply->user,
 						   cookie_reply->uid,
 						   cookie_reply->gid,
@@ -116,6 +118,7 @@
 	authreq->login_id = req.id;
 	authreq->auth_id = ++auth_id_counter;
 	authreq->fd = client_fd;
+	memcpy(&authreq->ip, &req.ip, sizeof(IPADDR));
 	strcpy(authreq->login_tag, req.login_tag);
 
 	auth_process = auth_process_find(req.auth_process);

Index: master-interface.h
===================================================================
RCS file: /home/cvs/dovecot/src/master/master-interface.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- master-interface.h	9 Aug 2002 09:15:56 -0000	1.1.1.1
+++ master-interface.h	6 Nov 2002 14:20:50 -0000	1.2
@@ -1,6 +1,7 @@
 #ifndef __MASTER_INTERFACE_H
 #define __MASTER_INTERFACE_H
 
+#include "network.h"
 #include "../auth/auth-interface.h"
 
 #define LOGIN_TAG_SIZE 32
@@ -21,6 +22,7 @@
 	int auth_process;
 	unsigned char cookie[AUTH_COOKIE_SIZE];
 
+	IPADDR ip;
 	char login_tag[LOGIN_TAG_SIZE];
 } MasterRequest;
 

Index: settings.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/settings.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- settings.c	21 Oct 2002 00:09:29 -0000	1.11
+++ settings.c	6 Nov 2002 14:20:50 -0000	1.12
@@ -40,11 +40,12 @@
 	{ "login_dir",		SET_STR, &set_login_dir },
 	{ "login_chroot",	SET_BOOL,&set_login_chroot },
 	{ "login_processes_count", SET_INT, &set_login_processes_count },
-
 	{ "max_logging_users",	SET_INT, &set_max_logging_users },
+
 	{ "imap_executable",	SET_STR, &set_imap_executable },
 	{ "valid_chroot_dirs",	SET_STR, &set_valid_chroot_dirs },
 	{ "max_imap_processes",	SET_INT, &set_max_imap_processes },
+	{ "verbose_proctitle",	SET_BOOL,&set_verbose_proctitle },
 	{ "first_valid_uid",	SET_INT, &set_first_valid_uid },
 	{ "last_valid_uid",	SET_INT, &set_last_valid_uid },
 	{ "first_valid_gid",	SET_INT, &set_first_valid_gid },
@@ -94,6 +95,7 @@
 char *set_imap_executable = PKG_LIBDIR "/imap";
 char *set_valid_chroot_dirs = NULL;
 unsigned int set_max_imap_processes = 1024;
+int set_verbose_proctitle = FALSE;
 
 unsigned int set_first_valid_uid = 500, set_last_valid_uid = 0;
 unsigned int set_first_valid_gid = 1, set_last_valid_gid = 0;

Index: settings.h
===================================================================
RCS file: /home/cvs/dovecot/src/master/settings.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- settings.h	21 Oct 2002 00:09:29 -0000	1.5
+++ settings.h	6 Nov 2002 14:20:50 -0000	1.6
@@ -30,6 +30,7 @@
 extern char *set_imap_executable;
 extern char *set_valid_chroot_dirs;
 extern unsigned int set_max_imap_processes;
+extern int set_verbose_proctitle;
 
 extern unsigned int set_first_valid_uid, set_last_valid_uid;
 extern unsigned int set_first_valid_gid, set_last_valid_gid;




More information about the dovecot-cvs mailing list