nalika / rpms / bash

Forked from rpms/bash 2 years ago
Clone

Blame SOURCES/bash-3.2-audit.patch

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