]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: Fixed accepting FIFO connections with BSDI.
authorTimo Sirainen <tss@iki.fi>
Thu, 19 Aug 2010 17:19:53 +0000 (18:19 +0100)
committerTimo Sirainen <tss@iki.fi>
Thu, 19 Aug 2010 17:19:53 +0000 (18:19 +0100)
src/lib-master/master-service.c

index 38f64a1c65d20feff242946df08537d3b3a4a3c7..54d1d38686b53c58883f5f06c8fe3ac8d7b95e83 100644 (file)
@@ -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;