diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-11-21 20:51:19 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-11-21 20:51:19 -0500 |
commit | 0001803f0b9523c94fa2ede48eaecb047fef4524 (patch) | |
tree | f334332811e033ff966d94f6268f0629a94304b3 /bashhist.c | |
parent | 89a92869e56aba4e4cab2d639c00a86f0545c862 (diff) | |
download | android_external_bash-0001803f0b9523c94fa2ede48eaecb047fef4524.tar.gz android_external_bash-0001803f0b9523c94fa2ede48eaecb047fef4524.tar.bz2 android_external_bash-0001803f0b9523c94fa2ede48eaecb047fef4524.zip |
Bash-4.1 distribution source
Diffstat (limited to 'bashhist.c')
-rw-r--r-- | bashhist.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -38,6 +38,10 @@ #include "bashintl.h" +#if defined (SYSLOG_HISTORY) +# include <syslog.h> +#endif + #include "shell.h" #include "flags.h" #include "input.h" @@ -691,6 +695,26 @@ check_add_history (line, force) return 0; } +#if defined (SYSLOG_HISTORY) +#define SYSLOG_MAXLEN 600 + +void +bash_syslog_history (line) + const char *line; +{ + char trunc[SYSLOG_MAXLEN]; + + if (strlen(line) < SYSLOG_MAXLEN) + syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s", getpid(), current_user.uid, line); + else + { + strncpy (trunc, line, SYSLOG_MAXLEN); + trunc[SYSLOG_MAXLEN - 1] = '\0'; + syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d UID=%d %s", getpid(), current_user.uid, trunc); + } +} +#endif + /* Add a line to the history list. The variable COMMAND_ORIENTED_HISTORY controls the style of history remembering; when non-zero, and LINE is not the first line of a @@ -746,6 +770,10 @@ bash_add_history (line) if (add_it) really_add_history (line); +#if defined (SYSLOG_HISTORY) + bash_syslog_history (line); +#endif + using_history (); } |