]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: log: don't CLOEXEC the inherited FDs
authorWilliam Lallemand <wlallemand@haproxy.com>
Tue, 13 Nov 2018 17:30:12 +0000 (18:30 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 13 Nov 2018 18:32:45 +0000 (19:32 +0100)
When configuring the logs with a FD and using the master worker, the FD
was closed upon a reload because it was configured with CLOEXEC. It
leads to using the wrong FD for the logs and to close them. Which is
unfortunate since the master rely on the FD left opened during a reload.

The fix is to stop doing a CLOEXEC when the FD is inherited.
No backport needed.

src/log.c

index f6eeacbec9bf1d00a3cadaa23fc9a7aa808a363c..896219468688f991757e7ebf4524e70dfca91255 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1378,12 +1378,13 @@ void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd
                                                 nblogger, strerror(errno), errno);
                                }
                                continue;
+                       } else {
+                               /* we don't want to receive anything on this socket */
+                               setsockopt(*plogfd, SOL_SOCKET, SO_RCVBUF, &zero, sizeof(zero));
+                               /* does nothing under Linux, maybe needed for others */
+                               shutdown(*plogfd, SHUT_RD);
+                               fcntl(*plogfd, F_SETFD, fcntl(*plogfd, F_GETFD, FD_CLOEXEC) | FD_CLOEXEC);
                        }
-                       /* we don't want to receive anything on this socket */
-                       setsockopt(*plogfd, SOL_SOCKET, SO_RCVBUF, &zero, sizeof(zero));
-                       /* does nothing under Linux, maybe needed for others */
-                       shutdown(*plogfd, SHUT_RD);
-                       fcntl(*plogfd, F_SETFD, fcntl(*plogfd, F_GETFD, FD_CLOEXEC) | FD_CLOEXEC);
                }
 
                switch (logsrv->format) {