nalika / rpms / bash

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