On (14/09/15 16:36), Petr Cech wrote:
>On 09/11/2015 11:02 AM, Lukas Slebodnik wrote:
>>I do not understand how is the function chown_debug_file related to journald.
>>sssd can be compiled with journald support and in the same time can log to the
>>files. This is a default for fedora and rehl7.
>>
>>If someone want to enable logging all messages to journald then it is required
>>manula change to the file /etc/systemd/system/sssd.service.d/journal.conf
>>
>>
>>LS
>
>Right, thanks, it wasn't good way how to fix it. There is another fixing
>patch attached.
>
>I used variable debug_file which inform us if we use logfiles.
>And I hope that I can ignore variable debug_to_stderr.
>
>Petr
>From 8cb0a4a6b59259e9096ae6f5926595b7b10d6b27 Mon Sep 17 00:00:00 2001
>From: Petr Cech <pcech(a)redhat.com>
>Date: Thu, 10 Sep 2015 10:05:59 -0400
>Subject: [PATCH] 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
>---
> src/util/debug.c | 35 +++++++++++++++++++----------------
> 1 file changed, 19 insertions(+), 16 deletions(-)
>
>diff --git a/src/util/debug.c b/src/util/debug.c
>index
69df54386101973548108c3194a1bfd111f046f0..b6ab368db824bbd297dcb410c3e669d911ff0d33 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;
ACK
The error message is not displayed when logging to journald or to stderr.
Becasue if debug_file is not set then we will not log to files and
in this case it does not make sense to call chown().
http://sssd-ci.duckdns.org/logs/job/31/41/summary.html
BTW we could see the error message in cwrap test.
src/tests/cwrap/server-tests.log
master:
* 152fed23797c8950ca18cf6dc2bddb61a3f615c8
sssd-1-13:
* 6e2822b151c21ce6e3287a0cf25d40e9f10a6127
LS