1 From 08fab6898a9937fbc39de6222cd33167707cd763 Mon Sep 17 00:00:00 2001
2 From: Robbie Harwood <rharwood@redhat.com>
3 Date: Wed, 11 Apr 2018 16:15:00 -0400
4 Subject: [PATCH] Always choose highest requested debug level
6 Allowing the CLI to lower the debug level specified in a config file
7 is dubious, and previously broken since we don't distinguish "default
8 value" from "explicitly requested value of 0" in popt. This resulted
9 in "Debug Enabled (level: 0)" even when the log level was not actually
10 0, which is confusing for users.
12 Remove the gp_debug_args() function since it is no longer used.
14 Signed-off-by: Robbie Harwood <rharwood@redhat.com>
15 Reviewed-by: Simo Sorce <simo@redhat.com>
17 (cherry picked from commit 5a714768aec776dc875237dd729c85389932a688)
19 proxy/src/gp_debug.c | 34 ++++++++--------------------------
20 proxy/src/gp_debug.h | 3 +--
21 proxy/src/gssproxy.c | 2 +-
22 3 files changed, 10 insertions(+), 29 deletions(-)
24 diff --git a/proxy/src/gp_debug.c b/proxy/src/gp_debug.c
25 index 4a141fc..a0f51f0 100644
26 --- a/proxy/src/gp_debug.c
27 +++ b/proxy/src/gp_debug.c
29 -/* Copyright (C) 2011 the GSS-PROXY contributors, see COPYING for license */
30 +/* Copyright (C) 2011,2018 the GSS-PROXY contributors, see COPYING for license */
37 /* global debug switch */
40 -int gp_debug_args(int level) {
41 - static int args_level = 0;
50 void gp_debug_toggle(int level)
52 - static bool krb5_trace_set = false;
53 + if (level <= gp_debug)
56 - /* Command line and environment options override config file */
57 - gp_debug = gp_debug_args(0);
58 - if (gp_debug == 0) {
62 - if (!getenv("KRB5_TRACE")) {
63 - setenv("KRB5_TRACE", "/dev/stderr", 1);
64 - krb5_trace_set = true;
66 - } else if (krb5_trace_set) {
67 - unsetenv("KRB5_TRACE");
68 - krb5_trace_set = false;
70 + if (level >= 3 && !getenv("KRB5_TRACE"))
71 + setenv("KRB5_TRACE", "/dev/stderr", 1);
74 GPDEBUG("Debug Enabled (level: %d)\n", level);
77 diff --git a/proxy/src/gp_debug.h b/proxy/src/gp_debug.h
78 index 1c2f8a3..4932bfd 100644
79 --- a/proxy/src/gp_debug.h
80 +++ b/proxy/src/gp_debug.h
82 -/* Copyright (C) 2011 the GSS-PROXY contributors, see COPYING for license */
83 +/* Copyright (C) 2011,2018 the GSS-PROXY contributors, see COPYING for license */
91 -int gp_debug_args(int level);
92 void gp_debug_toggle(int);
93 void gp_debug_printf(const char *format, ...);
94 void gp_debug_time_printf(const char *format, ...);
95 diff --git a/proxy/src/gssproxy.c b/proxy/src/gssproxy.c
96 index 5fc4f8d..3b6a16e 100644
97 --- a/proxy/src/gssproxy.c
98 +++ b/proxy/src/gssproxy.c
99 @@ -209,7 +209,7 @@ int main(int argc, const char *argv[])
101 if (opt_debug || opt_debug_level > 0) {
102 if (opt_debug_level == 0) opt_debug_level = 1;
103 - gp_debug_args(opt_debug_level);
104 + gp_debug_toggle(opt_debug_level);
107 if (opt_daemon && opt_interactive) {