From 003f08c1642f060e57c55e950d4690d470451602 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 6 Aug 2013 16:08:31 +0200 Subject: [PATCH] clogd: fix descriptor leak when daemonzing --- WHATS_NEW | 1 + daemons/cmirrord/clogd.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index 446a85359..fd7e39f5c 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.100 - ================================ + Fix clogd descriptor leak when daemonizing. Fix clvmd descriptor leak on restart. Add pipe_open/close() to replace less secure popen() glibc call. Fix metadata area offset/size overflow if it's >= 4g and while using lvmetad. diff --git a/daemons/cmirrord/clogd.c b/daemons/cmirrord/clogd.c index adf7a925a..86d06bda9 100644 --- a/daemons/cmirrord/clogd.c +++ b/daemons/cmirrord/clogd.c @@ -202,6 +202,12 @@ static void daemonize(void) (dup2(devnull, 2) < 0)) /* reopen stderr */ exit(EXIT_FAILURE); + if ((devnull > STDERR_FILENO) && close(devnull)) { + LOG_ERROR("Failed to close descriptor %d: %s", + devnull, strerror(errno)); + exit(EXIT_FAILURE); + } + LOG_OPEN("cmirrord", LOG_PID, LOG_DAEMON); (void) dm_prepare_selinux_context(CMIRRORD_PIDFILE, S_IFREG);