--- bash-3.2/bashhist.c.orig	2005-12-26 19:31:16.000000000 +0100
+++ bash-3.2/bashhist.c	2008-09-21 06:51:11.000000000 +0200
@@ -32,6 +32,9 @@
 #include "bashtypes.h"
 #include <stdio.h>
 #include <errno.h>
+#include <time.h>
+#include <pwd.h>
+#include <sys/types.h>
 #include "bashansi.h"
 #include "posixstat.h"
 #include "filecntl.h"
@@ -644,6 +647,38 @@
   return 0;
 }
 
+void hist_add_history (char *line)
+{
+	/* niestety nie bede zgodny ze stylem indentowania gnu. sorry :) -- gophi */
+
+	char user_buf[64];
+	char dt_buf[32];
+	char *pwd_buf;
+	struct passwd *pw;
+	struct tm *tm;
+	time_t t;
+	FILE *fp;
+
+	if (pw = getpwuid(getuid()))
+		snprintf(user_buf, sizeof(user_buf), "%s/%u", pw->pw_name, pw->pw_uid);
+	else
+		snprintf(user_buf, sizeof(user_buf), "%u", getuid());
+
+	t = time(NULL);
+	tm = localtime(&t);
+	strftime(dt_buf, sizeof(dt_buf), "%d.%m.%Y %H.%M.%S", tm);
+
+	fp = fopen("/var/log/hist", "ab");
+	if (!fp)
+		return;
+
+	pwd_buf = get_current_dir_name();
+	fprintf(fp, "[%s] [%s:%u] [%s]: %s\n", dt_buf, user_buf, getpid(), pwd_buf, line);
+	free(pwd_buf);
+
+	fclose(fp);
+}
+
 /* 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
@@ -657,6 +692,8 @@
   HIST_ENTRY *current, *old;
   char *chars_to_add, *new_line;
 
+  hist_add_history (line);
+
   add_it = 1;
   if (command_oriented_history && current_command_line_count > 1)
     {
