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