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 >
Text File  |  2013-10-06  |  2KB  |  59 lines

  1. +++ bash-4.1/debian/patches/syslog-username.dpatch    2013-09-24 15:00:11.000000000 +0300
  2. @@ -0,0 +1,56 @@
  3. +#! /bin/sh -e
  4. +
  5. +if [ $# -eq 3 -a "$2" = '-d' ]; then
  6. +    pdir="-d $3"
  7. +elif [ $# -ne 1 ]; then
  8. +    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
  9. +    exit 1
  10. +fi
  11. +case "$1" in
  12. +    -patch) patch $pdir -f --no-backup-if-mismatch -p1 < $0;;
  13. +    -unpatch) patch $pdir -f --no-backup-if-mismatch -R -p1 < $0;;
  14. +    *)
  15. +    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
  16. +    exit 1
  17. +esac
  18. +exit 0
  19. +
  20. +# DP: Write username to syslog instead of UID
  21. +
  22. +--- bash/bashhist.c    2009-08-14 22:33:02.000000000 +0300
  23. ++++ bash/bashhist.c    2013-10-02 08:02:06.000000000 +0300
  24. +@@ -31,6 +31,7 @@
  25. + #include "bashtypes.h"
  26. + #include <stdio.h>
  27. ++#include <stdlib.h>
  28. + #include <errno.h>
  29. + #include "bashansi.h"
  30. + #include "posixstat.h"
  31. +@@ -704,13 +705,24 @@
  32. + {
  33. +   char trunc[SYSLOG_MAXLEN];
  34. ++  char user_str[81];  /* "USER=<max 32 chars> SUDO_USER=<max 32 chars>\0" */
  35. ++  const char *sudo_user = getenv("SUDO_USER");
  36. ++  if (sudo_user)
  37. ++    {
  38. ++      snprintf(user_str, sizeof(user_str), "USER=%s SUDO_USER=%s", current_user.user_name, sudo_user);
  39. ++    }
  40. ++  else
  41. ++    {
  42. ++      snprintf(user_str, sizeof(user_str), "USER=%s", current_user.user_name);
  43. ++    }
  44. ++
  45. +   if (strlen(line) < SYSLOG_MAXLEN)
  46. +-    syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s", getpid(), current_user.uid, line);
  47. ++    syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s %s", getpid(), current_user.uid, user_str, line);
  48. +   else
  49. +     {
  50. +       strncpy (trunc, line, SYSLOG_MAXLEN);
  51. +       trunc[SYSLOG_MAXLEN - 1] = '\0';
  52. +-      syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d UID=%d %s", getpid(), current_user.uid, trunc);
  53. ++      syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d UID=%d %s %s", getpid(), current_user.uid, user_str, trunc);
  54. +     }
  55. + }
  56. + #endif
  57.