File audit-rl-patch of Package bash

--- readline-6.2/config.h.in
+++ readline-6.2/config.h.in	2013-01-09 09:31:06.833952652 +0000
@@ -251,6 +251,9 @@
 
 #undef CTYPE_NON_ASCII
 
+/* Define if you have <linux/audit.h> and it defines AUDIT_USER_TTY */
+#undef HAVE_DECL_AUDIT_USER_TTY
+
 /* modify settings or make new ones based on what autoconf tells us. */
 
 /* Ultrix botches type-ahead when switching from canonical to
--- readline-6.2/configure.in
+++ readline-6.2/configure.in	2013-01-09 09:33:09.125452625 +0000
@@ -159,6 +159,8 @@ AC_CHECK_HEADERS(sys/ptem.h,,,
 
 AC_SYS_LARGEFILE
 
+AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include <linux/audit.h>]])
+
 BASH_SYS_SIGNAL_VINTAGE
 BASH_SYS_REINSTALL_SIGHANDLERS
 
--- readline-6.2/readline.c
+++ readline-6.2/readline.c	2009-01-21 16:40:12.000000000 +0000
@@ -55,6 +55,12 @@
 extern int errno;
 #endif /* !errno */
 
+#if defined (HAVE_DECL_AUDIT_USER_TTY)
+#  include <sys/socket.h>
+#  include <linux/audit.h>
+#  include <linux/netlink.h>
+#endif
+
 /* System-specific feature definitions and include files. */
 #include "rldefs.h"
 #include "rlmbutil.h"
@@ -297,7 +303,47 @@ rl_set_prompt (prompt)
   rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
   return 0;
 }
-  
+
+#if defined (HAVE_DECL_AUDIT_USER_TTY)
+/* Report STRING to the audit system. */
+static void
+audit_tty (char *string)
+{
+  struct sockaddr_nl addr;
+  struct msghdr msg;
+  struct nlmsghdr nlm;
+  struct iovec iov[2];
+  size_t size;
+  int fd;
+
+  size = strlen (string) + 1;
+  fd = socket (AF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
+  if (fd < 0)
+    return;
+  nlm.nlmsg_len = NLMSG_LENGTH (size);
+  nlm.nlmsg_type = AUDIT_USER_TTY;
+  nlm.nlmsg_flags = NLM_F_REQUEST;
+  nlm.nlmsg_seq = 0;
+  nlm.nlmsg_pid = 0;
+  iov[0].iov_base = &nlm;
+  iov[0].iov_len = sizeof (nlm);
+  iov[1].iov_base = string;
+  iov[1].iov_len = size;
+  addr.nl_family = AF_NETLINK;
+  addr.nl_pid = 0;
+  addr.nl_groups = 0;
+  msg.msg_name = &addr;
+  msg.msg_namelen = sizeof (addr);
+  msg.msg_iov = iov;
+  msg.msg_iovlen = 2;
+  msg.msg_control = NULL;
+  msg.msg_controllen = 0;
+  msg.msg_flags = 0;
+  (void)sendmsg (fd, &msg, 0);
+  close (fd);
+}
+#endif
+
 /* Read a line of input.  Prompt with PROMPT.  An empty PROMPT means
    none.  A return value of NULL means that EOF was encountered. */
 char *
@@ -348,6 +394,11 @@ readline (prompt)
     RL_SETSTATE (RL_STATE_CALLBACK);
 #endif
 
+#if defined (HAVE_DECL_AUDIT_USER_TTY)
+  if (value != NULL)
+    audit_tty (value);
+#endif
+
   return (value);
 }
 
openSUSE Build Service is sponsored by