----- Original Message -----
> From: "Siteshwar Vashisht" <svashi...@redhat.com>
> To: bug-bash@gnu.org
> Sent: Wednesday, January 25, 2017 1:39:12 PM
> Subject: Make syslog history configurable
> 
> Hello,
> 
> Bash history is logged to syslog if SYSLOG_HISTORY macro is defined in
> config-top.h. There is no option to enable/disable it at runtime. I am
> adding a shell option 'syshist' that can be used to configure logging bash
> history to syslog at runtime.

I modified the patch to use shopt instead of set to enable/disable syslog 
history.
> 
> 
> --
> --
> Siteshwar Vashisht
> 

-- 
--
Siteshwar Vashisht
From 49d2435aefca79b08d19f67c139d2091634853f5 Mon Sep 17 00:00:00 2001
From: Siteshwar Vashisht <svashi...@redhat.com>
Date: Wed, 25 Jan 2017 15:58:59 +0100
Subject: [PATCH] Make syslog history configurable with shopt

---
 bashhist.c         |  5 +++--
 builtins/shopt.def | 11 +++++++++++
 config-top.h       |  2 +-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/bashhist.c b/bashhist.c
index 9979f99..7ab6486 100644
--- a/bashhist.c
+++ b/bashhist.c
@@ -749,7 +749,7 @@ check_add_history (line, force)
 #define SYSLOG_MAXLEN 600
 
 extern char *shell_name;
-
+int syslog_history = 0;
 #ifndef OPENLOG_OPTS
 #define OPENLOG_OPTS 0
 #endif
@@ -851,7 +851,8 @@ bash_add_history (line)
     really_add_history (line);
 
 #if defined (SYSLOG_HISTORY)
-  bash_syslog_history (line);
+  if (syslog_history)
+    bash_syslog_history (line);
 #endif
 
   using_history ();
diff --git a/builtins/shopt.def b/builtins/shopt.def
index 2febb7e..848bab3 100644
--- a/builtins/shopt.def
+++ b/builtins/shopt.def
@@ -118,6 +118,10 @@ extern char *shell_name;
 extern int debugging_mode;
 #endif
 
+#if defined (SYSLOG_HISTORY)
+extern int syslog_history;
+#endif
+
 static void shopt_error __P((char *));
 
 static int set_shellopts_after_change __P((char *, int));
@@ -223,6 +227,9 @@ static struct {
 #endif
   { "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL },
   { "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL },
+#if defined (SYSLOG_HISTORY)
+  { "syslog_history", &syslog_history, (shopt_set_func_t *)NULL },
+#endif
   { "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
   { (char *)0, (int *)0, (shopt_set_func_t *)NULL }
 };
@@ -345,6 +352,10 @@ reset_shopt_options ()
   command_oriented_history = 1;
 #endif
 
+#if defined (SYSLOG_HISTORY)
+  syslog_history = 0;
+#endif
+
 #if defined (READLINE)
   complete_fullquote = 1;
   force_fignore = 1;
diff --git a/config-top.h b/config-top.h
index cb0e002..8051fad 100644
--- a/config-top.h
+++ b/config-top.h
@@ -115,7 +115,7 @@
 
 /* Define if you want each line saved to the history list in bashhist.c:
    bash_add_history() to be sent to syslog(). */
-/* #define SYSLOG_HISTORY */
+#define SYSLOG_HISTORY
 #if defined (SYSLOG_HISTORY)
 #  define SYSLOG_FACILITY LOG_USER
 #  define SYSLOG_LEVEL LOG_INFO
-- 
2.9.3

Reply via email to