From: Timo Sirainen Date: Thu, 19 Aug 2010 17:19:53 +0000 (+0100) Subject: lib-master: Fixed accepting FIFO connections with BSDI. X-Git-Tag: 2.0.1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=835ba470fb6a73b74e258e12678236106d0df09e;p=thirdparty%2Fdovecot%2Fcore.git lib-master: Fixed accepting FIFO connections with BSDI. --- diff --git a/src/lib-master/master-service.c b/src/lib-master/master-service.c index 38f64a1c65..54d1d38686 100644 --- a/src/lib-master/master-service.c +++ b/src/lib-master/master-service.c @@ -709,16 +709,25 @@ static void master_service_listen(struct master_service_listener *l) 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;