diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2012-12-15 19:56:33 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-05-16 18:52:35 +0200 |
commit | 2cdff52874e8cd7d9584e164bd55713fec467b9c (patch) | |
tree | 3cdfd7c5c7c129f91d4ccf7b94eff7378d2d8622 | |
parent | 127b7731f3e6a3d665c35fbca93f0c2bdb9a0983 (diff) | |
download | sssd-2cdff52874e8cd7d9584e164bd55713fec467b9c.tar.gz sssd-2cdff52874e8cd7d9584e164bd55713fec467b9c.tar.xz sssd-2cdff52874e8cd7d9584e164bd55713fec467b9c.zip |
Set cloexec flag for log files
https://fedorahosted.org/sssd/ticket/1708
The services kept the fd to /var/log/sssd/sssd.log open. I don't think
there's any point in keeping the logfiles open after exec-ing for the
child, so I set the CLOEXEC flag.
-rw-r--r-- | src/util/debug.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/debug.c b/src/util/debug.c index 1b78ebaef..ee25d3120 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -23,6 +23,7 @@ #include <stdio.h> #include <stdarg.h> #include <stdlib.h> +#include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> @@ -117,6 +118,8 @@ int open_debug_file_ex(const char *filename, FILE **filep) const char *log_file; mode_t old_umask; int ret; + int debug_fd; + int flags; if (filename == NULL) { log_file = debug_log_file; @@ -142,6 +145,14 @@ int open_debug_file_ex(const char *filename, FILE **filep) } umask(old_umask); + debug_fd = fileno(f); + if (debug_fd == -1) { + return EIO; + } + + flags = fcntl(debug_fd, F_GETFD, 0); + (void) fcntl(debug_fd, F_SETFD, flags | FD_CLOEXEC); + if (filep == NULL) { debug_file = f; } else { |