aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarol Babioch <karol@babioch.de>2018-10-14 19:58:58 (GMT)
committerJouni Malinen <j@w1.fi>2018-10-20 16:26:03 (GMT)
commitac1f5915673835ed2523342aebc51042880098c3 (patch)
tree62e8b24a94198c458efd66acb6b7db69c9a4ee83
parent1737eb39823d5265929190412a2221688f37f769 (diff)
downloadhostap-ac1f5915673835ed2523342aebc51042880098c3.zip
hostap-ac1f5915673835ed2523342aebc51042880098c3.tar.gz
hostap-ac1f5915673835ed2523342aebc51042880098c3.tar.bz2
Enable the close-on-exec flag for the debug log file descriptor
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>
-rw-r--r--src/utils/wpa_debug.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c
index 3fe14ce..a56462b 100644
--- a/src/utils/wpa_debug.c
+++ b/src/utils/wpa_debug.c
@@ -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 "