From ant@notatla.demon.co.uk Tue May 2 13:26:38 2000 Date: Sun, 23 Apr 2000 20:35:11 +0100 From: Antonomasia To: lance@spitzner.net Subject: bash history logging Lance, In the bash-2.03 package of RH6.2 this mod will add history logging. It is done in the lib/readline/history.c file, concerned with recording commands rather than reading keystrokes, but the effect is almost the same. One thing this doesn't record is when someone repeats the last command because that does not generate a new history record. Just 2 things need to be added: an include of the syslog.h file and a syslog(3) call with the new history entry. I've split the syslog(3) section into 2 to cater for long and short lines separately because some syslog()s are/have been buggy. 1 /* History.c -- standalone history library */ 2 3 /* Copyright (C) 1989, 1992 Free Software Foundation, Inc. 32 #include + 33 #include 217 /* Place STRING at the end of the history list. The data field 218 is set to NULL. */ 219 void 220 add_history (string) 221 char *string; 222 { 223 HIST_ENTRY *temp; 224 + 225 if (strlen(string)<60) { + 226 syslog(LOG_INFO, "BASH2 HISTORY: PID=%d %s", getpid(), string); + 227 } else { + 228 char trunc[60]; + 229 + 230 strncpy(trunc,string,sizeof(trunc)); + 231 trunc[sizeof(trunc)-1]='\0'; + 232 syslog(LOG_INFO, "BASH2 HISTORY: PID=%d %s(++TRUNC)", + 233 getpid(), trunc); + 234 } 235 236 if (history_stifled && (history_length == max_input_history)) 237 { 238 register int i; -- ############################################################## # Antonomasia ant@notatla.demon.co.uk # # See http://www.notatla.demon.co.uk/ # ##############################################################