rcolebaugh / rpms / bash

Forked from rpms/bash 2 years ago
Clone

Blame SOURCES/bash-3.2-audit.patch

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