@@ -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 int out_fd = -1;
static FILE *out_file = NULL;
@@ -567,6 +570,14 @@ int wpa_debug_open_file(const char *path)
return -1;
}
+#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");
+ close(out_fd);
+ return -1;
+ }
+#endif /* __linux__ */
#ifndef _WIN32
setvbuf(out_file, NULL, _IOLBF, 0);
#endif /* _WIN32 */
On Linux platforms this flag will make sure that file descriptor is 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 platform. Signed-off-by: Karol Babioch <karol@babioch.de> --- src/utils/wpa_debug.c | 11 +++++++++++ 1 file changed, 11 insertions(+)