nalika / rpms / bash

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