199 lines
7.1 KiB
Diff
199 lines
7.1 KiB
Diff
From 8dba7476922856e3a0f6cb935570df47b51917f1 Mon Sep 17 00:00:00 2001
|
|
From: Alexey Tikhonov <atikhono@redhat.com>
|
|
Date: Fri, 18 Jun 2021 21:56:53 +0200
|
|
Subject: [PATCH 14/16] DEBUG: don't reset debug_timestamps/microseconds to
|
|
DEFAULT in `_sss_debug_init()`.
|
|
|
|
Otherwise `server_setup()` skips reading config settings.
|
|
|
|
Reviewed-by: Pawel Polawski <ppolawsk@redhat.com>
|
|
---
|
|
src/tests/cmocka/test_child_common.c | 2 +-
|
|
src/tests/debug-tests.c | 26 +++++++++++++-------------
|
|
src/util/debug.c | 14 +++-----------
|
|
src/util/debug.h | 8 ++++++--
|
|
src/util/server.c | 8 ++++----
|
|
5 files changed, 27 insertions(+), 31 deletions(-)
|
|
|
|
diff --git a/src/tests/cmocka/test_child_common.c b/src/tests/cmocka/test_child_common.c
|
|
index 87cae3405575a0c6d2f746359518766c20acb346..9fb26412f3e6c2553e477f72f40f0fd6a156cdab 100644
|
|
--- a/src/tests/cmocka/test_child_common.c
|
|
+++ b/src/tests/cmocka/test_child_common.c
|
|
@@ -163,7 +163,7 @@ static void extra_args_test(struct child_test_ctx *child_tctx,
|
|
child_pid = fork();
|
|
assert_int_not_equal(child_pid, -1);
|
|
if (child_pid == 0) {
|
|
- debug_timestamps = 1;
|
|
+ debug_timestamps = SSSDBG_TIMESTAMP_ENABLED;
|
|
|
|
exec_child_ex(child_tctx,
|
|
child_tctx->pipefd_to_child,
|
|
diff --git a/src/tests/debug-tests.c b/src/tests/debug-tests.c
|
|
index e27fee45785a8a042922e14d562b4b6846bb8cd9..68a1fb7795ff9c247a3c5706ca479905ce55134c 100644
|
|
--- a/src/tests/debug-tests.c
|
|
+++ b/src/tests/debug-tests.c
|
|
@@ -194,7 +194,7 @@ int test_helper_debug_check_message(int level)
|
|
}
|
|
msg[fsize] = '\0';
|
|
|
|
- if (debug_timestamps == 1) {
|
|
+ if (debug_timestamps == SSSDBG_TIMESTAMP_ENABLED) {
|
|
int time_hour = 0;
|
|
int time_min = 0;
|
|
int time_sec = 0;
|
|
@@ -344,8 +344,8 @@ START_TEST(test_debug_is_set_single_no_timestamp)
|
|
SSSDBG_TRACE_LDB
|
|
};
|
|
|
|
- debug_timestamps = 0;
|
|
- debug_microseconds = 0;
|
|
+ debug_timestamps = SSSDBG_TIMESTAMP_DISABLED;
|
|
+ debug_microseconds = SSSDBG_MICROSECONDS_DISABLED;
|
|
debug_prg_name = "sssd";
|
|
sss_set_logger(sss_logger_str[FILES_LOGGER]);
|
|
|
|
@@ -384,8 +384,8 @@ START_TEST(test_debug_is_set_single_timestamp)
|
|
SSSDBG_TRACE_LDB
|
|
};
|
|
|
|
- debug_timestamps = 1;
|
|
- debug_microseconds = 0;
|
|
+ debug_timestamps = SSSDBG_TIMESTAMP_ENABLED;
|
|
+ debug_microseconds = SSSDBG_MICROSECONDS_DISABLED;
|
|
debug_prg_name = "sssd";
|
|
sss_set_logger(sss_logger_str[FILES_LOGGER]);
|
|
|
|
@@ -428,8 +428,8 @@ START_TEST(test_debug_is_set_single_timestamp_microseconds)
|
|
SSSDBG_TRACE_LDB
|
|
};
|
|
|
|
- debug_timestamps = 1;
|
|
- debug_microseconds = 1;
|
|
+ debug_timestamps = SSSDBG_TIMESTAMP_ENABLED;
|
|
+ debug_microseconds = SSSDBG_MICROSECONDS_ENABLED;
|
|
debug_prg_name = "sssd";
|
|
sss_set_logger(sss_logger_str[FILES_LOGGER]);
|
|
|
|
@@ -473,8 +473,8 @@ START_TEST(test_debug_is_notset_no_timestamp)
|
|
SSSDBG_TRACE_LDB
|
|
};
|
|
|
|
- debug_timestamps = 0;
|
|
- debug_microseconds = 0;
|
|
+ debug_timestamps = SSSDBG_TIMESTAMP_DISABLED;
|
|
+ debug_microseconds = SSSDBG_MICROSECONDS_DISABLED;
|
|
debug_prg_name = "sssd";
|
|
sss_set_logger(sss_logger_str[FILES_LOGGER]);
|
|
|
|
@@ -515,8 +515,8 @@ START_TEST(test_debug_is_notset_timestamp)
|
|
SSSDBG_TRACE_LDB
|
|
};
|
|
|
|
- debug_timestamps = 0;
|
|
- debug_microseconds = 0;
|
|
+ debug_timestamps = SSSDBG_TIMESTAMP_DISABLED;
|
|
+ debug_microseconds = SSSDBG_MICROSECONDS_DISABLED;
|
|
debug_prg_name = "sssd";
|
|
sss_set_logger(sss_logger_str[FILES_LOGGER]);
|
|
|
|
@@ -557,8 +557,8 @@ START_TEST(test_debug_is_notset_timestamp_microseconds)
|
|
SSSDBG_TRACE_LDB
|
|
};
|
|
|
|
- debug_timestamps = 0;
|
|
- debug_microseconds = 1;
|
|
+ debug_timestamps = SSSDBG_TIMESTAMP_DISABLED;
|
|
+ debug_microseconds = SSSDBG_MICROSECONDS_ENABLED;
|
|
debug_prg_name = "sssd";
|
|
sss_set_logger(sss_logger_str[FILES_LOGGER]);
|
|
|
|
diff --git a/src/util/debug.c b/src/util/debug.c
|
|
index f87e85812aa243deab4683ad7d7712d527daa4a2..6f12344374ef104bde1ddd9b738270ce961d5893 100644
|
|
--- a/src/util/debug.c
|
|
+++ b/src/util/debug.c
|
|
@@ -103,14 +103,6 @@ void _sss_debug_init(int dbg_lvl, const char *logger)
|
|
debug_level = SSSDBG_UNRESOLVED;
|
|
}
|
|
|
|
- if (debug_timestamps == SSSDBG_TIMESTAMP_UNRESOLVED) {
|
|
- debug_timestamps = SSSDBG_TIMESTAMP_DEFAULT;
|
|
- }
|
|
-
|
|
- if (debug_microseconds == SSSDBG_MICROSECONDS_UNRESOLVED) {
|
|
- debug_microseconds = SSSDBG_MICROSECONDS_DEFAULT;
|
|
- }
|
|
-
|
|
sss_set_logger(logger);
|
|
|
|
/* if 'FILES_LOGGER' is requested then open log file, if it wasn't
|
|
@@ -305,8 +297,8 @@ void sss_vdebug_fn(const char *file,
|
|
}
|
|
#endif
|
|
|
|
- if (debug_timestamps) {
|
|
- if (debug_microseconds) {
|
|
+ if (debug_timestamps == SSSDBG_TIMESTAMP_ENABLED) {
|
|
+ if (debug_microseconds == SSSDBG_MICROSECONDS_ENABLED) {
|
|
gettimeofday(&tv, NULL);
|
|
t = tv.tv_sec;
|
|
} else {
|
|
@@ -320,7 +312,7 @@ void sss_vdebug_fn(const char *file,
|
|
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
|
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
}
|
|
- if (debug_microseconds) {
|
|
+ if (debug_microseconds == SSSDBG_MICROSECONDS_ENABLED) {
|
|
sss_debug_backtrace_printf(level, "%s:%.6ld): ",
|
|
last_time_str, tv.tv_usec);
|
|
} else {
|
|
diff --git a/src/util/debug.h b/src/util/debug.h
|
|
index 97564d43e2f2e0d88ccb1e88365f6d7aaf401e81..9d3499dbdfee95931b6004b9a5ec1b9832ce1b1c 100644
|
|
--- a/src/util/debug.h
|
|
+++ b/src/util/debug.h
|
|
@@ -29,10 +29,14 @@
|
|
#include "util/util_errors.h"
|
|
|
|
#define SSSDBG_TIMESTAMP_UNRESOLVED -1
|
|
-#define SSSDBG_TIMESTAMP_DEFAULT 1
|
|
+#define SSSDBG_TIMESTAMP_DISABLED 0
|
|
+#define SSSDBG_TIMESTAMP_ENABLED 1
|
|
+#define SSSDBG_TIMESTAMP_DEFAULT SSSDBG_TIMESTAMP_ENABLED
|
|
|
|
#define SSSDBG_MICROSECONDS_UNRESOLVED -1
|
|
-#define SSSDBG_MICROSECONDS_DEFAULT 0
|
|
+#define SSSDBG_MICROSECONDS_DISABLED 0
|
|
+#define SSSDBG_MICROSECONDS_ENABLED 1
|
|
+#define SSSDBG_MICROSECONDS_DEFAULT SSSDBG_MICROSECONDS_DISABLED
|
|
|
|
|
|
enum sss_logger_t {
|
|
diff --git a/src/util/server.c b/src/util/server.c
|
|
index b6f450a798b84e22e493f3a32d5289e20f3fc280..4fe29f96b8176c236fc35052265dbf6974678608 100644
|
|
--- a/src/util/server.c
|
|
+++ b/src/util/server.c
|
|
@@ -624,8 +624,8 @@ int server_setup(const char *name, int flags,
|
|
"[%s]\n", ret, strerror(ret));
|
|
return ret;
|
|
}
|
|
- if (dt) debug_timestamps = 1;
|
|
- else debug_timestamps = 0;
|
|
+ if (dt) debug_timestamps = SSSDBG_TIMESTAMP_ENABLED;
|
|
+ else debug_timestamps = SSSDBG_TIMESTAMP_DISABLED;
|
|
}
|
|
|
|
/* same for debug microseconds */
|
|
@@ -639,8 +639,8 @@ int server_setup(const char *name, int flags,
|
|
"[%s]\n", ret, strerror(ret));
|
|
return ret;
|
|
}
|
|
- if (dm) debug_microseconds = 1;
|
|
- else debug_microseconds = 0;
|
|
+ if (dm) debug_microseconds = SSSDBG_MICROSECONDS_ENABLED;
|
|
+ else debug_microseconds = SSSDBG_MICROSECONDS_DISABLED;
|
|
}
|
|
|
|
ret = confdb_get_bool(ctx->confdb_ctx, conf_entry,
|
|
--
|
|
2.20.1
|
|
|