Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-distro / recipes-security / gssproxy / files / Always-choose-highest-requested-debug-level.patch
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
5
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.
11
12 Remove the gp_debug_args() function since it is no longer used.
13
14 Signed-off-by: Robbie Harwood <rharwood@redhat.com>
15 Reviewed-by: Simo Sorce <simo@redhat.com>
16 Merges: #229
17 (cherry picked from commit 5a714768aec776dc875237dd729c85389932a688)
18 ---
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(-)
23
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
28 @@ -1,4 +1,4 @@
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 */
31  
32  #include "config.h"
33  #include <stdbool.h>
34 @@ -7,35 +7,17 @@
35  #include "gp_log.h"
36  
37  /* global debug switch */
38 -int gp_debug;
39 -
40 -int gp_debug_args(int level) {
41 -    static int args_level = 0;
42 -
43 -    if (level != 0) {
44 -        args_level = level;
45 -    }
46 -    return args_level;
47 -}
48 +int gp_debug = 0;
49  
50  void gp_debug_toggle(int level)
51  {
52 -    static bool krb5_trace_set = false;
53 +    if (level <= gp_debug)
54 +        return;
55  
56 -    /* Command line and environment options override config file */
57 -    gp_debug = gp_debug_args(0);
58 -    if (gp_debug == 0) {
59 -        gp_debug = level;
60 -    }
61 -    if (level >= 3) {
62 -        if (!getenv("KRB5_TRACE")) {
63 -            setenv("KRB5_TRACE", "/dev/stderr", 1);
64 -            krb5_trace_set = true;
65 -        }
66 -    } else if (krb5_trace_set) {
67 -        unsetenv("KRB5_TRACE");
68 -        krb5_trace_set = false;
69 -    }
70 +    if (level >= 3 && !getenv("KRB5_TRACE"))
71 +        setenv("KRB5_TRACE", "/dev/stderr", 1);
72 +
73 +    gp_debug = level;
74      GPDEBUG("Debug Enabled (level: %d)\n", level);
75  }
76  
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
81 @@ -1,4 +1,4 @@
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 */
84  
85  #ifndef _GP_DEBUG_H_
86  #define _GP_DEBUG_H_
87 @@ -10,7 +10,6 @@
88  
89  extern int gp_debug;
90  
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[])
100  
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);
105      }
106  
107      if (opt_daemon && opt_interactive) {