From 152fed23797c8950ca18cf6dc2bddb61a3f615c8 Mon Sep 17 00:00:00 2001 From: Petr Cech Date: Oct 27 2015 09:44:02 +0000 Subject: DEBUG: Preventing chown_debug_file if journald on 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 --- diff --git a/src/util/debug.c b/src/util/debug.c index bd13fde..a8eea32 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;