bb9a7e
diff -up bash-4.2/config.h.in.audit bash-4.2/config.h.in
bb9a7e
--- bash-4.2/config.h.in.audit	2013-01-31 16:26:16.857698992 +0100
bb9a7e
+++ bash-4.2/config.h.in	2013-01-31 16:26:16.876699255 +0100
bb9a7e
@@ -1131,6 +1131,14 @@
bb9a7e
 
bb9a7e
 /* End additions for lib/intl */
bb9a7e
 
bb9a7e
+
bb9a7e
+/* Additions for lib/readline */
bb9a7e
+
bb9a7e
+/* Define if you have <linux/audit.h> and it defines AUDIT_USER_TTY */
bb9a7e
+#undef HAVE_DECL_AUDIT_USER_TTY
bb9a7e
+
bb9a7e
+/* End additions for lib/readline */
bb9a7e
+
bb9a7e
 #include "config-bot.h"
bb9a7e
 
bb9a7e
 #endif /* _CONFIG_H_ */
bb9a7e
diff -up bash-4.2/configure.in.audit bash-4.2/configure.in
bb9a7e
--- bash-4.2/configure.in.audit	2013-01-31 16:26:16.858699005 +0100
bb9a7e
+++ bash-4.2/configure.ac	2013-01-31 16:26:16.877699269 +0100
bb9a7e
@@ -888,6 +888,8 @@ BASH_FUNC_DUP2_CLOEXEC_CHECK
bb9a7e
 BASH_SYS_PGRP_SYNC
bb9a7e
 BASH_SYS_SIGNAL_VINTAGE
bb9a7e
 
bb9a7e
+AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include <linux/audit.h>]])
bb9a7e
+
bb9a7e
 dnl checking for the presence of certain library symbols
bb9a7e
 BASH_SYS_ERRLIST
bb9a7e
 BASH_SYS_SIGLIST
bb9a7e
diff -up bash-4.2/lib/readline/readline.c.audit bash-4.2/lib/readline/readline.c
bb9a7e
--- bash-4.2/lib/readline/readline.c.audit	2013-01-31 16:26:16.871699185 +0100
bb9a7e
+++ bash-4.2/lib/readline/readline.c	2013-01-31 17:24:23.902744860 +0100
bb9a7e
@@ -55,6 +55,12 @@
bb9a7e
 extern int errno;
bb9a7e
 #endif /* !errno */
bb9a7e
 
bb9a7e
+#if defined (HAVE_DECL_AUDIT_USER_TTY)
bb9a7e
+#  include <sys/socket.h>
bb9a7e
+#  include <linux/audit.h>
bb9a7e
+#  include <linux/netlink.h>
bb9a7e
+#endif
bb9a7e
+
bb9a7e
 /* System-specific feature definitions and include files. */
bb9a7e
 #include "rldefs.h"
bb9a7e
 #include "rlmbutil.h"
bb9a7e
@@ -301,7 +307,48 @@ rl_set_prompt (prompt)
bb9a7e
   rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
bb9a7e
   return 0;
bb9a7e
 }
bb9a7e
-  
bb9a7e
+
bb9a7e
+#if defined (HAVE_DECL_AUDIT_USER_TTY)
bb9a7e
+/* Report STRING to the audit system. */
bb9a7e
+static void
bb9a7e
+audit_tty (char *string)
bb9a7e
+{
bb9a7e
+  struct sockaddr_nl addr;
bb9a7e
+  struct msghdr msg;
bb9a7e
+  struct nlmsghdr nlm;
bb9a7e
+  struct iovec iov[2];
bb9a7e
+  size_t size;
bb9a7e
+  int fd;
bb9a7e
+
bb9a7e
+  size = strlen (string) + 1;
bb9a7e
+  fd = socket (AF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
bb9a7e
+  if (fd < 0)
bb9a7e
+    return;
bb9a7e
+  nlm.nlmsg_len = NLMSG_LENGTH (size);
bb9a7e
+  nlm.nlmsg_type = AUDIT_USER_TTY;
bb9a7e
+  nlm.nlmsg_flags = NLM_F_REQUEST;
bb9a7e
+  nlm.nlmsg_seq = 0;
bb9a7e
+  nlm.nlmsg_pid = 0;
bb9a7e
+  iov[0].iov_base = &nlm;
bb9a7e
+  iov[0].iov_len = sizeof (nlm);
bb9a7e
+  iov[1].iov_base = string;
bb9a7e
+  iov[1].iov_len = size;
bb9a7e
+  addr.nl_family = AF_NETLINK;
bb9a7e
+  addr.nl_pad = 0;
bb9a7e
+  addr.nl_pid = 0;
bb9a7e
+  addr.nl_groups = 0;
bb9a7e
+  msg.msg_name = &addr;
bb9a7e
+  msg.msg_namelen = sizeof (addr);
bb9a7e
+  msg.msg_iov = iov;
bb9a7e
+  msg.msg_iovlen = 2;
bb9a7e
+  msg.msg_control = NULL;
bb9a7e
+  msg.msg_controllen = 0;
bb9a7e
+  msg.msg_flags = 0;
bb9a7e
+  (void)sendmsg (fd, &msg, 0);
bb9a7e
+  close (fd);
bb9a7e
+}
bb9a7e
+#endif
bb9a7e
+
bb9a7e
 /* Read a line of input.  Prompt with PROMPT.  An empty PROMPT means
bb9a7e
    none.  A return value of NULL means that EOF was encountered. */
bb9a7e
 char *