]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Enable the close-on-exec flag for the debug log file descriptor
authorKarol Babioch <karol@babioch.de>
Sun, 14 Oct 2018 19:58:58 +0000 (21:58 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 20 Oct 2018 16:26:03 +0000 (19:26 +0300)
On Linux this flag will make sure that no file descriptor is
accidentally leaked into potential child processes. While this is not a
problem right now, it is considered to be good practice these days when
dealing with file descriptors on Linux.

Signed-off-by: Karol Babioch <karol@babioch.de>
src/utils/wpa_debug.c

index 3fe14ce270b58178a5b215f76f12da407a26793d..a56462b8bbdc75724ad8117751414512d4f272a6 100644 (file)
@@ -563,6 +563,14 @@ int wpa_debug_open_file(const char *path)
                return -1;
        }
 
+#ifdef __linux__
+       if (fcntl(out_fd, F_SETFD, FD_CLOEXEC) < 0) {
+               wpa_printf(MSG_DEBUG,
+                          "%s: Failed to set FD_CLOEXEC - continue without: %s",
+                          __func__, strerror(errno));
+       }
+#endif /* __linux__ */
+
        out_file = fdopen(out_fd, "a");
        if (out_file == NULL) {
                wpa_printf(MSG_ERROR, "wpa_debug_open_file: Failed to open "