diff options
author | Günther Deschner <gdeschner@redhat.com> | 2013-05-30 15:54:33 +0200 |
---|---|---|
committer | Günther Deschner <gdeschner@redhat.com> | 2014-01-14 14:31:56 +0100 |
commit | 0e7a983ae04658f818bcc0332db3f30a58b01aba (patch) | |
tree | 22e10c9e514227e94aefa76aec147505a02c2e7d /proxy/src | |
parent | 8b147c9196d9068d0fc5e5a8919b84e8cbb97ef4 (diff) | |
download | gss-proxy-0e7a983ae04658f818bcc0332db3f30a58b01aba.tar.gz gss-proxy-0e7a983ae04658f818bcc0332db3f30a58b01aba.tar.xz gss-proxy-0e7a983ae04658f818bcc0332db3f30a58b01aba.zip |
Make it easier to enable mechglue plugin debugging.
Instead of recompiling, one can set the "GSSI_DEBUG" environment variable at
runtime.
Signed-off-by: Günther Deschner <gdeschner@redhat.com>
Diffstat (limited to 'proxy/src')
-rw-r--r-- | proxy/src/mechglue/gss_plugin.c | 17 | ||||
-rw-r--r-- | proxy/src/mechglue/gss_plugin.h | 25 |
2 files changed, 31 insertions, 11 deletions
diff --git a/proxy/src/mechglue/gss_plugin.c b/proxy/src/mechglue/gss_plugin.c index 372ab2e..ab0f139 100644 --- a/proxy/src/mechglue/gss_plugin.c +++ b/proxy/src/mechglue/gss_plugin.c @@ -605,3 +605,20 @@ bool gpp_is_krb5_oid(const gss_OID mech) } return false; } + +bool gpp_debugging_enabled(void) +{ + static enum gpp_debugging debug = GPP_DEBUG_UNINITIALIZED; + char *envval; + + if (debug == GPP_DEBUG_UNINITIALIZED) { + envval = getenv("GSSI_DEBUG"); + if (envval) { + debug = GPP_DEBUG_ENABLED; + } else { + debug = GPP_DEBUG_DISABLED; + } + } + + return debug; +} diff --git a/proxy/src/mechglue/gss_plugin.h b/proxy/src/mechglue/gss_plugin.h index 739ec26..638ad77 100644 --- a/proxy/src/mechglue/gss_plugin.h +++ b/proxy/src/mechglue/gss_plugin.h @@ -54,26 +54,29 @@ enum gpp_behavior { GPP_REMOTE_ONLY, }; -#ifdef GSSI_DEBUGGING +enum gpp_debugging { + GPP_DEBUG_UNINITIALIZED = 0, + GPP_DEBUG_ENABLED, + GPP_DEBUG_DISABLED +}; #define GSSI_DEBUG(...) \ do { \ - fprintf(stderr, "GSSI %s:%d ", __FUNCTION__, __LINE__); \ - fprintf(stderr, __VA_ARGS__); \ - fflush(stderr); \ + if (gpp_debugging_enabled() == GPP_DEBUG_ENABLED) { \ + fprintf(stderr, "GSSI %s:%d ", __FUNCTION__, __LINE__); \ + fprintf(stderr, __VA_ARGS__); \ + fflush(stderr); \ + } \ } while(0); #define GSSI_TRACE(...) \ do { \ - fprintf(stderr, "GSSI %s:%d called\n", __FUNCTION__, __LINE__); \ - fflush(stderr); \ + if (gpp_debugging_enabled() == GPP_DEBUG_ENABLED) { \ + fprintf(stderr, "GSSI %s:%d called\n", __FUNCTION__, __LINE__); \ + fflush(stderr); \ + } \ } while(0); -#else -#define GSSI_DEBUG(...) -#define GSSI_TRACE(...) -#endif /* GSSI_DEBUGGING */ - gss_OID_set gss_mech_interposer(gss_OID mech_type); enum gpp_behavior gpp_get_behavior(void); bool gpp_is_special_oid(const gss_OID mech_type); |