[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#382037: Missing programname and PID in syslog-log by PAM



On Tue, Mar  4, 2008 at 18:51:33 -0800, Alan Coopersmith wrote:

> I'd have no objections to using openlog() on other OS'es too, though I'd
> prefer an autoconf test for the openlog() function over just adding __linux__
> (or just making it non-conditional for all OS'es if everyone has openlog()).
> 
Hi,

the attached patch adds a configure check for openlog, and changes the
greeter code to use #ifdef HAVE_OPENLOG instead of __OpenBSD__.  I don't
know if additional checks for <syslog.h> or LOG_AUTH are needed, though,
but that should be easy to fix if necessary.

Cheers,
Julien
>From a42b98b40ea79c1a4f5f963ed9101384a427e938 Mon Sep 17 00:00:00 2001
From: Julien Cristau <jcristau@debian.org>
Date: Mon, 10 Mar 2008 17:51:15 +0100
Subject: [PATCH] Add support for syslog on more than openbsd.

Also use LOG_AUTHPRIV by default, if that exists.
---
 configure.ac    |    2 +-
 greeter/greet.c |   13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1110525..756e6f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,7 +76,7 @@ if test "x$HAS_SETUSERCONTEXT" = "xyes" ; then
 		[Define to 1 if you have the 'setusercontext' function.])
 fi
 
-AC_CHECK_FUNCS([daemon sigaction])
+AC_CHECK_FUNCS([daemon sigaction openlog])
 AC_CHECK_HEADERS([grp.h])
 AC_TYPE_SIGNAL
 
diff --git a/greeter/greet.c b/greeter/greet.c
index 0aabec7..103305f 100644
--- a/greeter/greet.c
+++ b/greeter/greet.c
@@ -83,8 +83,11 @@ from The Open Group.
 #include "greet.h"
 #include "Login.h"
 
-#ifdef __OpenBSD__
+#ifdef HAVE_OPENLOG
 #include <syslog.h>
+#ifndef LOG_AUTHPRIV
+#define LOG_AUTHPRIV LOG_AUTH
+#endif
 #endif
 
 #if defined(SECURE_RPC) && defined(sun)
@@ -408,9 +411,7 @@ Greet (struct display *d, struct greet_info *greet)
 static void
 FailedLogin (struct display *d, struct greet_info *greet)
 {
-#ifdef __OpenBSD__
-    syslog(LOG_NOTICE, "LOGIN FAILURE ON %s",
-	   d->name);
+#ifdef HAVE_OPENLOG
     syslog(LOG_AUTHPRIV|LOG_NOTICE,
 	   "LOGIN FAILURE ON %s, %s",
 	   d->name, greet->name);
@@ -485,8 +486,8 @@ greet_user_rtn GreetUser(
 	LogError ("Cannot reopen display %s for greet window\n", d->name);
 	exit (RESERVER_DISPLAY);
     }
-#ifdef __OpenBSD__
-    openlog("xdm", LOG_ODELAY, LOG_AUTH);
+#ifdef HAVE_OPENLOG
+    openlog("xdm", LOG_ODELAY, LOG_AUTHPRIV);
 #endif
 
     for (;;) {
-- 
1.5.4.3


Reply to: