home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.f-secure.com
/
2014.06.ftp.f-secure.com.tar
/
ftp.f-secure.com
/
gpl
/
fsio
/
fsio-bash
/
create-syslog-username-dpatch-file.patch
< prev
next >
Wrap
Text File
|
2013-10-06
|
2KB
|
59 lines
+++ bash-4.1/debian/patches/syslog-username.dpatch 2013-09-24 15:00:11.000000000 +0300
@@ -0,0 +1,56 @@
+#! /bin/sh -e
+
+if [ $# -eq 3 -a "$2" = '-d' ]; then
+ pdir="-d $3"
+elif [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch $pdir -f --no-backup-if-mismatch -p1 < $0;;
+ -unpatch) patch $pdir -f --no-backup-if-mismatch -R -p1 < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+esac
+exit 0
+
+# DP: Write username to syslog instead of UID
+
+--- bash/bashhist.c 2009-08-14 22:33:02.000000000 +0300
++++ bash/bashhist.c 2013-10-02 08:02:06.000000000 +0300
+@@ -31,6 +31,7 @@
+
+ #include "bashtypes.h"
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <errno.h>
+ #include "bashansi.h"
+ #include "posixstat.h"
+@@ -704,13 +705,24 @@
+ {
+ char trunc[SYSLOG_MAXLEN];
+
++ char user_str[81]; /* "USER=<max 32 chars> SUDO_USER=<max 32 chars>\0" */
++ const char *sudo_user = getenv("SUDO_USER");
++ if (sudo_user)
++ {
++ snprintf(user_str, sizeof(user_str), "USER=%s SUDO_USER=%s", current_user.user_name, sudo_user);
++ }
++ else
++ {
++ snprintf(user_str, sizeof(user_str), "USER=%s", current_user.user_name);
++ }
++
+ if (strlen(line) < SYSLOG_MAXLEN)
+- syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s", getpid(), current_user.uid, line);
++ syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s %s", getpid(), current_user.uid, user_str, 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);
++ syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d UID=%d %s %s", getpid(), current_user.uid, user_str, trunc);
+ }
+ }
+ #endif