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