Blame SOURCES/readline-6.1-audit.patch

b13877
diff -up readline-6.1/config.h.in.audit readline-6.1/config.h.in
b13877
--- readline-6.1/config.h.in.audit	2009-03-10 15:57:45.000000000 +0100
b13877
+++ readline-6.1/config.h.in	2011-01-18 15:14:51.199219895 +0100
b13877
@@ -29,6 +29,9 @@
b13877
 
b13877
 #undef __CHAR_UNSIGNED__
b13877
 
b13877
+/* Define if you have <linux/audit.h> and it defines AUDIT_USER_TTY */
b13877
+#undef HAVE_DECL_AUDIT_USER_TTY
b13877
+
b13877
 /* Define if the `S_IS*' macros in <sys/stat.h> do not work properly.  */
b13877
 #undef STAT_MACROS_BROKEN
b13877
 
b13877
diff -up readline-6.1/configure.audit readline-6.1/configure
b13877
--- readline-6.1/configure.audit	2009-12-29 23:33:49.000000000 +0100
b13877
+++ readline-6.1/configure	2011-01-18 15:21:20.571330373 +0100
b13877
@@ -6602,7 +6602,9 @@ _ACEOF
b13877
 
b13877
 fi
b13877
 
b13877
-
b13877
+cat >>confdefs.h <<_ACEOF
b13877
+#define HAVE_DECL_AUDIT_USER_TTY 1
b13877
+_ACEOF
b13877
 
b13877
 { $as_echo "$as_me:$LINENO: checking if signal handlers must be reinstalled when invoked" >&5
b13877
 $as_echo_n "checking if signal handlers must be reinstalled when invoked... " >&6; }
b13877
diff -up readline-6.1/configure.in.audit readline-6.1/configure.in
b13877
--- readline-6.1/configure.in.audit	2009-10-12 16:12:15.000000000 +0200
b13877
+++ readline-6.1/configure.in	2011-01-18 15:14:51.199219895 +0100
b13877
@@ -159,6 +159,8 @@ AC_CHECK_HEADERS(sys/ptem.h,,,
b13877
 
b13877
 AC_SYS_LARGEFILE
b13877
 
b13877
+AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include <linux/audit.h>]])
b13877
+
b13877
 BASH_SYS_SIGNAL_VINTAGE
b13877
 BASH_SYS_REINSTALL_SIGHANDLERS
b13877
 
b13877
diff -up readline-6.1/readline.c.audit readline-6.1/readline.c
b13877
--- readline-6.1/readline.c.audit	2009-08-31 14:45:31.000000000 +0200
b13877
+++ readline-6.1/readline.c	2011-01-18 15:14:51.200219841 +0100
b13877
@@ -55,6 +55,12 @@
b13877
 extern int errno;
b13877
 #endif /* !errno */
b13877
 
b13877
+#if defined (HAVE_DECL_AUDIT_USER_TTY)
b13877
+#  include <sys/socket.h>
b13877
+#  include <linux/audit.h>
b13877
+#  include <linux/netlink.h>
b13877
+#endif
b13877
+
b13877
 /* System-specific feature definitions and include files. */
b13877
 #include "rldefs.h"
b13877
 #include "rlmbutil.h"
b13877
@@ -301,7 +307,47 @@ rl_set_prompt (prompt)
b13877
   rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
b13877
   return 0;
b13877
 }
b13877
-  
b13877
+
b13877
+#if defined (HAVE_DECL_AUDIT_USER_TTY)
b13877
+/* Report STRING to the audit system. */
b13877
+static void
b13877
+audit_tty (char *string)
b13877
+{
b13877
+  struct sockaddr_nl addr;
b13877
+  struct msghdr msg;
b13877
+  struct nlmsghdr nlm;
b13877
+  struct iovec iov[2];
b13877
+  size_t size;
b13877
+  int fd;
b13877
+
b13877
+  size = strlen (string) + 1;
b13877
+  fd = socket (AF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
b13877
+  if (fd < 0)
b13877
+    return;
b13877
+  nlm.nlmsg_len = NLMSG_LENGTH (size);
b13877
+  nlm.nlmsg_type = AUDIT_USER_TTY;
b13877
+  nlm.nlmsg_flags = NLM_F_REQUEST;
b13877
+  nlm.nlmsg_seq = 0;
b13877
+  nlm.nlmsg_pid = 0;
b13877
+  iov[0].iov_base = &nlm;
b13877
+  iov[0].iov_len = sizeof (nlm);
b13877
+  iov[1].iov_base = string;
b13877
+  iov[1].iov_len = size;
b13877
+  addr.nl_family = AF_NETLINK;
b13877
+  addr.nl_pid = 0;
b13877
+  addr.nl_groups = 0;
b13877
+  msg.msg_name = &addr;
b13877
+  msg.msg_namelen = sizeof (addr);
b13877
+  msg.msg_iov = iov;
b13877
+  msg.msg_iovlen = 2;
b13877
+  msg.msg_control = NULL;
b13877
+  msg.msg_controllen = 0;
b13877
+  msg.msg_flags = 0;
b13877
+  (void)sendmsg (fd, &msg, 0);
b13877
+  close (fd);
b13877
+}
b13877
+#endif
b13877
+
b13877
 /* Read a line of input.  Prompt with PROMPT.  An empty PROMPT means
b13877
    none.  A return value of NULL means that EOF was encountered. */
b13877
 char *
b13877
@@ -352,6 +398,11 @@ readline (prompt)
b13877
     RL_SETSTATE (RL_STATE_CALLBACK);
b13877
 #endif
b13877
 
b13877
+#if defined (HAVE_DECL_AUDIT_USER_TTY)
b13877
+  if (value != NULL)
b13877
+    audit_tty (value);
b13877
+#endif
b13877
+
b13877
   return (value);
b13877
 }
b13877