diff options
40 files changed, 62 insertions, 61 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 8326f3855..20696246c 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -956,7 +956,7 @@ static int get_service_config(struct mt_ctx *ctx, const char *name, * make sure to pass it into the children, overriding the * config file. */ - svc->command = talloc_asprintf(svc, "%s/sssd_%s -d %d%s%s", + svc->command = talloc_asprintf(svc, "%s/sssd_%s -d %#.4x%s%s", SSSD_LIBEXEC_PATH, svc->name, cmdline_debug_level, @@ -1099,7 +1099,7 @@ static int get_provider_config(struct mt_ctx *ctx, const char *name, debug_to_file ? " --debug-to-files" : ""); } else { svc->command = talloc_asprintf(svc, - "%s/sssd_be --domain %s -d %d%s%s ", + "%s/sssd_be --domain %s -d %#.4x%s%s ", SSSD_LIBEXEC_PATH, svc->name, cmdline_debug_level, @@ -2331,6 +2331,7 @@ int main(int argc, const char *argv[]) return 1; } } + debug_level = debug_convert_old_level(debug_level); /* 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/monitor/monitor_sbus.c b/src/monitor/monitor_sbus.c index 632de496f..a1c6ad338 100644 --- a/src/monitor/monitor_sbus.c +++ b/src/monitor/monitor_sbus.c @@ -204,7 +204,8 @@ errno_t monitor_common_rotate_logs(struct confdb_ctx *confdb, } if (debug_level != old_debug_level) { - DEBUG(0, ("Debug level changed to %d\n", debug_level)); + DEBUG(0, ("Debug level changed to %#.4x\n", debug_level)); + debug_level = debug_convert_old_level(debug_level); } return EOK; diff --git a/src/providers/child_common.c b/src/providers/child_common.c index 16618c780..6e0f6a1a7 100644 --- a/src/providers/child_common.c +++ b/src/providers/child_common.c @@ -400,7 +400,7 @@ static errno_t prepare_child_argv(TALLOC_CTX *mem_ctx, argv[--argc] = NULL; - argv[--argc] = talloc_asprintf(argv, "--debug-level=%d", + argv[--argc] = talloc_asprintf(argv, "--debug-level=%#.4x", debug_level); if (argv[argc] == NULL) { ret = ENOMEM; diff --git a/src/providers/data_provider.h b/src/providers/data_provider.h index e699e08f4..c666072d3 100644 --- a/src/providers/data_provider.h +++ b/src/providers/data_provider.h @@ -140,7 +140,7 @@ /* AUTH related common data and functions */ #define DEBUG_PAM_DATA(level, pd) do { \ - if (level <= debug_level) pam_print_data(level, pd); \ + if (DEBUG_IS_SET(debug_get_level(level))) pam_print_data(level, pd); \ } while(0); diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index 380e6cdb1..7df82f44c 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -1216,6 +1216,8 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); + /* set up things like debug , signals, daemonization, etc... */ debug_log_file = talloc_asprintf(NULL, "sssd_%s", be_domain); diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c index b5c417344..fd23c0dbe 100644 --- a/src/providers/data_provider_fo.c +++ b/src/providers/data_provider_fo.c @@ -432,7 +432,7 @@ static void be_resolve_server_done(struct tevent_req *subreq) /* all fine we got the server */ - if (debug_level >= 4 && fo_get_server_name(state->srv)) { + if (DEBUG_IS_SET(SSSDBG_CONF_SETTINGS) && fo_get_server_name(state->srv)) { struct resolv_hostent *srvaddr; char ipaddr[128]; srvaddr = fo_get_server_hostent(state->srv); @@ -447,8 +447,8 @@ static void be_resolve_server_done(struct tevent_req *subreq) ipaddr, 128); DEBUG(4, ("Found address for server %s: [%s] TTL %d\n", - fo_get_server_str_name(state->srv), ipaddr, - srvaddr->addr_list[0]->ttl)); + fo_get_server_str_name(state->srv), ipaddr, + srvaddr->addr_list[0]->ttl)); } srv_status_change = fo_get_server_hostname_last_change(state->srv); diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c index ffc6c798d..48442de9b 100644 --- a/src/providers/krb5/krb5_child.c +++ b/src/providers/krb5/krb5_child.c @@ -1573,6 +1573,8 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); + DEBUG(7, ("krb5_child started.\n")); pd = talloc_zero(NULL, struct pam_data); diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c index fb8dd8063..8a1dc4900 100644 --- a/src/providers/ldap/ldap_child.c +++ b/src/providers/ldap/ldap_child.c @@ -378,6 +378,8 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); + DEBUG(7, ("ldap_child started.\n")); main_ctx = talloc_new(NULL); diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c index 5594dd551..6f73310ee 100644 --- a/src/providers/ldap/sdap_async.c +++ b/src/providers/ldap/sdap_async.c @@ -981,7 +981,7 @@ static errno_t sdap_get_generic_ext_step(struct tevent_req *req) DEBUG(6, ("calling ldap_search_ext with [%s][%s].\n", state->filter, state->search_base)); - if (debug_level >= 7) { + if (DEBUG_IS_SET(SSSDBG_TRACE_LIBS)) { int i; if (state->attrs) { diff --git a/src/providers/ldap/sdap_fd_events.c b/src/providers/ldap/sdap_fd_events.c index 4fb67b82c..3750da773 100644 --- a/src/providers/ldap/sdap_fd_events.c +++ b/src/providers/ldap/sdap_fd_events.c @@ -104,7 +104,7 @@ static int sdap_ldap_connect_callback_add(LDAP *ld, Sockbuf *sb, return EINVAL; } - if (debug_level >= 7) { + if (DEBUG_IS_SET(SSSDBG_TRACE_LIBS)) { char *uri = ldap_url_desc2str(srv); DEBUG(7, ("New LDAP connection to [%s] with fd [%d].\n", uri, ber_fd)); diff --git a/src/providers/proxy/proxy_auth.c b/src/providers/proxy/proxy_auth.c index f92c64714..adb0d8728 100644 --- a/src/providers/proxy/proxy_auth.c +++ b/src/providers/proxy/proxy_auth.c @@ -240,7 +240,7 @@ static struct tevent_req *proxy_child_init_send(TALLOC_CTX *mem_ctx, state->child_ctx = child_ctx; state->command = talloc_asprintf(req, - "%s/proxy_child -d %d%s%s --domain %s --id %d", + "%s/proxy_child -d %#.4x%s%s --domain %s --id %d", SSSD_LIBEXEC_PATH, debug_level, (debug_timestamps ? "" : " --debug-timestamps=0"), (debug_to_file ? " --debug-to-files" : ""), diff --git a/src/providers/proxy/proxy_child.c b/src/providers/proxy/proxy_child.c index 0f5884973..d19cc74c6 100644 --- a/src/providers/proxy/proxy_child.c +++ b/src/providers/proxy/proxy_child.c @@ -507,6 +507,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); /* set up things like debug , signals, daemonization, etc... */ debug_log_file = talloc_asprintf(NULL, "proxy_child_%s", domain); diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c index 041e25f26..ba45d7a41 100644 --- a/src/providers/proxy/proxy_id.c +++ b/src/providers/proxy/proxy_id.c @@ -395,7 +395,7 @@ done: #define DEBUG_GR_MEM(level, grp) \ do { \ - if (debug_level >= level) { \ + if (DEBUG_IS_SET(debug_get_level(level))) { \ if (!grp->gr_mem || !grp->gr_mem[0]) { \ DEBUG(level, ("Group %s has no members!\n", \ grp->gr_name)); \ diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c index 8fe53a8bb..7f60b7327 100644 --- a/src/responder/nss/nsssrv.c +++ b/src/responder/nss/nsssrv.c @@ -353,6 +353,8 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); + /* 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 86283eaec..2308288d5 100644 --- a/src/responder/pam/pamsrv.c +++ b/src/responder/pam/pamsrv.c @@ -209,6 +209,8 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); + /* set up things like debug, signals, daemonization, etc... */ debug_log_file = "sssd_pam"; diff --git a/src/sbus/sssd_dbus_common.c b/src/sbus/sssd_dbus_common.c index d446632d2..311da677b 100644 --- a/src/sbus/sssd_dbus_common.c +++ b/src/sbus/sssd_dbus_common.c @@ -226,7 +226,7 @@ void sbus_toggle_watch(DBusWatch *dbus_watch, void *data) } } - if (debug_level >= 8) { + if (DEBUG_IS_SET(SSSDBG_TRACE_INTERNAL)) { #ifdef HAVE_DBUS_WATCH_GET_UNIX_FD fd = dbus_watch_get_unix_fd(dbus_watch); #else diff --git a/src/tests/auth-tests.c b/src/tests/auth-tests.c index 026466271..aae2d0086 100644 --- a/src/tests/auth-tests.c +++ b/src/tests/auth-tests.c @@ -320,6 +320,8 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); + tests_set_cwd(); ret = clean_db_dir(); diff --git a/src/tests/crypto-tests.c b/src/tests/crypto-tests.c index 286bc2356..0f6f2fe0c 100644 --- a/src/tests/crypto-tests.c +++ b/src/tests/crypto-tests.c @@ -135,7 +135,7 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - debug_level = debug; + debug_level = debug_convert_old_level(debug); tests_set_cwd(); Suite *s = crypto_suite(); diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c index 8beaa8a26..439e5cf23 100644 --- a/src/tests/fail_over-tests.c +++ b/src/tests/fail_over-tests.c @@ -307,7 +307,7 @@ main(int argc, const char *argv[]) } } poptFreeContext(pc); - debug_level = debug; + debug_level = debug_convert_old_level(debug); tests_set_cwd(); diff --git a/src/tests/files-tests.c b/src/tests/files-tests.c index 7f6b41ed1..15d34c8e8 100644 --- a/src/tests/files-tests.c +++ b/src/tests/files-tests.c @@ -318,7 +318,7 @@ int main(int argc, const char *argv[]) return 1; } poptFreeContext(pc); - debug_level = debug; + debug_level = debug_convert_old_level(debug); tests_set_cwd(); diff --git a/src/tests/find_uid-tests.c b/src/tests/find_uid-tests.c index 8d1362f7f..a8f740563 100644 --- a/src/tests/find_uid-tests.c +++ b/src/tests/find_uid-tests.c @@ -114,7 +114,7 @@ Suite *find_uid_suite (void) int main(void) { - debug_level = 255; + debug_level = SSSDBG_MASK_ALL; int number_failed; tests_set_cwd(); diff --git a/src/tests/krb5_utils-tests.c b/src/tests/krb5_utils-tests.c index d5d1f0943..65e43193b 100644 --- a/src/tests/krb5_utils-tests.c +++ b/src/tests/krb5_utils-tests.c @@ -654,6 +654,7 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); + debug_level = debug_convert_old_level(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 5e85b6f84..99eedd9d6 100644 --- a/src/tests/refcount-tests.c +++ b/src/tests/refcount-tests.c @@ -218,7 +218,7 @@ int main(int argc, const char *argv[]) } } poptFreeContext(pc); - debug_level = debug; + debug_level = debug_convert_old_level(debug); tests_set_cwd(); diff --git a/src/tests/resolv-tests.c b/src/tests/resolv-tests.c index 5c1a487f4..3768fc978 100644 --- a/src/tests/resolv-tests.c +++ b/src/tests/resolv-tests.c @@ -790,7 +790,7 @@ int main(int argc, const char *argv[]) } } poptFreeContext(pc); - debug_level = debug; + debug_level = debug_convert_old_level(debug); 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 fbbc83618..6ae2356b7 100644 --- a/src/tests/simple_access-tests.c +++ b/src/tests/simple_access-tests.c @@ -162,6 +162,7 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); 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 2b91d482f..8e86c11f2 100644 --- a/src/tests/strtonum-tests.c +++ b/src/tests/strtonum-tests.c @@ -446,6 +446,8 @@ int main(int argc, const char *argv[]) { } poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); + tests_set_cwd(); strtonum_suite = create_strtonum_suite(); diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index 4c2021cfb..87b06ee40 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -3120,6 +3120,8 @@ int main(int argc, const char *argv[]) { } poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); + tests_set_cwd(); ret = unlink(TESTS_PATH"/"LOCAL_SYSDB_FILE); diff --git a/src/tests/util-tests.c b/src/tests/util-tests.c index e6d099b6f..b347aa7e1 100644 --- a/src/tests/util-tests.c +++ b/src/tests/util-tests.c @@ -355,6 +355,8 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); + debug_level = debug_convert_old_level(debug_level); + tests_set_cwd(); srunner_run_all(sr, CK_ENV); diff --git a/src/tools/selinux.c b/src/tools/selinux.c index 45672d1bb..8eb19a236 100644 --- a/src/tools/selinux.c +++ b/src/tools/selinux.c @@ -121,19 +121,7 @@ static void sss_semanage_error_callback(void *varg, return; } - if (level <= debug_level) { - if (debug_timestamps) { - time_t rightnow = time(NULL); - char stamp[25]; - memcpy(stamp, ctime(&rightnow), 24); - stamp[24] = '\0'; - debug_fn("(%s) [%s] [libsemanage] (%d): %s\n", - stamp, debug_prg_name, level, message); - } else { - debug_fn("[%s] [libsemanage] (%d): %s\n", - debug_prg_name, level, message); - } - } + DEBUG_MSG(level, "libsemanage", message); free(message); } diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c index 37b60c896..7f45ebb89 100644 --- a/src/tools/sss_cache.c +++ b/src/tools/sss_cache.c @@ -300,7 +300,7 @@ errno_t init_context(int argc, const char *argv[], struct cache_tool_ctx **tctx) BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } - debug_level = debug; + debug_level = debug_convert_old_level(debug); debug_prg_name = argv[0]; CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/sss_groupadd.c b/src/tools/sss_groupadd.c index 8817625d5..90b1d08ff 100644 --- a/src/tools/sss_groupadd.c +++ b/src/tools/sss_groupadd.c @@ -65,7 +65,7 @@ int main(int argc, const char **argv) BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } - debug_level = pc_debug; + debug_level = debug_convert_old_level(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 c9af565c2..49c5ad34b 100644 --- a/src/tools/sss_groupdel.c +++ b/src/tools/sss_groupdel.c @@ -61,7 +61,7 @@ int main(int argc, const char **argv) BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } - debug_level = pc_debug; + debug_level = debug_convert_old_level(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 48701adf6..bea57f874 100644 --- a/src/tools/sss_groupmod.c +++ b/src/tools/sss_groupmod.c @@ -98,7 +98,7 @@ int main(int argc, const char **argv) BAD_POPT_PARAMS(pc, _("Specify group to modify\n"), ret, fini); } - debug_level = pc_debug; + debug_level = debug_convert_old_level(pc_debug); CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c index a5702b589..40af95cce 100644 --- a/src/tools/sss_groupshow.c +++ b/src/tools/sss_groupshow.c @@ -639,7 +639,7 @@ int main(int argc, const char **argv) } } - debug_level = pc_debug; + debug_level = debug_convert_old_level(pc_debug); if (ret != -1) { BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c index 8de4816f6..3b0351635 100644 --- a/src/tools/sss_useradd.c +++ b/src/tools/sss_useradd.c @@ -96,7 +96,7 @@ int main(int argc, const char **argv) } } - debug_level = pc_debug; + debug_level = debug_convert_old_level(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 c5010e34e..1de406900 100644 --- a/src/tools/sss_userdel.c +++ b/src/tools/sss_userdel.c @@ -173,7 +173,7 @@ int main(int argc, const char **argv) } } - debug_level = pc_debug; + debug_level = debug_convert_old_level(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 e6d54d586..50fb0a0e4 100644 --- a/src/tools/sss_usermod.c +++ b/src/tools/sss_usermod.c @@ -109,7 +109,7 @@ int main(int argc, const char **argv) BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } - debug_level = pc_debug; + debug_level = debug_convert_old_level(pc_debug); /* username is an argument without --option */ pc_username = poptGetArg(pc); diff --git a/src/util/debug.c b/src/util/debug.c index cca92eb93..e7ae83860 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -33,7 +33,7 @@ const char *debug_prg_name = "sssd"; -int debug_level = SSS_UNRESOLVED_DEBUG_LEVEL; +int debug_level = SSSDBG_UNRESOLVED; int debug_timestamps = SSSDBG_TIMESTAMP_UNRESOLVED; int debug_to_file = 0; @@ -143,22 +143,22 @@ int debug_get_level(int old_level) void ldb_debug_messages(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) { - int loglevel = -1; + int loglevel = SSSDBG_UNRESOLVED; int ret; char * message = NULL; switch(level) { case LDB_DEBUG_FATAL: - loglevel = 0; + loglevel = SSSDBG_FATAL_FAILURE; break; case LDB_DEBUG_ERROR: - loglevel = 1; + loglevel = SSSDBG_CRIT_FAILURE; break; case LDB_DEBUG_WARNING: - loglevel = 6; + loglevel = SSSDBG_TRACE_FUNC; break; case LDB_DEBUG_TRACE: - loglevel = 9; + loglevel = SSSDBG_TRACE_ALL; break; } @@ -168,19 +168,8 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level, return; } - if (loglevel <= debug_level) { - if (debug_timestamps) { - time_t rightnow = time(NULL); - char stamp[25]; - memcpy(stamp, ctime(&rightnow), 24); - stamp[24] = '\0'; - debug_fn("(%s) [%s] [ldb] (%d): %s\n", - stamp, debug_prg_name, loglevel, message); - } else { - debug_fn("[%s] [ldb] (%d): %s\n", - debug_prg_name, loglevel, message); - } - } + DEBUG_MSG(loglevel, "ldb", message); + free(message); } diff --git a/src/util/server.c b/src/util/server.c index 7d16d0484..38b1bacae 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -463,13 +463,15 @@ int server_setup(const char *name, int flags, /* 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, + SSSDBG_DEFAULT, &debug_level); if (ret != EOK) { DEBUG(0, ("Error reading from confdb (%d) [%s]\n", ret, strerror(ret))); return ret; } + + debug_level = debug_convert_old_level(debug_level); } /* same for debug timestamps */ diff --git a/src/util/util.h b/src/util/util.h index f1f1c634e..22b0937d7 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -61,7 +61,6 @@ int debug_get_level(int old_level); int debug_convert_old_level(int old_level); errno_t set_debug_file_from_fd(const int fd); -#define SSS_DEFAULT_DEBUG_LEVEL SSSDBG_DEFAULT #define SSS_UNRESOLVED_DEBUG_LEVEL SSSDBG_UNRESOLVED #define SSSDBG_FATAL_FAILURE 0x0010 /* level 0 */ |