From 131684b9107a3fc07906013d16b35975531f2864 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Jun 16 2016 11:36:44 +0000 Subject: DEBUG: Add `debug` alias for debug_level Our users constantly make the mistake of typing `debug = 9` in the sssd.conf instead of `debug_level = 9` as would be correct. This happens frequently-enough that we should just alias it rather than continue to have people make mistakes. Resolves: https://fedorahosted.org/sssd/ticket/2999 Reviewed-by: Pavel Březina Reviewed-by: Petr Cech --- diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h index 3ed82ca..0a3d6a0 100644 --- a/src/confdb/confdb.h +++ b/src/confdb/confdb.h @@ -53,6 +53,7 @@ #define CONFDB_SERVICE_PATH_TMPL "config/%s" #define CONFDB_SERVICE_COMMAND "command" #define CONFDB_SERVICE_DEBUG_LEVEL "debug_level" +#define CONFDB_SERVICE_DEBUG_LEVEL_ALIAS "debug" #define CONFDB_SERVICE_DEBUG_TIMESTAMPS "debug_timestamps" #define CONFDB_SERVICE_DEBUG_MICROSECONDS "debug_microseconds" #define CONFDB_SERVICE_DEBUG_TO_FILES "debug_to_files" diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in index abbf5dc..0612758 100644 --- a/src/config/SSSDConfig/__init__.py.in +++ b/src/config/SSSDConfig/__init__.py.in @@ -40,6 +40,7 @@ else: # TODO: This needs to be made external option_strings = { # [service] + 'debug' : _('Set the verbosity of the debug logging'), 'debug_level' : _('Set the verbosity of the debug logging'), 'debug_timestamps' : _('Include timestamps in debug logs'), 'debug_microseconds' : _('Include microseconds in timestamps in debug logs'), diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py index e518c75..6ec3023 100755 --- a/src/config/SSSDConfigTest.py +++ b/src/config/SSSDConfigTest.py @@ -299,6 +299,7 @@ class SSSDConfigTestSSSDService(unittest.TestCase): 'krb5_rcache_dir', 'user', 'default_domain_suffix', + 'debug', 'debug_level', 'debug_timestamps', 'debug_microseconds', @@ -497,6 +498,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase): options = domain.list_options() control_list = [ 'description', + 'debug', 'debug_level', 'debug_timestamps', 'min_id', @@ -863,6 +865,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase): options = domain.list_options() control_list = [ 'description', + 'debug', 'debug_level', 'debug_timestamps', 'min_id', diff --git a/src/config/etc/sssd.api.conf b/src/config/etc/sssd.api.conf index fef5536..9114659 100644 --- a/src/config/etc/sssd.api.conf +++ b/src/config/etc/sssd.api.conf @@ -3,6 +3,7 @@ [service] # Options available to all services +debug = int, None, false debug_level = int, None, false debug_timestamps = bool, None, false debug_microseconds = bool, None, false @@ -108,6 +109,7 @@ subdomains_provider = str, None, false [domain] # Options available to all domains description = str, None, false +debug = int, None, false debug_level = int, None, false debug_timestamps = bool, None, false command = str, None, false diff --git a/src/man/sssd.conf.5.xml b/src/man/sssd.conf.5.xml index b82e941..d5442d0 100644 --- a/src/man/sssd.conf.5.xml +++ b/src/man/sssd.conf.5.xml @@ -70,6 +70,19 @@ + debug (integer) + + + SSSD 1.14 and later also includes the + debug alias for + debug_level as a + convenience feature. If both are specified, the + value of debug_level + will be used. + + + + debug_timestamps (bool) diff --git a/src/util/server.c b/src/util/server.c index 67a2595..074dc34 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -567,7 +567,7 @@ int server_setup(const char *name, int flags, /* set debug level if any in conf_entry */ ret = confdb_get_int(ctx->confdb_ctx, conf_entry, CONFDB_SERVICE_DEBUG_LEVEL, - SSSDBG_DEFAULT, + SSSDBG_UNRESOLVED, &debug_level); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "Error reading from confdb (%d) " @@ -575,6 +575,19 @@ int server_setup(const char *name, int flags, return ret; } + if (debug_level == SSSDBG_UNRESOLVED) { + /* Check for the `debug` alias */ + ret = confdb_get_int(ctx->confdb_ctx, conf_entry, + CONFDB_SERVICE_DEBUG_LEVEL_ALIAS, + SSSDBG_DEFAULT, + &debug_level); + if (ret != EOK) { + DEBUG(SSSDBG_FATAL_FAILURE, "Error reading from confdb (%d) " + "[%s]\n", ret, strerror(ret)); + return ret; + } + } + debug_level = debug_convert_old_level(debug_level); }