summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-03-30 12:13:38 -0400
committerSimo Sorce <simo@redhat.com>2012-04-02 23:56:54 -0400
commitbe13a48d8929c6edcc7525749d57ce450204d657 (patch)
tree0afd5b0c304627e6a02d7c8efa2a30eb20b14c54
parent14ef713434acb89e8c715eed7ba180a38fd604a9 (diff)
downloadgss-proxy-be13a48d8929c6edcc7525749d57ce450204d657.tar.gz
gss-proxy-be13a48d8929c6edcc7525749d57ce450204d657.tar.xz
gss-proxy-be13a48d8929c6edcc7525749d57ce450204d657.zip
Debug: Add debugging macro and config options
Ticket #43
-rw-r--r--proxy/src/gp_common.h2
-rw-r--r--proxy/src/gp_config.c9
-rw-r--r--proxy/src/gp_debug.c10
-rw-r--r--proxy/src/gp_debug.h10
-rw-r--r--proxy/src/gssproxy.c7
5 files changed, 38 insertions, 0 deletions
diff --git a/proxy/src/gp_common.h b/proxy/src/gp_common.h
index 3763e12..89c7827 100644
--- a/proxy/src/gp_common.h
+++ b/proxy/src/gp_common.h
@@ -26,6 +26,8 @@
#ifndef _GP_COMMON_H_
#define _GP_COMMON_H_
+#include "gp_debug.h"
+
/* add element to list head */
#define LIST_ADD(list, elem) do { \
elem->prev = NULL; \
diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c
index ca0f2c1..f20a7b8 100644
--- a/proxy/src/gp_config.c
+++ b/proxy/src/gp_config.c
@@ -286,6 +286,15 @@ int load_config(struct gp_config *cfg)
return ENOENT;
}
+ tmpstr = iniparser_getstring(d, "gssproxy:debug", NULL);
+ if (tmpstr) {
+ if (strcasecmp(tmpstr, "1") == 0 ||
+ strcasecmp(tmpstr, "on") == 0 ||
+ strcasecmp(tmpstr, "true") == 0) {
+ gp_debug_enable();
+ }
+ }
+
tmpstr = iniparser_getstring(d, "gssproxy:socket", NULL);
if (tmpstr) {
cfg->socket_name = strdup(tmpstr);
diff --git a/proxy/src/gp_debug.c b/proxy/src/gp_debug.c
index 2f94738..dbf7c49 100644
--- a/proxy/src/gp_debug.c
+++ b/proxy/src/gp_debug.c
@@ -24,8 +24,18 @@
*/
#include "config.h"
+#include <gssapi/gssapi.h>
#include "gp_debug.h"
+/* global debug switch */
+int gp_debug;
+
+void gp_debug_enable(void)
+{
+ gp_debug = 1;
+ GPDEBUG("Debug Enabled\n");
+}
+
void gp_log_failure(gss_OID mech, uint32_t maj, uint32_t min)
{
uint32_t msgctx;
diff --git a/proxy/src/gp_debug.h b/proxy/src/gp_debug.h
index 5f1a525..3bcc3bd 100644
--- a/proxy/src/gp_debug.h
+++ b/proxy/src/gp_debug.h
@@ -29,6 +29,16 @@
#include <gssapi/gssapi.h>
#include "rpcgen/gss_proxy.h"
+extern int gp_debug;
+
+void gp_debug_enable(void);
+
+#define GPDEBUG(...) do { \
+ if (gp_debug) { \
+ fprintf(stderr, __VA_ARGS__); \
+ } \
+} while(0)
+
void gp_log_failure(gss_OID mech, uint32_t maj, uint32_t min);
#endif /* _GP_DEBUG_H_ */
diff --git a/proxy/src/gssproxy.c b/proxy/src/gssproxy.c
index 311cc52..f8a0834 100644
--- a/proxy/src/gssproxy.c
+++ b/proxy/src/gssproxy.c
@@ -36,6 +36,7 @@ int main(int argc, const char *argv[])
int opt_interactive = 0;
int opt_version = 0;
char *opt_config_file = NULL;
+ int opt_debug = 0;
verto_ctx *vctx;
verto_ev *ev;
int vflags;
@@ -51,6 +52,8 @@ int main(int argc, const char *argv[])
_("Run interactive (not a daemon)"), NULL}, \
{"config", 'c', POPT_ARG_STRING, &opt_config_file, 0, \
_("Specify a non-default config file"), NULL}, \
+ {"debug", 'd', POPT_ARG_NONE, &opt_debug, 0, \
+ _("Specify a non-default config file"), NULL}, \
{"version", '\0', POPT_ARG_NONE, &opt_version, 0, \
_("Print version number and exit"), NULL }, \
POPT_TABLEEND
@@ -72,6 +75,10 @@ int main(int argc, const char *argv[])
return 0;
}
+ if (opt_debug) {
+ gp_debug_enable();
+ }
+
if (opt_daemon && opt_interactive) {
fprintf(stderr, "Option -i|--interactive is not allowed together with -D|--daemon\n");
poptPrintUsage(pc, stderr, 0);