Blame SOURCES/Make-syslog-of-call-status-configurable.patch

15b414
From 07b32184ee337ec06a405724b4b88cad22829c6d Mon Sep 17 00:00:00 2001
15b414
From: Robbie Harwood <rharwood@redhat.com>
15b414
Date: Mon, 30 Sep 2019 15:00:56 -0400
15b414
Subject: [PATCH] Make syslog of call status configurable
15b414
15b414
Add a parameter (syslog_status) to configuration and
15b414
CLI (--syslog-status).  This logs the results of GSSAPI calls at
15b414
LOG_DEBUG.  Typically these calls resemble:
15b414
15b414
    gssproxy[28914]: (OID: { 1 2 840 113554 1 2 2 }) Unspecified GSS
15b414
    failure.  Minor code may provide more information, No credentials
15b414
    cache found
15b414
15b414
Since these messages worry some admins, turn them off by default.
15b414
15b414
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
15b414
(cherry picked from commit 116618e1523038691fcb481107ba15ffd42942ac)
15b414
(cherry picked from commit cc61409b7b20974332549dd028d889b87dbff98d)
15b414
---
15b414
 man/gssproxy.8.xml      |  8 ++++++++
15b414
 man/gssproxy.conf.5.xml | 10 ++++++++++
15b414
 src/gp_config.c         |  6 ++++++
15b414
 src/gp_log.c            |  9 +++++++--
15b414
 src/gp_log.h            |  3 +++
15b414
 src/gssproxy.c          |  6 ++++++
15b414
 6 files changed, 40 insertions(+), 2 deletions(-)
15b414
15b414
diff --git a/man/gssproxy.8.xml b/man/gssproxy.8.xml
15b414
index 21f7e6a..4019135 100644
15b414
--- a/man/gssproxy.8.xml
15b414
+++ b/man/gssproxy.8.xml
15b414
@@ -151,6 +151,14 @@
15b414
                 </listitem>
15b414
             </varlistentry>
15b414
 
15b414
+            <varlistentry>
15b414
+                <term>
15b414
+                    <option>--syslog-status</option>
15b414
+                </term>
15b414
+                <listitem>
15b414
+                    <para>Enable additional logging to syslog.</para>
15b414
+                </listitem>
15b414
+            </varlistentry>
15b414
             <varlistentry>
15b414
                 <term>
15b414
                     <option>--version</option>
15b414
diff --git a/man/gssproxy.conf.5.xml b/man/gssproxy.conf.5.xml
15b414
index 21c9653..53cae3d 100644
15b414
--- a/man/gssproxy.conf.5.xml
15b414
+++ b/man/gssproxy.conf.5.xml
15b414
@@ -365,6 +365,16 @@
15b414
                     </listitem>
15b414
                 </varlistentry>
15b414
 
15b414
+                <varlistentry>
15b414
+                    <term>syslog_status (boolean)</term>
15b414
+                    <listitem>
15b414
+                        <para>Enable per-call debugging output to the syslog.
15b414
+                        This may be useful for investigating problems in
15b414
+                        applications using gssproxy.</para>
15b414
+                        <para>Default: syslog_status = false</para>
15b414
+                    </listitem>
15b414
+                </varlistentry>
15b414
+
15b414
                 <varlistentry>
15b414
                     <term>trusted (boolean)</term>
15b414
                         <listitem><para>Defines whether this service is considered trusted. Use with caution, this enables impersonation.</para>
15b414
diff --git a/src/gp_config.c b/src/gp_config.c
15b414
index 78474ed..88d5f29 100644
15b414
--- a/src/gp_config.c
15b414
+++ b/src/gp_config.c
15b414
@@ -611,6 +611,12 @@ int load_config(struct gp_config *cfg)
15b414
         goto done;
15b414
     }
15b414
 
15b414
+    ret = gp_config_get_string(ctx, "gssproxy", "syslog_status", &tmpstr);
15b414
+    if (ret == 0)
15b414
+        gp_syslog_status = gp_boolean_is_true(tmpstr);
15b414
+    else if (ret != ENOENT)
15b414
+        goto done;
15b414
+
15b414
     ret = gp_config_get_string(ctx, "gssproxy", "run_as_user", &tmpstr);
15b414
     if (ret == 0) {
15b414
         cfg->proxy_user = strdup(tmpstr);
15b414
diff --git a/src/gp_log.c b/src/gp_log.c
15b414
index b6eb161..e67e8d3 100644
15b414
--- a/src/gp_log.c
15b414
+++ b/src/gp_log.c
15b414
@@ -5,6 +5,9 @@
15b414
 #include <stdio.h>
15b414
 #include <stdarg.h>
15b414
 
15b414
+/* global logging switch */
15b414
+bool gp_syslog_status = false;
15b414
+
15b414
 void gp_logging_init(void)
15b414
 {
15b414
     openlog("gssproxy",
15b414
@@ -55,7 +58,9 @@ void gp_log_status(gss_OID mech, uint32_t maj, uint32_t min)
15b414
 {
15b414
     char buf[MAX_LOG_LINE];
15b414
 
15b414
-    gp_fmt_status(mech, maj, min, buf, MAX_LOG_LINE);
15b414
+    if (!gp_syslog_status)
15b414
+        return;
15b414
 
15b414
-    GPERROR("%s\n", buf);
15b414
+    gp_fmt_status(mech, maj, min, buf, MAX_LOG_LINE);
15b414
+    syslog(LOG_DEBUG, "%s\n", buf);
15b414
 }
15b414
diff --git a/src/gp_log.h b/src/gp_log.h
15b414
index fc8cbdb..31ad648 100644
15b414
--- a/src/gp_log.h
15b414
+++ b/src/gp_log.h
15b414
@@ -3,9 +3,12 @@
15b414
 #ifndef _GP_LOG_H_
15b414
 #define _GP_LOG_H_
15b414
 
15b414
+#include <stdbool.h>
15b414
 #include <syslog.h>
15b414
 #include <gssapi/gssapi.h>
15b414
 
15b414
+extern bool gp_syslog_status;
15b414
+
15b414
 #define MAX_LOG_LINE 1024
15b414
 #define GPERROR(...) syslog(LOG_ERR, __VA_ARGS__);
15b414
 #define GPAUDIT(...) syslog(LOG_INFO, __VA_ARGS__);
15b414
diff --git a/src/gssproxy.c b/src/gssproxy.c
15b414
index db6e89b..6b72a9b 100644
15b414
--- a/src/gssproxy.c
15b414
+++ b/src/gssproxy.c
15b414
@@ -157,6 +157,7 @@ int main(int argc, const char *argv[])
15b414
     int opt_version = 0;
15b414
     int opt_debug = 0;
15b414
     int opt_debug_level = 0;
15b414
+    int opt_syslog_status = 0;
15b414
     verto_ctx *vctx;
15b414
     verto_ev *ev;
15b414
     int wait_fd;
15b414
@@ -182,6 +183,8 @@ int main(int argc, const char *argv[])
15b414
          _("Enable debugging"), NULL}, \
15b414
         {"debug-level", '\0', POPT_ARG_INT, &opt_debug_level, 0, \
15b414
          _("Set debugging level"), NULL}, \
15b414
+        {"syslog-status", '\0', POPT_ARG_NONE, &opt_syslog_status, 0, \
15b414
+         _("Enable GSSAPI status logging to syslog"), NULL}, \
15b414
         {"version", '\0', POPT_ARG_NONE, &opt_version, 0, \
15b414
          _("Print version number and exit"), NULL }, \
15b414
         POPT_TABLEEND
15b414
@@ -211,6 +214,9 @@ int main(int argc, const char *argv[])
15b414
         gp_debug_toggle(opt_debug_level);
15b414
     }
15b414
 
15b414
+    if (opt_syslog_status)
15b414
+        gp_syslog_status = true;
15b414
+
15b414
     if (opt_daemon && opt_interactive) {
15b414
         fprintf(stderr, "Option -i|--interactive is not allowed together with -D|--daemon\n");
15b414
         poptPrintUsage(pc, stderr, 0);