Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37808947
en ru br
Репозитории ALT
S:1.4-alt1.qa1
5.1: 1.4-alt1
4.1: 1.4-alt1
www.altlinux.org/Changes

Группа :: Система/Серверы
Пакет: smtptrapd

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: smtptrapd-1.4-alt-pidfile.patch
Скачать


Adding support for pid file
--- smtptrapd.c.orig	2008-01-05 21:39:36 +0300
+++ smtptrapd.c	2008-01-05 21:39:57 +0300
@@ -76,6 +76,7 @@
 	char *chroot_dir;
 	char *banner;
 	char *username;
+	char *pidfile;
 	struct in_addr local_ip;
 	short bind_local;
 	int port;
@@ -121,6 +122,7 @@
 
 int drop_priv(void) {
 	struct passwd *p;
+	FILE *pidfile;
 
 	p = getpwnam((config.username == NULL) ?  
 	               UNPRIV_USER : config.username);
@@ -131,6 +133,23 @@
 		return -1;
 	}
 
+        if (config.pidfile) {
+                /* write to pid file */
+                if ((pidfile=fopen(config.pidfile, "w")) == NULL) {
+                        syslog(LOG_CRIT, "error: could not open pid file %s: %s", 
+			                 config.pidfile, strerror(errno));
+                        return -1;
+                }
+                fprintf(pidfile, "%d\n", (unsigned int)getpid());
+
+                /* we're done, clean up */
+                if (fclose(pidfile) != 0) {
+                        syslog(LOG_CRIT, "error: could not close pid file %s: %s", 
+			                 config.pidfile, strerror(errno));
+                        return -1;
+		}
+        }
+
 	if (config.chroot_dir != NULL) {
 
 		if (chdir(config.chroot_dir) != 0)
@@ -181,7 +200,7 @@
 
 			char buf[BUFSIZ];
 			struct sockaddr_in addr;
-			int addrlen = sizeof(addr);
+			unsigned int addrlen = sizeof(addr);
 
 			pthread_mutex_unlock(&queue.mutex);
 
@@ -270,7 +289,7 @@
 	int state = SMTP_STATE_NONE;
 	char buf[BUFSIZ], from[LOG_SIZ], rcpt[LOG_SIZ];
 	struct sockaddr_in addr;
-	int addrlen = sizeof(addr);
+	unsigned int addrlen = sizeof(addr);
 	int i = 0, etime = 0, itime = time(NULL);
 
 	/* some nice initialisation of strings */
@@ -452,11 +471,12 @@
 	config.chroot_dir = NULL;
 	config.username = NULL;
 	config.banner = NULL;
+	config.pidfile = NULL;
 	config.port = LISTEN_PORT;
 	config.threads = NUM_CONSUMER;
 	config.max_queue_len = MAX_QUEUE_LEN;
 
-	while ((c = getopt(argc, argv, "hc:l:p:b:u:m:t:")) != -1) {
+	while ((c = getopt(argc, argv, "hc:l:p:b:u:m:t:f:")) != -1) {
 		switch (c) {
 			case 'h':
 
@@ -467,7 +487,8 @@
 				       "-u [username] "
 				       "-t [number of threads] "
 				       "-p [listen port] "
-				       "-m [max accept queue length]");
+				       "-m [max accept queue length] "
+				       "-f [pid file path]" );
 
 				exit(EX_USAGE);
 
@@ -486,6 +507,10 @@
 				config.chroot_dir = strdup(optarg);
 			break;
 
+			case 'f':
+				config.pidfile = strdup(optarg);
+			break;
+
 			case 'b':
 				config.banner = strdup(optarg);
 			break;
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin