From 152fed23797c8950ca18cf6dc2bddb61a3f615c8 Mon Sep 17 00:00:00 2001 From: Petr Cech Date: Thu, 10 Sep 2015 10:05:59 -0400 Subject: DEBUG: Preventing chown_debug_file if journald on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is function chown_debug_file() which didn't check if the SSSD is compiled with journald support. This patch add simple checking of this state. Resolves: https://fedorahosted.org/sssd/ticket/2493 Reviewed-by: Lukáš Slebodník --- src/util/debug.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/util/debug.c') diff --git a/src/util/debug.c b/src/util/debug.c index bd13fdec..a8eea327 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -316,24 +316,27 @@ int chown_debug_file(const char *filename, const char *log_file; errno_t ret; - if (filename == NULL) { - log_file = debug_log_file; - } else { - log_file = filename; - } + if (debug_file) { - ret = asprintf(&logpath, "%s/%s.log", LOG_PATH, log_file); - if (ret == -1) { - return ENOMEM; - } + if (filename == NULL) { + log_file = debug_log_file; + } else { + log_file = filename; + } - ret = chown(logpath, uid, gid); - free(logpath); - if (ret != 0) { - ret = errno; - DEBUG(SSSDBG_FATAL_FAILURE, "chown failed for [%s]: [%d]\n", - log_file, ret); - return ret; + ret = asprintf(&logpath, "%s/%s.log", LOG_PATH, log_file); + if (ret == -1) { + return ENOMEM; + } + + ret = chown(logpath, uid, gid); + free(logpath); + if (ret != 0) { + ret = errno; + DEBUG(SSSDBG_FATAL_FAILURE, "chown failed for [%s]: [%d]\n", + log_file, ret); + return ret; + } } return EOK; -- cgit