>From 3fec383bd8a7efbd6a6d9f5176cced553986f636 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 21 Feb 2014 17:34:34 +0100 Subject: [PATCH] DEBUG: Keep printing messages to stderr if sssd is running interactively --- src/util/debug.c | 3 ++- src/util/server.c | 4 ++++ src/util/util.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/debug.c b/src/util/debug.c index b66de07b4e3a4549548f627f07a45f97068fa21b..bd592ca01eaecd252539213a2ae6c33deff6cc1d 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -42,6 +42,7 @@ int debug_level = SSSDBG_UNRESOLVED; int debug_timestamps = SSSDBG_TIMESTAMP_UNRESOLVED; int debug_microseconds = SSSDBG_MICROSECONDS_UNRESOLVED; int debug_to_file = 0; +int debug_fg; const char *debug_log_file = "sssd"; FILE *debug_file = NULL; @@ -212,7 +213,7 @@ void debug_fn(const char *file, errno_t ret; va_list ap_fallback; - if (!debug_file) { + if (!debug_file && debug_fg) { /* If we are not outputting logs to files, we should be sending them * to journald. * NOTE: on modern systems, this is where stdout/stderr will end up diff --git a/src/util/server.c b/src/util/server.c index 24c3548ed32112a55e1b69202da3e7ff88bb0f15..8c523329a0c7a84bc1fe69680a9b3faafb3e1b08 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -564,9 +564,13 @@ int server_setup(const char *name, int flags, if (flags & FLAGS_INTERACTIVE) { /* terminate when stdin goes away */ stdin_event_flags = TEVENT_FD_READ; + /* debug messages should go directory to stderr */ + debug_fg = 1; } else { /* stay alive forever */ stdin_event_flags = 0; + /* debug messages should go to journal if configured */ + debug_fg = 0; } /* catch EOF on stdin */ diff --git a/src/util/util.h b/src/util/util.h index c74ff5b56fdcb362386e4bb01bd293d7e3bf42a1..4e75830e1cb26eca249d5a04c5bb1184d84908d6 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -68,6 +68,7 @@ extern int debug_timestamps; extern int debug_microseconds; extern int debug_to_file; extern const char *debug_log_file; +extern int debug_fg; void debug_fn(const char *file, long line, const char *function, -- 1.8.5.3