dovecot-2.0: lib-master: Fixed accepting FIFO connections with B...

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 19 20:19:58 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/565f18727209
changeset: 12011:565f18727209
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 19 18:19:53 2010 +0100
description:
lib-master: Fixed accepting FIFO connections with BSDI.

diffstat:

 src/lib-master/master-service.c |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r a83963495e55 -r 565f18727209 src/lib-master/master-service.c
--- a/src/lib-master/master-service.c	Thu Aug 19 18:06:22 2010 +0100
+++ b/src/lib-master/master-service.c	Thu Aug 19 18:19:53 2010 +0100
@@ -709,16 +709,25 @@
 	conn.listen_fd = l->fd;
 	conn.fd = net_accept(l->fd, &conn.remote_ip, &conn.remote_port);
 	if (conn.fd < 0) {
+		struct stat st;
+		int orig_errno = errno;
+
 		if (conn.fd == -1)
 			return;
 
-		if (errno != ENOTSOCK) {
+		if (errno == ENOTSOCK) {
+			/* it's not a socket. should be a fifo. */
+		} else if (errno == EINVAL &&
+			   (fstat(l->fd, &st) < 0 || !S_ISFIFO(st.st_mode))) {
+			/* BSDI fails accept(fifo) with EINVAL. */
+		} else {
+			errno = orig_errno;
 			i_error("net_accept() failed: %m");
 			master_service_error(service);
 			return;
 		}
-		/* it's not a socket. probably a fifo. use the "listener"
-		   as the connection fd and stop the listener. */
+		/* use the "listener" as the connection fd and stop the
+		   listener. */
 		conn.fd = l->fd;
 		conn.listen_fd = l->fd;
 		conn.fifo = TRUE;


More information about the dovecot-cvs mailing list