On Tue, Jul 08, 2014 at 09:53:50AM +0200, Sumit Bose wrote:
> On Mon, Jul 07, 2014 at 10:20:21PM +0200, Jakub Hrozek wrote:
> > On Mon, Jul 07, 2014 at 03:57:28PM +0200, Sumit Bose wrote:
> > > On Mon, Jul 07, 2014 at 03:21:54PM +0200, Jakub Hrozek wrote:
> > > > On Tue, Jun 03, 2014 at 09:53:13AM +0200, Jakub Hrozek wrote:
> > > > > On Mon, Feb 24, 2014 at 08:39:25AM -0500, Simo Sorce wrote:
> > > > > > On Mon, 2014-02-24 at 11:54 +0100, Jakub Hrozek wrote:
> > > > > > > On Thu, Feb 20, 2014 at 08:47:30AM -0500, Stephen Gallagher wrote:
> > > > > > > > -----BEGIN PGP SIGNED MESSAGE-----
> > > > > > > > Hash: SHA1
> > > > > > > > 
> > > > > > > > On 02/19/2014 05:18 PM, Lukas Slebodnik wrote:
> > > > > > > > > On (19/02/14 22:03), Sumit Bose wrote:
> > > > > > > > >> On Wed, Feb 19, 2014 at 09:04:48PM +0100, Lukas Slebodnik 
> > > > > > > > >> wrote:
> > > > > > > > >>> On (19/02/14 12:37), Jakub Hrozek wrote:
> > > > > > > > >>>> On Wed, Feb 19, 2014 at 12:02:23PM +0100, Jakub Hrozek
> > > > > > > > >>>> wrote:
> > > > > > > > >>>>>> I realized I made a mistake in the rebasing above. I
> > > > > > > > >>>>>> fixed that and then needed to do another manual rebase of
> > > > > > > > >>>>>> these patches atop it. These patches apply atop the
> > > > > > > > >>>>>> "[SSSD] DEBUG macro refactoring v6" patches.
> > > > > > > > >>>>> 
> > > > > > > > >>>>> These patches work for me, so ACK.
> > > > > > > > >>>> 
> > > > > > > > >>>> Pushed to master.
> > > > > > > > >>> 
> > > > > > > > >>> find_uid-tests failed with these patches on fedora20. 
> > > > > > > > >>> http://kojipkgs.fedoraproject.org//work/tasks/8367/6548367/build.log
> > > > > > > > >>
> > > > > > > > >>
> > > > > > > > >>> 
> > > > > > > > Do you have additional patches in this build?
> > > > > > > > >> 
> > > > > > > > >> /builddir/build/SRPMS/sssd-1.11.90-0.20140219.1816.git22a9323._temp.fc20.src.rpm
> > > > > > > > >>
> > > > > > > > >>
> > > > > > > > >> 
> > > > > > > > The git hash does not look like anything from master.
> > > > > > > > >> 
> > > > > > > > > Yes, I was testing some patches.
> > > > > > > > > 
> > > > > > > > >> I started a koji build 
> > > > > > > > >> http://koji.fedoraproject.org/koji/taskinfo?taskID=6549081 
> > > > > > > > >> with
> > > > > > > > >> current master (4cde267bec52ae1723a125d19439a5c75b47ebb7) 
> > > > > > > > >> which
> > > > > > > > >> is working fine.
> > > > > > > > >> 
> > > > > > > > > I tried one more time with master and koji works fine. 
> > > > > > > > > Unfortunately, I am able to reproduce it locally in mock :-(
> > > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > I've seen that happen intermittently as well in mock and koji. I
> > > > > > > > suspect there may be a bug/race condition in 
> > > > > > > > sd_uid_get_sessions(),
> > > > > > > > but I can't reproduce it consistently (and the DEBUG error 
> > > > > > > > doesn't
> > > > > > > > seem to fire...)
> > > > > > > > 
> > > > > > > > A quick look at the code suggests that we're probably missing a
> > > > > > > > 'return EOK' after '*result = false', though.
> > > > > > > > 
> > > > > > > > I'll run a couple tests and see if that fixes the issue...
> > > > > > > 
> > > > > > > I found another issue related to journald support..if you compile 
> > > > > > > sssd
> > > > > > > with journald support and run it on the foreground (-i) then the 
> > > > > > > debug
> > > > > > > messages are still redirected to journal. That seems strange to 
> > > > > > > me, but
> > > > > > > also in line with what a comment in the code says:
> > > > > > > 
> > > > > > >          /* 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
> > > > > > > 
> > > > > > > So I'm not entirely sure about the expected behaviour, but I would
> > > > > > > prefer if there was still a way to see the debug messages 
> > > > > > > directly on
> > > > > > > the console.
> > > > > > > 
> > > > > > > I hacked up a patch that also adds a third state where if sssd is 
> > > > > > > running
> > > > > > > on the foreground even with journald support, then just fprintf 
> > > > > > > is used.
> > > > > > > See the attachment.
> > > > > > 
> > > > > > Wouldn't it be simpler to just set debug_file = stderr ?
> > > > > 
> > > > > I tried to go this way, but it seems actually harder to me..
> > > > > 
> > > > > To summarize:
> > > > > with "sssd -f" debug_file should be a log file
> > > > > with "sssd" debug_file should be NULL, indicating journald
> > > > > with "sssd -i", debug_file should be stderr, indicating stderr.
> > > > > 
> > > > > The problem is, that we don't pass the "-i" flag down to the 
> > > > > responders
> > > > > and back ends when forking them. So the alternative would be to add 
> > > > > "-i"
> > > > > to sssd_be and all responders, pass the flag to the child processes 
> > > > > and
> > > > > only set debug_file to stderr if '-i' is present. If you prefer this 
> > > > > way,
> > > > > I can prepare a patch along these lines.
> > > > > 
> > > > > But then we also terminate the process which is running with "-i" if 
> > > > > its
> > > > > stdin goes away, I guess it would be safe to keep this logic since 
> > > > > stdin
> > > > > in the child processes is /dev/null already, I just wanted to mention
> > > > > there is a number of cases to test..
> > > > 
> > > > Any opinions? I'd like to fix this bug before tagging 1.12.0..
> > > 
> > > Maybe having an option --debug-to-stdout would be nicer for the child
> > > processes because it fits better to the existing SSSD_DEBUG_OPTS and
> > > will have no additional meaning as -i? For the monitor this option
> > > should be rejected and hidden from the help.
> > > 
> > > bye,
> > > Sumit
> > 
> > Perhaps..
> > 
> > to clarify, you're suggesting that --debug-to-stdout would be added to
> > all processes (monitor and child), but only child processes in libexec
> > would expose it and this option would be used when spawning the child
> > processes?
> 
> yes, my idea was to add it to SSSD_DEBUG_OPTS which would make it
> immediately available to all processes. But having it for the monitor
> make no sense because '-D --debug-to-stdout' and '-f --debug-to-stdout'
> are config errors and '-i --debug-to-stdout' is a no-op.
> 
> bye,
> Sumit

Patches are attached. I found out the same issue also affected the CLI
tools and tests, which is fixed with the second patch.

In order to test, you need to run configure --with-initscript=systemd
--with-systemdunitdir=/usr/lib/systemd/system --with-syslog=journald 

sssd -i -d <N>  logs to stderr
sssd -i -f -d <N> logs to files
sssd -D -d <N> logs to journald
sssd -D -f -d <N> logs to files

It's not possible to log to journald when running on the foreground or
to stderr when running as deamon.
>From 67c8d8be3030a1cf3dbda14bd74f3c4308190642 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhro...@redhat.com>
Date: Tue, 8 Jul 2014 15:05:24 +0200
Subject: [PATCH 1/2] SSSD: Send debug to stderr when running on foreground

https://fedorahosted.org/sssd/ticket/2348

When SSSD is running in interactive mode, we should print DEBUG messages
directly to stderr, not journal.
---
 src/monitor/monitor.c           | 21 ++++++++++++++++++++-
 src/providers/ldap/ldap_child.c |  2 ++
 src/util/child_common.c         | 10 ++++++++++
 src/util/debug.c                |  3 ++-
 src/util/util.h                 |  3 +++
 5 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 
5feba706af63e579403296329e3275c7ba8c12e9..39f4e6437e1a60c830a30b4596a385b3c54ea167
 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1124,6 +1124,14 @@ static int get_service_config(struct mt_ctx *ctx, const 
char *name,
                 talloc_free(svc);
                 return ENOMEM;
             }
+        } else if (ctx->is_daemon == false) {
+            svc->command = talloc_strdup_append(
+                svc->command, " --debug-to-stderr"
+            );
+            if (!svc->command) {
+                talloc_free(svc);
+                return ENOMEM;
+            }
         }
     }
 
@@ -1287,6 +1295,14 @@ static int get_provider_config(struct mt_ctx *ctx, const 
char *name,
                 talloc_free(svc);
                 return ENOMEM;
             }
+        } else if (ctx->is_daemon == false) {
+            svc->command = talloc_strdup_append(
+                svc->command, " --debug-to-stderr"
+            );
+            if (!svc->command) {
+                talloc_free(svc);
+                return ENOMEM;
+            }
         }
     }
 
@@ -2735,7 +2751,10 @@ int main(int argc, const char *argv[])
     }
 
     if (opt_daemon) flags |= FLAGS_DAEMON;
-    if (opt_interactive) flags |= FLAGS_INTERACTIVE;
+    if (opt_interactive) {
+        flags |= FLAGS_INTERACTIVE;
+        debug_to_stderr = 1;
+    }
 
     if (opt_config_file) {
         config_file = talloc_strdup(tmp_ctx, opt_config_file);
diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c
index 
ee7bbff89ae63373d781a78cb5d5f2f1704f27bd..e2fe3f232b3f051bf1d94617c2c711b7087130c7
 100644
--- a/src/providers/ldap/ldap_child.c
+++ b/src/providers/ldap/ldap_child.c
@@ -439,6 +439,8 @@ int main(int argc, const char *argv[])
          _("Show timestamps with microseconds"), NULL},
         {"debug-fd", 0, POPT_ARG_INT, &debug_fd, 0,
          _("An open file descriptor for the debug logs"), NULL},
+        {"debug-to-stderr", 0, POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, 
&debug_to_stderr, 0, \
+         _("Send the debug output to stderr directly."), NULL }, \
         POPT_TABLEEND
     };
 
diff --git a/src/util/child_common.c b/src/util/child_common.c
index 
08aac1143e3dccf1d02a3600f86cec92f1587efd..81bbab70ed44a6c0a4410909924aec195c643bea
 100644
--- a/src/util/child_common.c
+++ b/src/util/child_common.c
@@ -637,8 +637,10 @@ static errno_t prepare_child_argv(TALLOC_CTX *mem_ctx,
     bool child_debug_to_file = debug_to_file;
     bool child_debug_timestamps = debug_timestamps;
     bool child_debug_microseconds = debug_microseconds;
+    bool child_debug_stderr = debug_to_stderr;
 
     if (child_debug_to_file) argc++;
+    if (child_debug_stderr) argc++;
 
     /*
      * program name, debug_level, debug_to_file, debug_timestamps,
@@ -659,6 +661,14 @@ static errno_t prepare_child_argv(TALLOC_CTX *mem_ctx,
         goto fail;
     }
 
+    if (child_debug_stderr) {
+        argv[--argc] = talloc_strdup(argv, "--debug-to-stderr");
+        if (argv[argc] == NULL) {
+            ret = ENOMEM;
+            goto fail;
+        }
+    }
+
     if (child_debug_to_file) {
         argv[--argc] = talloc_asprintf(argv, "--debug-fd=%d",
                                        child_debug_fd);
diff --git a/src/util/debug.c b/src/util/debug.c
index 
b66de07b4e3a4549548f627f07a45f97068fa21b..a99d5403a238f125010b9b309355b30f9f528c44
 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_to_stderr = 0;
 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_to_stderr) {
         /* 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/util.h b/src/util/util.h
index 
5c02c33a551440afeb32c00542fe2574784e8cb1..6a9bc0c2e5f5dd3307a3e0708b6f755eec687ac8
 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -68,6 +68,7 @@ extern int debug_level;
 extern int debug_timestamps;
 extern int debug_microseconds;
 extern int debug_to_file;
+extern int debug_to_stderr;
 extern const char *debug_log_file;
 void debug_fn(const char *file,
               long line,
@@ -107,6 +108,8 @@ errno_t set_debug_file_from_fd(const int fd);
          _("Debug level"), NULL}, \
         {"debug-to-files", 'f', POPT_ARG_NONE, &debug_to_file, 0, \
          _("Send the debug output to files instead of stderr"), NULL }, \
+        {"debug-to-stderr", 0, POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, 
&debug_to_stderr, 0, \
+         _("Send the debug output to stderr directly."), NULL }, \
         {"debug-timestamps", 0, POPT_ARG_INT, &debug_timestamps, 0, \
          _("Add debug timestamps"), NULL}, \
          {"debug-microseconds", 0, POPT_ARG_INT, &debug_microseconds, 0, \
-- 
1.9.3

>From a1bb4fd31808a7f734e8947b3d91c5c16359109a Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhro...@redhat.com>
Date: Wed, 9 Jul 2014 11:24:21 +0200
Subject: [PATCH 2/2] TOOLS: Always debug to stderr

https://fedorahosted.org/sssd/ticket/2348

Programs that are supposed to only be executed on the foreground should
log to stderr automatically.
---
 src/tests/auth-tests.c                    | 2 +-
 src/tests/cmocka/sbus_internal_tests.c    | 2 +-
 src/tests/cmocka/test_ad_access_filter.c  | 2 +-
 src/tests/cmocka/test_ad_common.c         | 2 +-
 src/tests/cmocka/test_ad_gpo.c            | 2 +-
 src/tests/cmocka/test_dp_opts.c           | 2 +-
 src/tests/cmocka/test_dyndns.c            | 2 +-
 src/tests/cmocka/test_fqnames.c           | 2 +-
 src/tests/cmocka/test_ifp.c               | 2 +-
 src/tests/cmocka/test_ipa_idmap.c         | 2 +-
 src/tests/cmocka/test_nested_groups.c     | 2 +-
 src/tests/cmocka/test_nss_srv.c           | 2 +-
 src/tests/cmocka/test_responder_common.c  | 2 +-
 src/tests/cmocka/test_sdap.c              | 2 +-
 src/tests/cmocka/test_sss_idmap.c         | 2 +-
 src/tests/cmocka/test_sss_sifp.c          | 2 +-
 src/tests/cmocka/test_utils.c             | 2 +-
 src/tests/crypto-tests.c                  | 2 +-
 src/tests/fail_over-tests.c               | 2 +-
 src/tests/files-tests.c                   | 2 +-
 src/tests/krb5_child-test.c               | 2 +-
 src/tests/krb5_utils-tests.c              | 2 +-
 src/tests/refcount-tests.c                | 2 +-
 src/tests/resolv-tests.c                  | 2 +-
 src/tests/responder_socket_access-tests.c | 2 +-
 src/tests/simple_access-tests.c           | 2 +-
 src/tests/strtonum-tests.c                | 2 +-
 src/tests/sysdb-tests.c                   | 2 +-
 src/tests/sysdb_ssh-tests.c               | 2 +-
 src/tests/util-tests.c                    | 2 +-
 src/tools/sss_cache.c                     | 2 +-
 src/tools/sss_debuglevel.c                | 2 +-
 src/tools/sss_groupadd.c                  | 2 +-
 src/tools/sss_groupdel.c                  | 2 +-
 src/tools/sss_groupmod.c                  | 2 +-
 src/tools/sss_groupshow.c                 | 2 +-
 src/tools/sss_seed.c                      | 2 +-
 src/tools/sss_useradd.c                   | 2 +-
 src/tools/sss_userdel.c                   | 2 +-
 src/tools/sss_usermod.c                   | 2 +-
 src/util/util.h                           | 8 ++++++++
 41 files changed, 48 insertions(+), 40 deletions(-)

diff --git a/src/tests/auth-tests.c b/src/tests/auth-tests.c
index 
810a02be877fb4d3adcc183a3eda9b5468e3eca0..670a4d2adc671703d872ee94cae5f6910d97cffe
 100644
--- a/src/tests/auth-tests.c
+++ b/src/tests/auth-tests.c
@@ -317,7 +317,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tests/cmocka/sbus_internal_tests.c 
b/src/tests/cmocka/sbus_internal_tests.c
index 
0d3e25a4e3c457a251ec0fe1c335ae8684f92fab..a79f54d266375036915c8a2ff95378a379ee4448
 100644
--- a/src/tests/cmocka/sbus_internal_tests.c
+++ b/src/tests/cmocka/sbus_internal_tests.c
@@ -259,7 +259,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
     tests_set_cwd();
     return run_tests(tests);
 }
diff --git a/src/tests/cmocka/test_ad_access_filter.c 
b/src/tests/cmocka/test_ad_access_filter.c
index 
3f4e44f14150a1a23eda5e7b914ddcee94203c65..7654e8498b4d5e346598964e4725f55410149585
 100644
--- a/src/tests/cmocka/test_ad_access_filter.c
+++ b/src/tests/cmocka/test_ad_access_filter.c
@@ -349,7 +349,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tests/cmocka/test_ad_common.c 
b/src/tests/cmocka/test_ad_common.c
index 
bbd56b1b9b78cb78cb24726522822ad2f7ae9980..c4b6bd0f21827424291176abf520008d2d9488de
 100644
--- a/src/tests/cmocka/test_ad_common.c
+++ b/src/tests/cmocka/test_ad_common.c
@@ -234,7 +234,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tests/cmocka/test_ad_gpo.c b/src/tests/cmocka/test_ad_gpo.c
index 
231c3608dbde312bce468aee0ba8e2169187a68f..e6319118e3c94e3a5c9c7e06f7025f2cd4ec9037
 100644
--- a/src/tests/cmocka/test_ad_gpo.c
+++ b/src/tests/cmocka/test_ad_gpo.c
@@ -380,7 +380,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tests/cmocka/test_dp_opts.c b/src/tests/cmocka/test_dp_opts.c
index 
31dde47c75b1fada1dd03f18c59c34066c5f79a9..0f3052ab3c2add8286db6d5f065a8ca9391aae13
 100644
--- a/src/tests/cmocka/test_dp_opts.c
+++ b/src/tests/cmocka/test_dp_opts.c
@@ -400,7 +400,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     /* Even though normally the tests should clean up after themselves
      * they might not after a failed run. Remove the old db to be sure */
diff --git a/src/tests/cmocka/test_dyndns.c b/src/tests/cmocka/test_dyndns.c
index 
db90e661cba032dc230478dbb10cae1109c37f05..b0e8df81bc079efa8ebd8ae45603921261330c9b
 100644
--- a/src/tests/cmocka/test_dyndns.c
+++ b/src/tests/cmocka/test_dyndns.c
@@ -422,7 +422,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     /* Even though normally the tests should clean up after themselves
      * they might not after a failed run. Remove the old db to be sure */
diff --git a/src/tests/cmocka/test_fqnames.c b/src/tests/cmocka/test_fqnames.c
index 
c761093703b5c1a6716ef868c8d2f08ba7cb213c..a3d176af0b2fce6bb55db86756bf937fc7b8e829
 100644
--- a/src/tests/cmocka/test_fqnames.c
+++ b/src/tests/cmocka/test_fqnames.c
@@ -537,7 +537,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     /* Even though normally the tests should clean up after themselves
      * they might not after a failed run. Remove the old db to be sure */
diff --git a/src/tests/cmocka/test_ifp.c b/src/tests/cmocka/test_ifp.c
index 
650a9496978854c4c1aa6b72f58e831d60ca7c10..b0f6e09900a956a51c17d1c4cf1a7772dccc3a68
 100644
--- a/src/tests/cmocka/test_ifp.c
+++ b/src/tests/cmocka/test_ifp.c
@@ -475,7 +475,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     /* Even though normally the tests should clean up after themselves
      * they might not after a failed run. Remove the old db to be sure */
diff --git a/src/tests/cmocka/test_ipa_idmap.c 
b/src/tests/cmocka/test_ipa_idmap.c
index 
2fb2cde2f9a7f1172fb69b268d19b559ff9d2f32..8ad56298757c6b8fd2e857e1d92d0eb767b9e8c9
 100644
--- a/src/tests/cmocka/test_ipa_idmap.c
+++ b/src/tests/cmocka/test_ipa_idmap.c
@@ -241,7 +241,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tests/cmocka/test_nested_groups.c 
b/src/tests/cmocka/test_nested_groups.c
index 
955d05dd426af5219b7187046920de86437da4b3..0c1a53b0e6f1291b3ee55d3a4d4396e864ae228a
 100644
--- a/src/tests/cmocka/test_nested_groups.c
+++ b/src/tests/cmocka/test_nested_groups.c
@@ -463,7 +463,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     /* Even though normally the tests should clean up after themselves
      * they might not after a failed run. Remove the old db to be sure */
diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c
index 
24e58abe7f8bb8e4f578c2ed86a9ab7fbd6afd48..808a7a1854cb80b6ffb3f84f26144083e8599bb5
 100644
--- a/src/tests/cmocka/test_nss_srv.c
+++ b/src/tests/cmocka/test_nss_srv.c
@@ -1666,7 +1666,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     /* Even though normally the tests should clean up after themselves
      * they might not after a failed run. Remove the old db to be sure */
diff --git a/src/tests/cmocka/test_responder_common.c 
b/src/tests/cmocka/test_responder_common.c
index 
44627ab99425943dea9a1d27daa3435e1b11ad06..24bb54ff5120b281d43ddc7d5d4443c87a22af1c
 100644
--- a/src/tests/cmocka/test_responder_common.c
+++ b/src/tests/cmocka/test_responder_common.c
@@ -303,7 +303,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     /* Even though normally the tests should clean up after themselves
      * they might not after a failed run. Remove the old db to be sure */
diff --git a/src/tests/cmocka/test_sdap.c b/src/tests/cmocka/test_sdap.c
index 
33cefcc88b3a1c662751c463cc44c19526d77169..a1ecebdbda0b66c43ffd3ac1a8cf6a10481ee737
 100644
--- a/src/tests/cmocka/test_sdap.c
+++ b/src/tests/cmocka/test_sdap.c
@@ -574,7 +574,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     /* Even though normally the tests should clean up after themselves
      * they might not after a failed run. Remove the old db to be sure */
diff --git a/src/tests/cmocka/test_sss_idmap.c 
b/src/tests/cmocka/test_sss_idmap.c
index 
ff933216416b61618bf764d8c2554b273706c787..ccdfa63ad6065b29187637b721b5e93548a09372
 100644
--- a/src/tests/cmocka/test_sss_idmap.c
+++ b/src/tests/cmocka/test_sss_idmap.c
@@ -549,7 +549,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tests/cmocka/test_sss_sifp.c b/src/tests/cmocka/test_sss_sifp.c
index 
190dd76291528ab15bb25250778e4a008d1ea38b..54f2152075d860edc3a5438b4cf5cdd1a88d8f92
 100644
--- a/src/tests/cmocka/test_sss_sifp.c
+++ b/src/tests/cmocka/test_sss_sifp.c
@@ -1923,7 +1923,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     rv = run_tests(tests);
 
diff --git a/src/tests/cmocka/test_utils.c b/src/tests/cmocka/test_utils.c
index 
20e21a9baee0b8e09d573f2fc723db4d7f9c6f94..e49e7eca5628a65492becbf13dfc5fb93063ff15
 100644
--- a/src/tests/cmocka/test_utils.c
+++ b/src/tests/cmocka/test_utils.c
@@ -934,7 +934,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     /* Even though normally the tests should clean up after themselves
      * they might not after a failed run. Remove the old db to be sure */
diff --git a/src/tests/crypto-tests.c b/src/tests/crypto-tests.c
index 
87184594e2fb7cedc234350b56aa341d9de62713..ee807c6bcc46a9adea93bcef3158daf0eec30e98
 100644
--- a/src/tests/crypto-tests.c
+++ b/src/tests/crypto-tests.c
@@ -206,7 +206,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c
index 
78aaf9c10d833b04e4feacfc5bef3691abe76d2d..b21ead38229be5d55df2de10bec3dd00a8566d71
 100644
--- a/src/tests/fail_over-tests.c
+++ b/src/tests/fail_over-tests.c
@@ -311,7 +311,7 @@ main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tests/files-tests.c b/src/tests/files-tests.c
index 
e8bd3b97d21bea2170049bbab5faedb88cf87966..09df5cbd48ae056c7d089204f15c6d3b32d98477
 100644
--- a/src/tests/files-tests.c
+++ b/src/tests/files-tests.c
@@ -323,7 +323,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug);
+    DEBUG_CLI_INIT(debug);
 
     tests_set_cwd();
 
diff --git a/src/tests/krb5_child-test.c b/src/tests/krb5_child-test.c
index 
4046def65d39ffdc2c97b06c2d638150f3ca2f42..63caa5f6c97f3e5c0df459b7549e681e51fcc108
 100644
--- a/src/tests/krb5_child-test.c
+++ b/src/tests/krb5_child-test.c
@@ -443,7 +443,7 @@ main(int argc, const char *argv[])
         }
     }
 
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     if (opt != -1) {
         poptPrintUsage(pc, stderr, 0);
diff --git a/src/tests/krb5_utils-tests.c b/src/tests/krb5_utils-tests.c
index 
11fe1d749dccb5d367e3840ebc0a396b992bce2a..c59356ed040a0936394a83adedf0d51afcfdec4e
 100644
--- a/src/tests/krb5_utils-tests.c
+++ b/src/tests/krb5_utils-tests.c
@@ -662,7 +662,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     ret = mkdir(TESTS_PATH, 0775);
     if (ret != EOK) {
diff --git a/src/tests/refcount-tests.c b/src/tests/refcount-tests.c
index 
9713d4783d5ea39c1550a56c048ff1fdc6852ea8..7fb398e7aa931009c8957488bf4710cc3b33087b
 100644
--- a/src/tests/refcount-tests.c
+++ b/src/tests/refcount-tests.c
@@ -222,7 +222,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug);
+    DEBUG_CLI_INIT(debug);
 
     tests_set_cwd();
 
diff --git a/src/tests/resolv-tests.c b/src/tests/resolv-tests.c
index 
abf7539db92d8a0d0b7940953d39ec57e16804ed..5b85bf6ef45485444442f029d62afc9795037137
 100644
--- a/src/tests/resolv-tests.c
+++ b/src/tests/resolv-tests.c
@@ -967,7 +967,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug);
+    DEBUG_CLI_INIT(debug);
 
     if (!use_net_test) {
         printf("Network tests disabled. Rerun with the \"-n\" "
diff --git a/src/tests/responder_socket_access-tests.c 
b/src/tests/responder_socket_access-tests.c
index 
a01a5d12c24aae356a90fd537878b0a0953d89de..b1f7a4c1762664d800b046329e27bc0698ce94bf
 100644
--- a/src/tests/responder_socket_access-tests.c
+++ b/src/tests/responder_socket_access-tests.c
@@ -163,7 +163,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
     tests_set_cwd();
 
     Suite *s = responder_test_suite();
diff --git a/src/tests/simple_access-tests.c b/src/tests/simple_access-tests.c
index 
999277340e436431f14d7710c05c66823e0ebf9e..5c74eb85f80cbeee8cff456c08d9012babb9a9db
 100644
--- a/src/tests/simple_access-tests.c
+++ b/src/tests/simple_access-tests.c
@@ -658,7 +658,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
     test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_FILE, LOCAL_SYSDB_FILE);
diff --git a/src/tests/strtonum-tests.c b/src/tests/strtonum-tests.c
index 
009f0049a1c23055bef8a6c11a83920db709d15d..73a07114fa16d8ba3d41e7ad8adf5a094473b524
 100644
--- a/src/tests/strtonum-tests.c
+++ b/src/tests/strtonum-tests.c
@@ -449,7 +449,7 @@ int main(int argc, const char *argv[]) {
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 
51baae1f627a2e578123424522c2963f195b76cb..d24bd4f7d4f0e8f85afa7c98da8edc0635b2e328
 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -5986,7 +5986,7 @@ int main(int argc, const char *argv[]) {
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     if (!ldb_modules_path_is_set()) {
         fprintf(stderr, "Warning: LDB_MODULES_PATH is not set, "
diff --git a/src/tests/sysdb_ssh-tests.c b/src/tests/sysdb_ssh-tests.c
index 
ae0cb71c72827fae51c761f695277ed1ad3f15df..6a4c219b37fc71fdf35ee33b41756f77ae864d37
 100644
--- a/src/tests/sysdb_ssh-tests.c
+++ b/src/tests/sysdb_ssh-tests.c
@@ -400,7 +400,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     if (!ldb_modules_path_is_set()) {
         fprintf(stderr, "Warning: LDB_MODULES_PATH is not set, "
diff --git a/src/tests/util-tests.c b/src/tests/util-tests.c
index 
b79153e3e89b90182bfce7c504a7d6a764a0e59b..08e8b8d263c46618a0cdfb2203684305fa6dddc6
 100644
--- a/src/tests/util-tests.c
+++ b/src/tests/util-tests.c
@@ -1083,7 +1083,7 @@ int main(int argc, const char *argv[])
     }
     poptFreeContext(pc);
 
-    DEBUG_INIT(debug_level);
+    DEBUG_CLI_INIT(debug_level);
 
     tests_set_cwd();
 
diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c
index 
ffa4e35e28c960705733c530124927c0075242ac..7cd5852ab299466c6223fb048f35292a75f87e98
 100644
--- a/src/tools/sss_cache.c
+++ b/src/tools/sss_cache.c
@@ -600,7 +600,7 @@ errno_t init_context(int argc, const char *argv[], struct 
cache_tool_ctx **tctx)
         }
     }
 
-    DEBUG_INIT(debug);
+    DEBUG_CLI_INIT(debug);
     debug_prg_name = argv[0];
 
     if (ret != -1) {
diff --git a/src/tools/sss_debuglevel.c b/src/tools/sss_debuglevel.c
index 
c38591cfaf66e67c198bf83ad431df5c3e11e74b..dcacd5dc97f0f81e656737833f71abbf8f1aef29
 100644
--- a/src/tools/sss_debuglevel.c
+++ b/src/tools/sss_debuglevel.c
@@ -88,7 +88,7 @@ int main(int argc, const char **argv)
             goto fini;
         }
     }
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     /* get debug level */
     debug_as_string = poptGetArg(pc);
diff --git a/src/tools/sss_groupadd.c b/src/tools/sss_groupadd.c
index 
0152aeff091048aa2e0531e625456faf1fff28e1..f71d6dde722845288a67a676e4e737ecd84450a6
 100644
--- a/src/tools/sss_groupadd.c
+++ b/src/tools/sss_groupadd.c
@@ -68,7 +68,7 @@ int main(int argc, const char **argv)
         BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini);
     }
 
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     /* groupname is an argument, not option */
     pc_groupname = poptGetArg(pc);
diff --git a/src/tools/sss_groupdel.c b/src/tools/sss_groupdel.c
index 
947bb4a4d07fb41ebe54b2a823527add9507bdff..5dcc2056dbe13896115b81d58ae34e8985dd3d38
 100644
--- a/src/tools/sss_groupdel.c
+++ b/src/tools/sss_groupdel.c
@@ -63,7 +63,7 @@ int main(int argc, const char **argv)
         BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini);
     }
 
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     pc_groupname = poptGetArg(pc);
     if (pc_groupname == NULL) {
diff --git a/src/tools/sss_groupmod.c b/src/tools/sss_groupmod.c
index 
21d78278c74fbf8855fc3e50a7902ab63a569b40..eddc7034a7e08a5cc7397f5ac2b491d8b16d4976
 100644
--- a/src/tools/sss_groupmod.c
+++ b/src/tools/sss_groupmod.c
@@ -101,7 +101,7 @@ int main(int argc, const char **argv)
         BAD_POPT_PARAMS(pc, _("Specify group to modify\n"), ret, fini);
     }
 
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     CHECK_ROOT(ret, debug_prg_name);
 
diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c
index 
f7c798df635df44c9f02b52accb3da705e68971d..251e71b15d312822b4b8925b5b3063870c0147db
 100644
--- a/src/tools/sss_groupshow.c
+++ b/src/tools/sss_groupshow.c
@@ -680,7 +680,7 @@ int main(int argc, const char **argv)
         }
     }
 
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     if (ret != -1) {
         BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini);
diff --git a/src/tools/sss_seed.c b/src/tools/sss_seed.c
index 
32ab43b9cd5befcdf35cd170dad22ec445f667d0..0f8a76a61cb2a029015416a59d235a1c5d49deca
 100644
--- a/src/tools/sss_seed.c
+++ b/src/tools/sss_seed.c
@@ -523,7 +523,7 @@ static int seed_init(TALLOC_CTX *mem_ctx,
         BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini);
     }
 
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     CHECK_ROOT(ret, argv[0]);
 
diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c
index 
cab69e46d5f47dfe498e25f4a771ba0f25ca16ca..59439401e225d752ea9a82fdb33900bf44699e18
 100644
--- a/src/tools/sss_useradd.c
+++ b/src/tools/sss_useradd.c
@@ -99,7 +99,7 @@ int main(int argc, const char **argv)
         }
     }
 
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     if (ret != -1) {
         BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini);
diff --git a/src/tools/sss_userdel.c b/src/tools/sss_userdel.c
index 
e19143604ec54d6aa2f6abfa3cece64e18b7e709..d085dc3cabd31b2ee82b13c6cbc39c7658b071d1
 100644
--- a/src/tools/sss_userdel.c
+++ b/src/tools/sss_userdel.c
@@ -177,7 +177,7 @@ int main(int argc, const char **argv)
         }
     }
 
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     if (ret != -1) {
         BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini);
diff --git a/src/tools/sss_usermod.c b/src/tools/sss_usermod.c
index 
079c078e7b4cca7177f2d00ed3ec440a3013bba2..9683c6e9e7c2bf389563515162a3772ee73987ed
 100644
--- a/src/tools/sss_usermod.c
+++ b/src/tools/sss_usermod.c
@@ -144,7 +144,7 @@ int main(int argc, const char **argv)
         BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini);
     }
 
-    DEBUG_INIT(pc_debug);
+    DEBUG_CLI_INIT(pc_debug);
 
     /* username is an argument without --option */
     pc_username = poptGetArg(pc);
diff --git a/src/util/util.h b/src/util/util.h
index 
6a9bc0c2e5f5dd3307a3e0708b6f755eec687ac8..b605f230aa88958e4af598e5fa7896e5a74ce9d9
 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -152,6 +152,14 @@ errno_t set_debug_file_from_fd(const int fd);
     talloc_set_log_fn(talloc_log_fn); \
 } while (0)
 
+/* CLI tools shall debug to stderr even when SSSD was compiled with journald
+ * support
+ */
+#define DEBUG_CLI_INIT(dbg_lvl) do { \
+    DEBUG_INIT(dbg_lvl);             \
+    debug_to_stderr = 1;             \
+} while (0)
+
 #define PRINT(fmt, ...) fprintf(stdout, gettext(fmt), ##__VA_ARGS__)
 #define ERROR(fmt, ...) fprintf(stderr, gettext(fmt), ##__VA_ARGS__)
 
-- 
1.9.3

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to