bash-3.2-audit.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. diff -up bash-4.2/config.h.in.audit bash-4.2/config.h.in
  2. --- bash-4.2/config.h.in.audit 2013-01-31 16:26:16.857698992 +0100
  3. +++ bash-4.2/config.h.in 2013-01-31 16:26:16.876699255 +0100
  4. @@ -1131,6 +1131,14 @@
  5. /* End additions for lib/intl */
  6. +
  7. +/* Additions for lib/readline */
  8. +
  9. +/* Define if you have <linux/audit.h> and it defines AUDIT_USER_TTY */
  10. +#undef HAVE_DECL_AUDIT_USER_TTY
  11. +
  12. +/* End additions for lib/readline */
  13. +
  14. #include "config-bot.h"
  15. #endif /* _CONFIG_H_ */
  16. diff -up bash-4.2/configure.in.audit bash-4.2/configure.in
  17. --- bash-4.2/configure.in.audit 2013-01-31 16:26:16.858699005 +0100
  18. +++ bash-4.2/configure.ac 2013-01-31 16:26:16.877699269 +0100
  19. @@ -888,6 +888,8 @@ BASH_FUNC_DUP2_CLOEXEC_CHECK
  20. BASH_SYS_PGRP_SYNC
  21. BASH_SYS_SIGNAL_VINTAGE
  22. +AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include <linux/audit.h>]])
  23. +
  24. dnl checking for the presence of certain library symbols
  25. BASH_SYS_ERRLIST
  26. BASH_SYS_SIGLIST
  27. diff -up bash-4.2/lib/readline/readline.c.audit bash-4.2/lib/readline/readline.c
  28. --- bash-4.2/lib/readline/readline.c.audit 2013-01-31 16:26:16.871699185 +0100
  29. +++ bash-4.2/lib/readline/readline.c 2013-01-31 17:24:23.902744860 +0100
  30. @@ -55,6 +55,12 @@
  31. extern int errno;
  32. #endif /* !errno */
  33. +#if defined (HAVE_DECL_AUDIT_USER_TTY)
  34. +# include <sys/socket.h>
  35. +# include <linux/audit.h>
  36. +# include <linux/netlink.h>
  37. +#endif
  38. +
  39. /* System-specific feature definitions and include files. */
  40. #include "rldefs.h"
  41. #include "rlmbutil.h"
  42. @@ -301,7 +307,48 @@ rl_set_prompt (prompt)
  43. rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
  44. return 0;
  45. }
  46. -
  47. +
  48. +#if defined (HAVE_DECL_AUDIT_USER_TTY)
  49. +/* Report STRING to the audit system. */
  50. +static void
  51. +audit_tty (char *string)
  52. +{
  53. + struct sockaddr_nl addr;
  54. + struct msghdr msg;
  55. + struct nlmsghdr nlm;
  56. + struct iovec iov[2];
  57. + size_t size;
  58. + int fd;
  59. +
  60. + size = strlen (string) + 1;
  61. + fd = socket (AF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
  62. + if (fd < 0)
  63. + return;
  64. + nlm.nlmsg_len = NLMSG_LENGTH (size);
  65. + nlm.nlmsg_type = AUDIT_USER_TTY;
  66. + nlm.nlmsg_flags = NLM_F_REQUEST;
  67. + nlm.nlmsg_seq = 0;
  68. + nlm.nlmsg_pid = 0;
  69. + iov[0].iov_base = &nlm;
  70. + iov[0].iov_len = sizeof (nlm);
  71. + iov[1].iov_base = string;
  72. + iov[1].iov_len = size;
  73. + addr.nl_family = AF_NETLINK;
  74. + addr.nl_pad = 0;
  75. + addr.nl_pid = 0;
  76. + addr.nl_groups = 0;
  77. + msg.msg_name = &addr;
  78. + msg.msg_namelen = sizeof (addr);
  79. + msg.msg_iov = iov;
  80. + msg.msg_iovlen = 2;
  81. + msg.msg_control = NULL;
  82. + msg.msg_controllen = 0;
  83. + msg.msg_flags = 0;
  84. + (void)sendmsg (fd, &msg, 0);
  85. + close (fd);
  86. +}
  87. +#endif
  88. +
  89. /* Read a line of input. Prompt with PROMPT. An empty PROMPT means
  90. none. A return value of NULL means that EOF was encountered. */
  91. char *