Subject: pkg/20625: cyrus daemon gets extra SIGHUP at system startup, leading to port binding failures
To: None <gnats-bugs@gnats.netbsd.org>
From: John Kohl <jtk@kolvir.arlington.ma.us>
List: netbsd-bugs
Date: 03/08/2003 14:09:35
>Number:         20625
>Category:       pkg
>Synopsis:       cyrus daemon gets extra SIGHUP at system startup, leading to port binding failures
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 08 11:10:02 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     John Kohl
>Release:        NetBSD 1.6_STABLE
>Organization:
NetBSD Kernel Hackers `R` Us
>Environment:
	
	
System: NetBSD kolvir.arlington.ma.us 1.6_STABLE NetBSD 1.6_STABLE (KOLVIR-$Revision: 1.52 $) #18: Tue Jan 21 22:24:00 EST 2003 jtk@kolvir.arlington.ma.us:/usr/u4/sandbox/src/sys/arch/i386/compile/KOLVIR i386
Architecture: i386
Machine: i386
>Description:
	The cyrus daemon (pkg/mail/cyrus-imapd) neglects to detach from
the console controlling terminal, and gets a HUP when getty starts,
leading it to reread its config files and in some cases it drops bound
ports due to permission problems.

>How-To-Repeat:
set up cyrus.conf with multiple specific addresses bound to imap or pop3.
>Fix:
Add this patch:
--- master/master.c.orig	Wed Dec 25 09:05:31 2002
+++ master/master.c	Sat Mar  8 13:18:47 2003
@@ -1020,12 +1020,16 @@
     memset(&ctable, 0, sizeof(struct centry *) * child_table_size);
 
     if (close_std) {
+#ifdef __NetBSD__
+      daemon(0,0);
+#else
       /* close stdin/out/err */
       for (fd = 0; fd < 3; fd++) {
 	close(fd);
 	if (open("/dev/null", O_RDWR, 0) != fd)
 	  fatal("couldn't open /dev/null: %m", 2);
       }
+#endif
     }
 
     /* we reserve fds 3 and 4 for children to communicate with us, so they

>Release-Note:
>Audit-Trail:
>Unformatted: