2018-10-12 08:28:01 +00:00
|
|
|
From a386bc4950e02975ba9a21a5be82e91a53ec9281 Mon Sep 17 00:00:00 2001
|
2018-10-12 07:03:14 +00:00
|
|
|
From: Karol Babioch <karol@babioch.de>
|
|
|
|
Date: Thu, 11 Oct 2018 21:22:03 +0200
|
2018-10-12 08:28:01 +00:00
|
|
|
Subject: [PATCH v3 2/2] Enable the close-on-exec flag for the debug log file
|
2018-10-12 07:03:14 +00:00
|
|
|
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 the Linux.
|
|
|
|
|
|
|
|
Signed-off-by: Karol Babioch <karol@babioch.de>
|
|
|
|
---
|
2018-10-12 08:28:01 +00:00
|
|
|
src/utils/wpa_debug.c | 10 ++++++++++
|
|
|
|
1 file changed, 10 insertions(+)
|
2018-10-12 07:03:14 +00:00
|
|
|
|
|
|
|
diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c
|
2018-10-12 08:28:01 +00:00
|
|
|
index 5d2f7becb..12873737c 100644
|
2018-10-12 07:03:14 +00:00
|
|
|
--- a/src/utils/wpa_debug.c
|
|
|
|
+++ b/src/utils/wpa_debug.c
|
|
|
|
@@ -60,6 +60,9 @@ static int wpa_to_android_level(int level)
|
|
|
|
#ifdef CONFIG_DEBUG_FILE
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
+#ifdef __linux__
|
|
|
|
+#include <fcntl.h>
|
|
|
|
+#endif /* __linux__ */
|
|
|
|
|
|
|
|
static FILE *out_file = NULL;
|
2018-10-12 08:28:01 +00:00
|
|
|
#endif /* CONFIG_DEBUG_FILE */
|
|
|
|
@@ -566,6 +569,13 @@ int wpa_debug_open_file(const char *path)
|
|
|
|
close(out_fd);
|
2018-10-12 07:03:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2018-10-12 08:28:01 +00:00
|
|
|
+
|
2018-10-12 07:03:14 +00:00
|
|
|
+#ifdef __linux__
|
|
|
|
+ if (fcntl(out_fd, F_SETFD, FD_CLOEXEC) == -1) {
|
|
|
|
+ wpa_printf(MSG_ERROR, "wpa_debug_open_file: Failed to set O_CLOEXEC "
|
|
|
|
+ "on output file descriptor, using standard output");
|
|
|
|
+ }
|
|
|
|
+#endif /* __linux__ */
|
|
|
|
#ifndef _WIN32
|
|
|
|
setvbuf(out_file, NULL, _IOLBF, 0);
|
|
|
|
#endif /* _WIN32 */
|
|
|
|
--
|
|
|
|
2.19.1
|
|
|
|
|