From d3750f3c3a9e232629c8b634b7b5407114667700 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Wed, 27 Apr 2011 15:28:07 -0400 Subject: Override config file debug_level with command-line This patch also makes the following changes: 1) The [sssd] debug_level setting no longer acts as a default for all other sections. 2) We will now skip passing the debug argument to the child processes from the master unless the SSSD was run with a command-line argument for the debug level. https://fedorahosted.org/sssd/ticket/764 --- src/util/debug.c | 3 ++- src/util/server.c | 19 +++++++++++-------- src/util/util.h | 3 +++ 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src/util') diff --git a/src/util/debug.c b/src/util/debug.c index 1b78ebae..129b9d9b 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -31,7 +31,8 @@ #include "util/util.h" const char *debug_prg_name = "sssd"; -int debug_level = 0; + +int debug_level = SSS_UNRESOLVED_DEBUG_LEVEL; int debug_timestamps = 1; int debug_to_file = 0; diff --git a/src/util/server.c b/src/util/server.c index 1e8b148d..977c7511 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -444,14 +444,17 @@ int server_setup(const char *name, int flags, return ret; } - /* set debug level if any in conf_entry */ - ret = confdb_get_int(ctx->confdb_ctx, ctx, conf_entry, - CONFDB_SERVICE_DEBUG_LEVEL, - debug_level, &debug_level); - if (ret != EOK) { - DEBUG(0, ("Error reading from confdb (%d) [%s]\n", - ret, strerror(ret))); - return ret; + if (debug_level == SSS_UNRESOLVED_DEBUG_LEVEL) { + /* set debug level if any in conf_entry */ + ret = confdb_get_int(ctx->confdb_ctx, ctx, conf_entry, + CONFDB_SERVICE_DEBUG_LEVEL, + SSS_DEFAULT_DEBUG_LEVEL, + &debug_level); + if (ret != EOK) { + DEBUG(0, ("Error reading from confdb (%d) [%s]\n", + ret, strerror(ret))); + return ret; + } } /* same for debug timestamps */ diff --git a/src/util/util.h b/src/util/util.h index 61fe7f6c..ac6704ae 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -60,6 +60,9 @@ extern const char *debug_log_file; void debug_fn(const char *format, ...); errno_t set_debug_file_from_fd(const int fd); +#define SSS_DEFAULT_DEBUG_LEVEL 0 +#define SSS_UNRESOLVED_DEBUG_LEVEL -1 + #define SSSD_DEBUG_OPTS \ {"debug-level", 'd', POPT_ARG_INT, &debug_level, 0, \ _("Debug level"), NULL}, \ -- cgit