This patch is a modification of the origional bash bofh patch written by "ef@ccitt5.net" for bash-2.05a. It can be downloaded from: http://devsec.org/patch/bash/bash-bofh-2.05b.tk-1.patch -Thor Kooda 2005-09-21 diff -Naru bash-2.05b.orig/config.h.in bash-2.05b/config.h.in --- bash-2.05b.orig/config.h.in 2002-06-25 08:48:52.000000000 -0500 +++ bash-2.05b/config.h.in 2005-09-20 23:49:39.000000000 -0500 @@ -875,4 +875,10 @@ #include "config-bot.h" +/* Bash-bofh specific define templates */ +#undef BOFH +#undef SCRIPT_BOFH +#undef BOFH_LOGFACILITY +#undef BOFH_LOGLEVEL + #endif /* _CONFIG_H_ */ diff -Naru bash-2.05b.orig/configure bash-2.05b/configure --- bash-2.05b.orig/configure 2002-07-16 08:31:47.000000000 -0500 +++ bash-2.05b/configure 2005-09-20 23:49:39.000000000 -0500 @@ -712,6 +712,8 @@ make the echo builtin expand escape sequences by default --enable-mem-scramble scramble memory on calls to malloc and free + --enable-bofh enable bash-BOFH logging(default) + --disable-script-bofh disables shellscript logging(default) --enable-profiling allow profiling with gprof --enable-static-link link bash statically, for use as a root shell --disable-largefile omit support for large files @@ -1266,6 +1268,10 @@ opt_net_redirs=yes opt_progcomp=yes opt_separate_help=no +opt_bofh=yes +opt_script_bofh=no +opt_bofh_logfacility=LOG_USER +opt_bofh_loglevel=LOG_INFO opt_static_link=no opt_profiling=no @@ -1407,6 +1413,27 @@ opt_xpg_echo=$enableval fi; +# Check whether --enable-bofh or --disable-bofh was given. +if test "${enable_bofh+set}" = set; then + enableval="$enable_bofh" + opt_bofh=$enableval +fi; +# Check whether --enable-script_bofh or --disable-script_bofh was given. +if test "${enable_script_bofh+set}" = set; then + enableval="$enable_script_bofh" + opt_script_bofh=$enableval +fi; +# Check whether --with-bofh_logfacility or --without-bofh_logfacility was given +if test "${with_bofh_logfacility+set}" = set; then + withval="$with_bofh_logfacility" + opt_bofh_logfacility=$withval +fi; +# Check whether --with-bofh_loglevel or --without-bofh_loglevel was given. +if test "${with_bofh_loglevel+set}" = set; then + withval="$with_bofh_loglevel" + opt_bofh_loglevel=$withval +fi; + # Check whether --enable-mem-scramble or --disable-mem-scramble was given. if test "${enable_mem_scramble+set}" = set; then enableval="$enable_mem_scramble" @@ -1539,6 +1566,23 @@ fi +if test $opt_bofh = yes; then +cat >>confdefs.h <>confdefs.h <>confdefs.h <>confdefs.h < #endif +#ifdef BOFH +#include +#include +#endif + #if !defined (HAVE_GETPW_DECLS) extern struct passwd *getpwuid (); #endif /* !HAVE_GETPW_DECLS */ @@ -316,6 +321,11 @@ #endif volatile int locally_skip_execution; volatile int arg_index, top_level_arg_index; + +#ifdef BOFH + struct passwd *pwd_ent; +#endif + #ifdef __OPENNT char **env; @@ -523,8 +533,25 @@ running_under_emacs = term ? ((strmatch ("*term*", term, 0) == 0) ? 2 : 1) : 0; no_line_editing |= term && term[0] == 't' && term[1] == '\0'; +#ifdef BOFH +#ifndef SCRIPT_BOFH + openlog("bash",LOG_PID,BOFH_LOGFACILITY); + pwd_ent=getpwuid(getuid()); + syslog(BOFH_LOGLEVEL,"interactive shell started by username: %s UID: %d EUID: %d GID: %d EGID: %d", + pwd_ent->pw_name,pwd_ent->pw_uid,geteuid(),getgid(),getegid()); +#endif +#endif } +#ifdef BOFH +#ifdef SCRIPT_BOFH + openlog("bash",LOG_PID|LOG_NDELAY,BOFH_LOGFACILITY); + pwd_ent=getpwuid(getuid()); + syslog(BOFH_LOGLEVEL,"shell started by username: %s UID: %d EUID: %d GID: %d EGID: %d", + pwd_ent->pw_name,pwd_ent->pw_uid,geteuid(),getgid(),getegid()); +#endif +#endif + top_level_arg_index = arg_index; old_errexit_flag = exit_immediately_on_error; diff -Naru bash-2.05b.orig/y.tab.c bash-2.05b/y.tab.c --- bash-2.05b.orig/y.tab.c 2002-05-21 10:57:35.000000000 -0500 +++ bash-2.05b/y.tab.c 2005-09-20 23:50:08.000000000 -0500 @@ -80,6 +80,12 @@ #include "shmbutil.h" +#ifdef BOFH +#include +#include +#include +#endif + #if defined (READLINE) # include "bashline.h" # include @@ -3268,6 +3274,9 @@ int c; unsigned char uc; static int mustpop = 0; +#ifdef BOFH + struct passwd *pwd_ent; +#endif QUIT; @@ -3363,6 +3372,20 @@ set_line_mbstate (); +#ifdef BOFH +#ifdef SCRIPT_BOFH + pwd_ent=getpwuid(getuid()); + syslog(BOFH_LOGLEVEL,"[%s] %s", pwd_ent->pw_name,shell_input_line); +#else +#ifdef HISTORY + if (remember_on_history && shell_input_line && shell_input_line[0]){ + pwd_ent=getpwuid(getuid()); + syslog(BOFH_LOGLEVEL,"[%s] %s", pwd_ent->pw_name,shell_input_line); + } +#endif +#endif +#endif + #if defined (HISTORY) if (remember_on_history && shell_input_line && shell_input_line[0]) {