diff options
39 files changed, 52 insertions, 43 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index a5653999e..af2189c73 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -2497,7 +2497,7 @@ int main(int argc, const char *argv[]) } } - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); if (opt_version) { puts(VERSION""DISTRO_VERSION""PRERELEASE_VERSION); diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index 4e4bdab28..0ac83f43b 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -2388,8 +2388,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); - + DEBUG_INIT(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/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c index 3e64a8652..e7776248b 100644 --- a/src/providers/krb5/krb5_child.c +++ b/src/providers/krb5/krb5_child.c @@ -2078,7 +2078,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); debug_prg_name = talloc_asprintf(NULL, "[sssd[krb5_child[%d]]]", getpid()); if (!debug_prg_name) { diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c index f35d94672..9d82e7cf7 100644 --- a/src/providers/ldap/ldap_child.c +++ b/src/providers/ldap/ldap_child.c @@ -458,7 +458,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); debug_prg_name = talloc_asprintf(NULL, "[sssd[ldap_child[%d]]]", getpid()); if (!debug_prg_name) { diff --git a/src/providers/proxy/proxy_child.c b/src/providers/proxy/proxy_child.c index 8aa1d7627..c575948a7 100644 --- a/src/providers/proxy/proxy_child.c +++ b/src/providers/proxy/proxy_child.c @@ -510,7 +510,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); /* set up things like debug , signals, daemonization, etc... */ debug_log_file = talloc_asprintf(NULL, "proxy_child_%s", domain); diff --git a/src/responder/autofs/autofssrv.c b/src/responder/autofs/autofssrv.c index dcb188fd4..86a816a34 100644 --- a/src/responder/autofs/autofssrv.c +++ b/src/responder/autofs/autofssrv.c @@ -198,7 +198,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); /* set up things like debug, signals, daemonization, etc... */ debug_log_file = "sssd_autofs"; diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c index 1156c45f4..e01bd1a4d 100644 --- a/src/responder/nss/nsssrv.c +++ b/src/responder/nss/nsssrv.c @@ -472,7 +472,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); /* set up things like debug, signals, daemonization, etc... */ debug_log_file = "sssd_nss"; diff --git a/src/responder/pac/pacsrv.c b/src/responder/pac/pacsrv.c index 348fc6f47..036dd6a5f 100644 --- a/src/responder/pac/pacsrv.c +++ b/src/responder/pac/pacsrv.c @@ -235,7 +235,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); /* set up things like debug, signals, daemonization, etc... */ debug_log_file = "sssd_pac"; diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c index c94596c4c..c608f5814 100644 --- a/src/responder/pam/pamsrv.c +++ b/src/responder/pam/pamsrv.c @@ -236,7 +236,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); /* set up things like debug, signals, daemonization, etc... */ debug_log_file = "sssd_pam"; diff --git a/src/responder/ssh/sshsrv.c b/src/responder/ssh/sshsrv.c index fe01f81f1..32c0f3080 100644 --- a/src/responder/ssh/sshsrv.c +++ b/src/responder/ssh/sshsrv.c @@ -186,7 +186,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); /* set up things like debug, signals, daemonization, etc... */ debug_log_file = "sssd_ssh"; diff --git a/src/responder/sudo/sudosrv.c b/src/responder/sudo/sudosrv.c index b4f8f8879..cb89e1f75 100644 --- a/src/responder/sudo/sudosrv.c +++ b/src/responder/sudo/sudosrv.c @@ -176,7 +176,7 @@ int main(int argc, const char *argv[]) poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); /* set up things like debug, signals, daemonization, etc... */ debug_log_file = "sssd_sudo"; diff --git a/src/sss_client/ssh/sss_ssh_authorizedkeys.c b/src/sss_client/ssh/sss_ssh_authorizedkeys.c index 902b4a070..11deff9a6 100644 --- a/src/sss_client/ssh/sss_ssh_authorizedkeys.c +++ b/src/sss_client/ssh/sss_ssh_authorizedkeys.c @@ -73,7 +73,7 @@ int main(int argc, const char **argv) while ((ret = poptGetNextOpt(pc)) > 0) ; - debug_level = debug_convert_old_level(pc_debug); + DEBUG_INIT(pc_debug); if (ret != -1) { BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); diff --git a/src/sss_client/ssh/sss_ssh_knownhostsproxy.c b/src/sss_client/ssh/sss_ssh_knownhostsproxy.c index 76356bdc9..600895d1f 100644 --- a/src/sss_client/ssh/sss_ssh_knownhostsproxy.c +++ b/src/sss_client/ssh/sss_ssh_knownhostsproxy.c @@ -228,7 +228,7 @@ int main(int argc, const char **argv) while ((ret = poptGetNextOpt(pc)) > 0) ; - debug_level = debug_convert_old_level(pc_debug); + DEBUG_INIT(pc_debug); if (ret != -1) { BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); diff --git a/src/tests/auth-tests.c b/src/tests/auth-tests.c index 4d25e2ef7..ff8b9e1bd 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); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tests/crypto-tests.c b/src/tests/crypto-tests.c index 0492a3845..8932d8f56 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); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c index 3a7c4ae4e..93dda3a77 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); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tests/files-tests.c b/src/tests/files-tests.c index cb20e1aae..56c9ab9bf 100644 --- a/src/tests/files-tests.c +++ b/src/tests/files-tests.c @@ -322,7 +322,7 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tests/krb5_child-test.c b/src/tests/krb5_child-test.c index d55eec077..34d025b77 100644 --- a/src/tests/krb5_child-test.c +++ b/src/tests/krb5_child-test.c @@ -477,7 +477,7 @@ main(int argc, const char *argv[]) } } - debug_level = debug_convert_old_level(pc_debug); + DEBUG_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 fe5d8423f..77dc27ca8 100644 --- a/src/tests/krb5_utils-tests.c +++ b/src/tests/krb5_utils-tests.c @@ -791,7 +791,7 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_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 18f555320..9a7e5b94c 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); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tests/resolv-tests.c b/src/tests/resolv-tests.c index ad89aaf6d..c61d6f8ce 100644 --- a/src/tests/resolv-tests.c +++ b/src/tests/resolv-tests.c @@ -856,7 +856,7 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); 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 734bf1cbc..a01a5d12c 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); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_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 c61814eb5..486f87d9a 100644 --- a/src/tests/simple_access-tests.c +++ b/src/tests/simple_access-tests.c @@ -196,7 +196,7 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tests/strtonum-tests.c b/src/tests/strtonum-tests.c index e7d703643..009f0049a 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); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index d9afe7b88..3a07a6495 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -4099,7 +4099,7 @@ int main(int argc, const char *argv[]) { } poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tests/sysdb_ssh-tests.c b/src/tests/sysdb_ssh-tests.c index f914993cc..f44c2f946 100644 --- a/src/tests/sysdb_ssh-tests.c +++ b/src/tests/sysdb_ssh-tests.c @@ -402,7 +402,7 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tests/util-tests.c b/src/tests/util-tests.c index 59c80ca6f..80c03c73b 100644 --- a/src/tests/util-tests.c +++ b/src/tests/util-tests.c @@ -713,7 +713,7 @@ int main(int argc, const char *argv[]) } poptFreeContext(pc); - CONVERT_AND_SET_DEBUG_LEVEL(debug_level); + DEBUG_INIT(debug_level); tests_set_cwd(); diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c index 73d99651b..9b91f982b 100644 --- a/src/tools/sss_cache.c +++ b/src/tools/sss_cache.c @@ -414,7 +414,7 @@ errno_t init_context(int argc, const char *argv[], struct cache_tool_ctx **tctx) ret, fini); } - debug_level = debug_convert_old_level(debug); + DEBUG_INIT(debug); debug_prg_name = argv[0]; CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/sss_debuglevel.c b/src/tools/sss_debuglevel.c index 72701386a..e955ec381 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_level = debug_convert_old_level(pc_debug); + DEBUG_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 2a01f392c..5667e9aa2 100644 --- a/src/tools/sss_groupadd.c +++ b/src/tools/sss_groupadd.c @@ -67,7 +67,7 @@ int main(int argc, const char **argv) BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } - debug_level = debug_convert_old_level(pc_debug); + DEBUG_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 70030cab4..57c3e7004 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 = debug_convert_old_level(pc_debug); + DEBUG_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 c210bad75..1d80c5921 100644 --- a/src/tools/sss_groupmod.c +++ b/src/tools/sss_groupmod.c @@ -100,7 +100,7 @@ int main(int argc, const char **argv) BAD_POPT_PARAMS(pc, _("Specify group to modify\n"), ret, fini); } - debug_level = debug_convert_old_level(pc_debug); + DEBUG_INIT(pc_debug); CHECK_ROOT(ret, debug_prg_name); diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c index 2ba495c19..7ba1db139 100644 --- a/src/tools/sss_groupshow.c +++ b/src/tools/sss_groupshow.c @@ -675,7 +675,7 @@ int main(int argc, const char **argv) } } - debug_level = debug_convert_old_level(pc_debug); + DEBUG_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 18d0b9d08..cd1b26386 100644 --- a/src/tools/sss_seed.c +++ b/src/tools/sss_seed.c @@ -521,7 +521,7 @@ static int seed_init(TALLOC_CTX *mem_ctx, BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } - debug_level = debug_convert_old_level(pc_debug); + DEBUG_INIT(pc_debug); CHECK_ROOT(ret, argv[0]); diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c index 1bf174c51..ef594aed4 100644 --- a/src/tools/sss_useradd.c +++ b/src/tools/sss_useradd.c @@ -98,7 +98,7 @@ int main(int argc, const char **argv) } } - debug_level = debug_convert_old_level(pc_debug); + DEBUG_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 0d1c63e4c..5d250f6c9 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 = debug_convert_old_level(pc_debug); + DEBUG_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 a45005caa..f6730368a 100644 --- a/src/tools/sss_usermod.c +++ b/src/tools/sss_usermod.c @@ -111,7 +111,7 @@ int main(int argc, const char **argv) BAD_POPT_PARAMS(pc, poptStrerror(ret), ret, fini); } - debug_level = debug_convert_old_level(pc_debug); + DEBUG_INIT(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 e57656d7f..cb90d65ac 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -256,3 +256,8 @@ int rotate_debug_files(void) return open_debug_file(); } + +void talloc_log_fn(const char *message) +{ + DEBUG(SSSDBG_FATAL_FAILURE, (message)); +} diff --git a/src/util/util.h b/src/util/util.h index a96f519ad..df57a3dec 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -194,11 +194,15 @@ errno_t set_debug_file_from_fd(const int fd); */ #define DEBUG_IS_SET(level) (debug_level & (level)) -#define CONVERT_AND_SET_DEBUG_LEVEL(new_value) debug_level = ( \ - ((new_value) != SSSDBG_INVALID) \ - ? debug_convert_old_level(new_value) \ - : SSSDBG_UNRESOLVED /* Debug level should be loaded from config file. */ \ -); +#define DEBUG_INIT(dbg_lvl) do { \ + if (dbg_lvl != SSSDBG_INVALID) { \ + debug_level = debug_convert_old_level(dbg_lvl); \ + } else { \ + debug_level = SSSDBG_UNRESOLVED; \ + } \ +\ + talloc_set_log_fn(talloc_log_fn); \ +} while (0) #define PRINT(fmt, ...) fprintf(stdout, gettext(fmt), ##__VA_ARGS__) #define ERROR(fmt, ...) fprintf(stderr, gettext(fmt), ##__VA_ARGS__) @@ -341,6 +345,7 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level, int open_debug_file_ex(const char *filename, FILE **filep); int open_debug_file(void); int rotate_debug_files(void); +void talloc_log_fn(const char *msg); /* From sss_log.c */ #define SSS_LOG_EMERG 0 /* system is unusable */ |