<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.32.2">
</HEAD>
<BODY>
On Wed, 2011-08-10 at 20:37 +0200, Mat&#283;j Cepl wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
From: Steve Grubb &lt;<A HREF="mailto:sgrubb@redhat.com">sgrubb@redhat.com</A>&gt;

<A HREF="https://bugzilla.redhat.com/469357">https://bugzilla.redhat.com/469357</A>

Thanks for help with this patch to
&quot;Gaetan Nadon&quot; &lt;<A HREF="mailto:memsize@videotron.ca">memsize@videotron.ca</A>&gt;

Signed-off-by: Mat&#283;j Cepl &lt;<A HREF="mailto:mcepl@redhat.com">mcepl@redhat.com</A>&gt;
---
 configure.ac    |   16 +++++++++++++++-
 greeter/greet.c |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0c79999..ef2302c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,20 @@ if test &quot;x$USE_SELINUX&quot; != &quot;xno&quot; ; then
     )
 fi
 
+# Check for Linux Audit support
+AC_ARG_WITH(libaudit, AS_HELP_STRING([--with-libaudit],
+        [Add support for Linux Audit (default is autodetected)]),
+        [USE_LINUX_AUDIT=$withval], [USE_LINUX_AUDIT=auto])
+if test &quot;x$USE_LINUX_AUDIT&quot; != &quot;xno&quot; ; then
+    AC_CHECK_LIB(audit, audit_log_user_message,
+        [AC_DEFINE(USE_LINUX_AUDIT,1,[Use Linux Audit support])]
+        XDMGREET_LIBS=&quot;$XDMGREET_LIBS -laudit&quot;,
+        [AS_IF([test &quot;x$USE_LINUX_AUDIT&quot; = &quot;xyes&quot;],
+            [AC_MSG_ERROR([Linux Audit support requested, but audit_log_user_message not found.])]
+        )]
+    )
+fi
+
 # FIXME: Find better test for which OS'es use su -m  - for now, just try to
 # mirror the Imakefile setting of:
 # if  defined(OpenBSDArchitecture) || defined(NetBSDArchitecture) || defined(FreeBSDArchitecture) || defined(DarwinArchitecture)
@@ -171,7 +185,7 @@ AC_SUBST(SU)
 
 # Define a configure option to locate a special file (/dev/random or /dev/urandom)
 # that serves as a random or a pseudorandom number generator
-AC_ARG_WITH(random-device, AS_HELP_STRING([--with-random-device\[=&lt;pathname&gt;\]],
+AC_ARG_WITH(random-device, AS_HELP_STRING([--with-random-device=&lt;pathname&gt;],
</PRE>
</BLOCKQUOTE>
This line of code has nothing to do with USER_LOGIN event. Should be a separate patch.
<BLOCKQUOTE TYPE=CITE>
<PRE>
         [Use &lt;pathname&gt; as a source of randomness (default is auto-detected)]),
         [USE_DEVICE=&quot;$withval&quot;], [USE_DEVICE=&quot;auto&quot;])
 if test x$USE_DEVICE != xno ; then
diff --git a/greeter/greet.c b/greeter/greet.c
index 87d2a83..2d26c69 100644
--- a/greeter/greet.c
+++ b/greeter/greet.c
@@ -86,6 +86,13 @@ from The Open Group.
 # endif
 #endif
 
+#ifdef HAVE_LIBAUDIT
+#include &lt;libaudit.h&gt;
+#include &lt;pwd.h&gt;
+#else
+#define log_to_audit_system(l,h,s)   do { ; } while (0)
+#endif
+
 #include &lt;string.h&gt;
 
 #if defined(SECURE_RPC) &amp;&amp; defined(sun)
@@ -415,6 +422,29 @@ FailedLogin (struct display *d, const char *username)
     DrawFail (login);
 }
 
+#ifdef USE_PAM
+#ifdef HAVE_LIBAUDIT
+static void
+log_to_audit_system(const pam_handle_t *pamhp, int success)
+{
+        struct passwd *pw = NULL;
+        char *hostname = NULL, *tty = NULL, *login=NULL;
+        int audit_fd;
+
+        audit_fd = audit_open();
+        pam_get_item(pamhp, PAM_RHOST, &amp;hostname);
+        pam_get_item(pamhp, PAM_TTY, &amp;tty);
+        pam_get_item(pamhp, PAM_USER, &amp;login);
+        if (login)
+                pw = getpwnam(login);
+                audit_log_acct_message(audit_fd, AUDIT_USER_LOGIN,
+                        NULL, &quot;login&quot;, login ? login : &quot;(unknown)&quot;,
+                        pw ? pw-&gt;pw_uid : -1, hostname, NULL, tty, success);
+        close(audit_fd);
+}
+#endif
+#endif
+
 _X_EXPORT
 greet_user_rtn GreetUser(
     struct display          *d,
@@ -600,6 +630,7 @@ greet_user_rtn GreetUser(
         if ((pam_error == PAM_SUCCESS) &amp;&amp; (Verify (d, greet, verify))) {
             SetPrompt (login, 1, &quot;Login Successful&quot;, LOGIN_TEXT_INFO, False);
             SetValue (login, 1, NULL);
+            log_to_audit_system(*pamhp, 1);
             break;
         } else {
             /* Try to fill in username for failed login error log */
@@ -611,6 +642,7 @@ greet_user_rtn GreetUser(
                                          (void *) &amp;username));
             }
             FailedLogin (d, username);
+            log_to_audit_system(*pamhp, 0);
             RUN_AND_CHECK_PAM_ERROR(pam_end,
                                     (*pamhp, pam_error));
         }
-- 
1.7.6

_______________________________________________
<A HREF="mailto:xorg-devel@lists.x.org">xorg-devel@lists.x.org</A>: X.Org development
Archives: <A HREF="http://lists.x.org/archives/xorg-devel">http://lists.x.org/archives/xorg-devel</A>
Info: <A HREF="http://lists.x.org/mailman/listinfo/xorg-devel">http://lists.x.org/mailman/listinfo/xorg-devel</A>
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>