svashisht / rpms / bash

Forked from rpms/bash 4 years ago
Clone

Blame SOURCES/bash-5.0-syslog-history.patch

ff19ae
diff --git a/bashhist.c b/bashhist.c
ff19ae
--- a/bashhist.c
ff19ae
+++ b/bashhist.c
ff19ae
@@ -702,6 +702,12 @@ check_add_history (line, force)
ff19ae
 #if defined (SYSLOG_HISTORY)
ff19ae
 #define SYSLOG_MAXLEN 600
ff19ae
ff19ae
+#if defined (SYSLOG_SHOPT)
ff19ae
+int syslog_history = SYSLOG_SHOPT;
ff19ae
+#else
ff19ae
+int syslog_history = 1;
ff19ae
+#endif
ff19ae
+
ff19ae
 void
ff19ae
 bash_syslog_history (line)
ff19ae
      const char *line;
ff19ae
@@ -782,7 +788,8 @@ bash_add_history (line)
ff19ae
     really_add_history (line);
ff19ae
ff19ae
 #if defined (SYSLOG_HISTORY)
ff19ae
-  bash_syslog_history (line);
ff19ae
+  if (syslog_history)
ff19ae
+    bash_syslog_history (line);
ff19ae
 #endif
ff19ae
ff19ae
   using_history ();
ff19ae
diff --git a/builtins/shopt.def b/builtins/shopt.def
ff19ae
--- a/builtins/shopt.def
ff19ae
+++ b/builtins/shopt.def
ff19ae
@@ -115,6 +115,10 @@ extern char *shell_name;
ff19ae
 extern int debugging_mode;
ff19ae
 #endif
ff19ae
ff19ae
+#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
ff19ae
+extern int syslog_history;
ff19ae
+#endif
ff19ae
+
ff19ae
 static void shopt_error __P((char *));
ff19ae
ff19ae
 static int set_shellopts_after_change __P((char *, int));
ff19ae
@@ -208,6 +212,9 @@ static struct {
ff19ae
 #endif
ff19ae
   { "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL },
ff19ae
   { "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL },
ff19ae
+#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
ff19ae
+  { "syslog_history", &syslog_history, (shopt_set_func_t *)NULL },
ff19ae
+#endif
ff19ae
   { "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
ff19ae
   { (char *)0, (int *)0, (shopt_set_func_t *)NULL }
ff19ae
 };
ff19ae
diff --git a/config-top.h b/config-top.h
ff19ae
--- a/config-top.h
ff19ae
+++ b/config-top.h
ff19ae
@@ -109,5 +109,12 @@
ff19ae
 #  define SYSLOG_LEVEL LOG_INFO
ff19ae
 #endif
ff19ae
ff19ae
+/* Define if you want syslogging history to be controllable at runtime via a
ff19ae
+   shell option; if defined, the value is the default for the syslog_history
ff19ae
+   shopt option */
ff19ae
+#if defined (SYSLOG_HISTORY)
ff19ae
+#define SYSLOG_SHOPT 0
ff19ae
+#endif
ff19ae
+
ff19ae
 /* Define if you want to include code in shell.c to support wordexp(3) */
ff19ae
 /* #define WORDEXP_OPTION */
ff19ae
diff --git a/doc/bash.1 b/doc/bash.1
ff19ae
--- a/doc/bash.1
ff19ae
+++ b/doc/bash.1
ff19ae
@@ -9224,6 +9224,9 @@ If set, the
ff19ae
 to find the directory containing the file supplied as an argument.
ff19ae
 This option is enabled by default.
ff19ae
 .TP 8
ff19ae
+.B syslog_history
ff19ae
+If set, command history is logged to syslog.
ff19ae
+.TP 8
ff19ae
 .B xpg_echo
ff19ae
 If set, the \fBecho\fP builtin expands backslash-escape sequences
ff19ae
 by default.