From c723415701905e040503e710d3326110006d27f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Wed, 3 Aug 2011 09:15:52 +0200 Subject: [PATCH 6/6] New DEBUG facility - SSSDBG_UNRESOLVED changed from -1 to 0 Changes unresolved debug level value (SSSDBG_UNRESOLVED) from -1 to 0 so DEBUG macro could be reduced by one condition. Anyway, it has a minor effect, every time you want to load debug_level from command line parameters, you have to use following pattern: /* Set debug level to invalid value so we can deside if -d 0 was used. */ debug_level = SSSDBG_INVALID; pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { ... } debug_level = debug_level != SSSDBG_INVALID ? debug_convert_old_level(debug_level) : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ --- src/monitor/monitor.c | 12 +++++++++--- src/providers/data_provider_be.c | 7 ++++++- src/providers/krb5/krb5_child.c | 6 +++++- src/providers/ldap/ldap_child.c | 7 ++++++- src/providers/proxy/proxy_child.c | 7 ++++++- src/responder/nss/nsssrv.c | 7 ++++++- src/responder/pam/pamsrv.c | 7 ++++++- src/tests/auth-tests.c | 7 ++++++- src/tests/crypto-tests.c | 7 ++++++- src/tests/debug-tests.c | 9 +++++---- src/tests/fail_over-tests.c | 8 +++++++- src/tests/files-tests.c | 8 +++++++- src/tests/krb5_utils-tests.c | 7 ++++++- src/tests/refcount-tests.c | 8 +++++++- src/tests/resolv-tests.c | 8 +++++++- src/tests/simple_access-tests.c | 7 ++++++- src/tests/strtonum-tests.c | 7 ++++++- src/tests/sysdb-tests.c | 7 ++++++- src/tests/util-tests.c | 7 ++++++- src/tools/sss_cache.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_useradd.c | 2 +- src/tools/sss_userdel.c | 2 +- src/tools/sss_usermod.c | 2 +- src/util/debug.c | 9 +-------- src/util/server.c | 2 +- src/util/util.h | 7 ++++--- 30 files changed, 133 insertions(+), 44 deletions(-) diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index ae429f8..e536362 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -943,7 +943,7 @@ static int get_service_config(struct mt_ctx *ctx, const char *name, } if (!svc->command) { - if (cmdline_debug_level == SSS_UNRESOLVED_DEBUG_LEVEL) { + if (cmdline_debug_level == SSSDBG_UNRESOLVED) { svc->command = talloc_asprintf(svc, "%s/sssd_%s %s%s", SSSD_LIBEXEC_PATH, svc->name, @@ -1089,7 +1089,7 @@ static int get_provider_config(struct mt_ctx *ctx, const char *name, /* if there are no custom commands, build a default one */ if (!svc->command) { - if (cmdline_debug_level == SSS_UNRESOLVED_DEBUG_LEVEL) { + if (cmdline_debug_level == SSSDBG_UNRESOLVED) { svc->command = talloc_asprintf(svc, "%s/sssd_be --domain %s%s%s", SSSD_LIBEXEC_PATH, @@ -2321,6 +2321,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -2331,7 +2334,10 @@ int main(int argc, const char *argv[]) return 1; } } - debug_level = debug_convert_old_level(debug_level); + + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ /* If the level was passed at the command-line, we want * to save it and pass it to the children later. diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index 7df82f4..f81a45d 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -1197,6 +1197,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -1216,7 +1219,9 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ /* set up things like debug , signals, daemonization, etc... */ diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c index 48442de..85ae50c 100644 --- a/src/providers/krb5/krb5_child.c +++ b/src/providers/krb5/krb5_child.c @@ -1559,6 +1559,8 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { @@ -1573,7 +1575,9 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ DEBUG(7, ("krb5_child started.\n")); diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c index 8a1dc49..510c06d 100644 --- a/src/providers/ldap/ldap_child.c +++ b/src/providers/ldap/ldap_child.c @@ -365,6 +365,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -378,7 +381,9 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ DEBUG(7, ("ldap_child started.\n")); diff --git a/src/providers/proxy/proxy_child.c b/src/providers/proxy/proxy_child.c index d19cc74..37cf5e7 100644 --- a/src/providers/proxy/proxy_child.c +++ b/src/providers/proxy/proxy_child.c @@ -480,6 +480,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -507,7 +510,9 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ /* set up things like debug , signals, daemonization, etc... */ debug_log_file = talloc_asprintf(NULL, "proxy_child_%s", domain); diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c index 7f60b73..50c875b 100644 --- a/src/responder/nss/nsssrv.c +++ b/src/responder/nss/nsssrv.c @@ -340,6 +340,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -353,7 +356,9 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ /* set up things like debug, signals, daemonization, etc... */ debug_log_file = "sssd_nss"; diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c index 2308288..ba39e6e 100644 --- a/src/responder/pam/pamsrv.c +++ b/src/responder/pam/pamsrv.c @@ -196,6 +196,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -209,7 +212,9 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ /* set up things like debug, signals, daemonization, etc... */ debug_log_file = "sssd_pam"; diff --git a/src/tests/auth-tests.c b/src/tests/auth-tests.c index aae2d00..64e586a 100644 --- a/src/tests/auth-tests.c +++ b/src/tests/auth-tests.c @@ -308,6 +308,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -320,7 +323,9 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ tests_set_cwd(); diff --git a/src/tests/crypto-tests.c b/src/tests/crypto-tests.c index 0f6f2fe..8f3d8cf 100644 --- a/src/tests/crypto-tests.c +++ b/src/tests/crypto-tests.c @@ -122,6 +122,8 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { @@ -135,7 +137,10 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ + tests_set_cwd(); Suite *s = crypto_suite(); diff --git a/src/tests/debug-tests.c b/src/tests/debug-tests.c index 38e6add..c45846c 100644 --- a/src/tests/debug-tests.c +++ b/src/tests/debug-tests.c @@ -50,7 +50,7 @@ START_TEST(test_debug_convert_old_level_old_format) }; fail_unless( - debug_convert_old_level(SSS_UNRESOLVED_DEBUG_LEVEL) == SSSDBG_UNRESOLVED, + debug_convert_old_level(SSS_UNRESOLVED_DEBUG_LEVEL) == SSSDBG_FATAL_FAILURE, "Invalid conversion of SSS_UNRESOLVED_DEBUG_LEVEL" ); @@ -67,7 +67,7 @@ END_TEST START_TEST(test_debug_convert_old_level_new_format) { fail_unless( - debug_convert_old_level(SSSDBG_UNRESOLVED) == SSSDBG_UNRESOLVED, + debug_convert_old_level(SSSDBG_UNRESOLVED) == SSSDBG_FATAL_FAILURE, "Invalid conversion of SSSDBG_UNRESOLVED" ); fail_unless( @@ -119,7 +119,8 @@ END_TEST START_TEST(test_debug_get_level_old_format) { - fail_unless(debug_get_level(SSS_UNRESOLVED_DEBUG_LEVEL) == SSSDBG_UNRESOLVED, "Invalid conversion of -1"); + fail_unless(debug_get_level(SSS_UNRESOLVED_DEBUG_LEVEL) == SSSDBG_FATAL_FAILURE, + "Invalid conversion of SSS_UNRESOLVED_DEBUG_LEVEL"); fail_unless(debug_get_level(0) == SSSDBG_FATAL_FAILURE, "Invalid conversion of 0"); fail_unless(debug_get_level(1) == SSSDBG_CRIT_FAILURE, "Invalid conversion of 1"); fail_unless(debug_get_level(2) == SSSDBG_OP_FAILURE, "Invalid conversion of 2"); @@ -136,7 +137,7 @@ END_TEST START_TEST(test_debug_get_level_new_format) { fail_unless( - debug_get_level(SSSDBG_UNRESOLVED) == SSSDBG_UNRESOLVED, + debug_get_level(SSSDBG_UNRESOLVED) == SSSDBG_FATAL_FAILURE, "Invalid conversion of SSSDBG_UNRESOLVED" ); fail_unless( diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c index 439e5cf..a134596 100644 --- a/src/tests/fail_over-tests.c +++ b/src/tests/fail_over-tests.c @@ -292,6 +292,9 @@ main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -307,7 +310,10 @@ main(int argc, const char *argv[]) } } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug); + + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ tests_set_cwd(); diff --git a/src/tests/files-tests.c b/src/tests/files-tests.c index 15d34c8..63b077c 100644 --- a/src/tests/files-tests.c +++ b/src/tests/files-tests.c @@ -310,6 +310,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, (const char **) argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { fprintf(stderr, "\nInvalid option %s: %s\n\n", @@ -318,7 +321,10 @@ int main(int argc, const char *argv[]) return 1; } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug); + + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ tests_set_cwd(); diff --git a/src/tests/krb5_utils-tests.c b/src/tests/krb5_utils-tests.c index 65e4319..8472ecf 100644 --- a/src/tests/krb5_utils-tests.c +++ b/src/tests/krb5_utils-tests.c @@ -642,6 +642,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -654,7 +657,9 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ ret = mkdir(TESTS_PATH, 0775); if (ret != EOK) { diff --git a/src/tests/refcount-tests.c b/src/tests/refcount-tests.c index 99eedd9..39537a1 100644 --- a/src/tests/refcount-tests.c +++ b/src/tests/refcount-tests.c @@ -207,6 +207,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -218,7 +221,10 @@ int main(int argc, const char *argv[]) } } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug); + + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ tests_set_cwd(); diff --git a/src/tests/resolv-tests.c b/src/tests/resolv-tests.c index 3768fc9..fdcc66a 100644 --- a/src/tests/resolv-tests.c +++ b/src/tests/resolv-tests.c @@ -770,6 +770,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -790,7 +793,10 @@ int main(int argc, const char *argv[]) } } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug); + + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ if (!use_net_test) { printf("Network tests disabled. Rerun with the \"-n\" " diff --git a/src/tests/simple_access-tests.c b/src/tests/simple_access-tests.c index 6ae2356..9fc7540 100644 --- a/src/tests/simple_access-tests.c +++ b/src/tests/simple_access-tests.c @@ -150,6 +150,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -162,7 +165,9 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ Suite *s = access_simple_suite(); SRunner *sr = srunner_create(s); diff --git a/src/tests/strtonum-tests.c b/src/tests/strtonum-tests.c index 8e86c11..491a7be 100644 --- a/src/tests/strtonum-tests.c +++ b/src/tests/strtonum-tests.c @@ -434,6 +434,9 @@ int main(int argc, const char *argv[]) { POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -446,7 +449,9 @@ int main(int argc, const char *argv[]) { } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ tests_set_cwd(); diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index 87b06ee..e6ef1ab 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -3108,6 +3108,9 @@ int main(int argc, const char *argv[]) { POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -3120,7 +3123,9 @@ int main(int argc, const char *argv[]) { } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ tests_set_cwd(); diff --git a/src/tests/util-tests.c b/src/tests/util-tests.c index b347aa7..43b53f6 100644 --- a/src/tests/util-tests.c +++ b/src/tests/util-tests.c @@ -343,6 +343,9 @@ int main(int argc, const char *argv[]) POPT_TABLEEND }; + /* Set debug level to invalid value so we can deside if -d 0 was used. */ + debug_level = SSSDBG_INVALID; + pc = poptGetContext(argv[0], argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { @@ -355,7 +358,9 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - debug_level = debug_convert_old_level(debug_level); + debug_level = debug_level != SSSDBG_INVALID + ? debug_convert_old_level(debug_level) + : SSSDBG_UNRESOLVED; /* Debug level should be loaded from config file. */ tests_set_cwd(); diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c index 7f45ebb..e8b1926 100644 --- a/src/tools/sss_cache.c +++ b/src/tools/sss_cache.c @@ -250,7 +250,7 @@ errno_t init_context(int argc, const char *argv[], struct cache_tool_ctx **tctx) char *group = NULL; char *netgroup = NULL; char *domain = NULL; - int debug = 0; + int debug = SSSDBG_DEFAULT; errno_t ret = EOK; poptContext pc = NULL; diff --git a/src/tools/sss_groupadd.c b/src/tools/sss_groupadd.c index 90b1d08..1f974cd 100644 --- a/src/tools/sss_groupadd.c +++ b/src/tools/sss_groupadd.c @@ -34,7 +34,7 @@ int main(int argc, const char **argv) { gid_t pc_gid = 0; - int pc_debug = 0; + int pc_debug = SSSDBG_DEFAULT; struct poptOption long_options[] = { POPT_AUTOHELP { "debug",'\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, &pc_debug, diff --git a/src/tools/sss_groupdel.c b/src/tools/sss_groupdel.c index 49c5ad3..09f7350 100644 --- a/src/tools/sss_groupdel.c +++ b/src/tools/sss_groupdel.c @@ -32,7 +32,7 @@ int main(int argc, const char **argv) { int ret = EXIT_SUCCESS; - int pc_debug = 0; + int pc_debug = SSSDBG_DEFAULT; const char *pc_groupname = NULL; struct tools_ctx *tctx = NULL; diff --git a/src/tools/sss_groupmod.c b/src/tools/sss_groupmod.c index bea57f8..47134ae 100644 --- a/src/tools/sss_groupmod.c +++ b/src/tools/sss_groupmod.c @@ -35,7 +35,7 @@ int main(int argc, const char **argv) { gid_t pc_gid = 0; - int pc_debug = 0; + int pc_debug = SSSDBG_DEFAULT; struct poptOption long_options[] = { POPT_AUTOHELP { "debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, &pc_debug, diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c index 40af95c..764e324 100644 --- a/src/tools/sss_groupshow.c +++ b/src/tools/sss_groupshow.c @@ -601,7 +601,7 @@ static void print_recursive(struct group_info **group_members, int level) int main(int argc, const char **argv) { int ret = EXIT_SUCCESS; - int pc_debug = 0; + int pc_debug = SSSDBG_DEFAULT; bool pc_recursive = false; const char *pc_groupname = NULL; struct tools_ctx *tctx = NULL; diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c index 3b03516..747ebaf 100644 --- a/src/tools/sss_useradd.c +++ b/src/tools/sss_useradd.c @@ -38,7 +38,7 @@ int main(int argc, const char **argv) const char *pc_gecos = NULL; const char *pc_home = NULL; char *pc_shell = NULL; - int pc_debug = 0; + int pc_debug = SSSDBG_DEFAULT; int pc_create_home = 0; const char *pc_username = NULL; const char *pc_skeldir = NULL; diff --git a/src/tools/sss_userdel.c b/src/tools/sss_userdel.c index 1de4069..6d5e829 100644 --- a/src/tools/sss_userdel.c +++ b/src/tools/sss_userdel.c @@ -120,7 +120,7 @@ int main(int argc, const char **argv) struct tools_ctx *tctx = NULL; const char *pc_username = NULL; - int pc_debug = 0; + int pc_debug = SSSDBG_DEFAULT; int pc_remove = 0; int pc_force = 0; int pc_kick = 0; diff --git a/src/tools/sss_usermod.c b/src/tools/sss_usermod.c index 50fb0a0..dfcde9e 100644 --- a/src/tools/sss_usermod.c +++ b/src/tools/sss_usermod.c @@ -40,7 +40,7 @@ int main(int argc, const char **argv) char *pc_gecos = NULL; char *pc_home = NULL; char *pc_shell = NULL; - int pc_debug = 0; + int pc_debug = SSSDBG_DEFAULT; const char *pc_selinux_user = NULL; struct poptOption long_options[] = { POPT_AUTOHELP diff --git a/src/util/debug.c b/src/util/debug.c index e7ae838..3a1b7ca 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -35,7 +35,6 @@ const char *debug_prg_name = "sssd"; int debug_level = SSSDBG_UNRESOLVED; int debug_timestamps = SSSDBG_TIMESTAMP_UNRESOLVED; - int debug_to_file = 0; const char *debug_log_file = "sssd"; FILE *debug_file = NULL; @@ -63,12 +62,9 @@ int debug_convert_old_level(int old_level) if ((old_level != 0) && !(old_level & 0x000F)) return old_level; - if( old_level == SSS_UNRESOLVED_DEBUG_LEVEL ) - return SSSDBG_UNRESOLVED; - int new_level = SSSDBG_FATAL_FAILURE; - if (old_level == 0) + if (old_level <= 0) return new_level; if (old_level >= 1) @@ -118,9 +114,6 @@ int debug_get_level(int old_level) if ((old_level != 0) && !(old_level & 0x000F)) return old_level; - if( old_level == SSS_UNRESOLVED_DEBUG_LEVEL ) - return SSSDBG_UNRESOLVED; - if ((old_level > 9) || (old_level < 0)) return SSSDBG_FATAL_FAILURE; diff --git a/src/util/server.c b/src/util/server.c index 1d48d84..3e5309d 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -459,7 +459,7 @@ int server_setup(const char *name, int flags, return ret; } - if (debug_level == SSS_UNRESOLVED_DEBUG_LEVEL) { + if (debug_level == SSSDBG_UNRESOLVED) { /* set debug level if any in conf_entry */ ret = confdb_get_int(ctx->confdb_ctx, ctx, conf_entry, CONFDB_SERVICE_DEBUG_LEVEL, diff --git a/src/util/util.h b/src/util/util.h index f2c0377..7a069f8 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -75,7 +75,8 @@ errno_t set_debug_file_from_fd(const int fd); #define SSSDBG_TRACE_INTERNAL 0x2000 /* level 8 */ #define SSSDBG_TRACE_ALL 0x4000 /* level 9 */ -#define SSSDBG_UNRESOLVED -1 +#define SSSDBG_INVALID -1 +#define SSSDBG_UNRESOLVED 0 #define SSSDBG_MASK_ALL 0xFFF0 /* enable all debug levels */ #define SSSDBG_DEFAULT SSSDBG_FATAL_FAILURE @@ -107,7 +108,7 @@ errno_t set_debug_file_from_fd(const int fd); */ #define DEBUG(level, body) do { \ int __debug_macro_newlevel = debug_get_level(level); \ - if ((debug_level > 0) && (__debug_macro_newlevel & debug_level)) { \ + if (__debug_macro_newlevel & debug_level) { \ if (debug_timestamps) { \ time_t rightnow = time(NULL); \ char stamp[25]; \ @@ -134,7 +135,7 @@ errno_t set_debug_file_from_fd(const int fd); */ #define DEBUG_MSG(level, function, message) do { \ int __debug_macro_newlevel = debug_get_level(level); \ - if ((debug_level > 0) && (__debug_macro_newlevel & debug_level)) { \ + if (__debug_macro_newlevel & debug_level) { \ if (debug_timestamps) { \ time_t rightnow = time(NULL); \ char stamp[25]; \ -- 1.7.6