From affcec929408eb9a8dc26273a65930dff98a4861 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 14 Dec 2015 18:03:53 -0800 Subject: [PATCH] Bug 90882 - WTMPX_FILENAME is GNU specific Should handle Linux, Solaris, NetBSD, & FreeBSD --- configure.ac | 21 ++++++++++++++++++--- src/wtmp-helper.c | 14 ++++---------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index db4559c..5a852b8 100644 --- a/configure.ac +++ b/configure.ac @@ -185,9 +185,24 @@ fi AC_SUBST(WARN_CFLAGS) -AC_CHECK_HEADERS([shadow.h utmpx.h]) - -AC_CHECK_FUNCS([fgetpwent]) +AC_CHECK_HEADERS([paths.h shadow.h utmpx.h]) + +AC_CHECK_FUNCS([fgetpwent setutxdb]) + +wtmpx_found="no" +AC_CHECK_DECLS([WTMPX_FILENAME], [wtmpx_found="WTMPX_FILENAME"], + [], [#include ]) +if test "$wtmpx_found" = "no" ; then + AC_CHECK_DECLS([_PATH_WTMPX], [wtmpx_found="_PATH_WTMPX"], + [], [#include ]) + if test "$wtmpx_found" = "no" ; then + AC_CHECK_FILE([/var/log/utx.log], [wtmpx_found='"/var/log/utx.log"']) + if test "$wtmpx_found" = "no" ; then + AC_MSG_FAILURE([Do not know which filename to watch for wtmp changes]) + fi + fi +fi +AC_DEFINE_UNQUOTED([PATH_WTMP], [$wtmpx_found], [Path to wtmpx file]) dnl --------------------------------------------------------------------------- dnl - gtk-doc Documentation diff --git a/src/wtmp-helper.c b/src/wtmp-helper.c index 0c29d82..83ac43b 100644 --- a/src/wtmp-helper.c +++ b/src/wtmp-helper.c @@ -56,12 +56,12 @@ user_previous_login_free (UserPreviousLogin *previous_login) static gboolean wtmp_helper_start (void) { -#if defined(UTXDB_LOG) +#if defined(HAVE_SETUTXDB) if (setutxdb (UTXDB_LOG, NULL) != 0) { return FALSE; } -#elif defined(WTMPX_FILENAME) - if (utmpxname (WTMPX_FILENAME) != 0) { +#elif defined(PATH_WTMP) + if (utmpxname (PATH_WTMP) != 0) { return FALSE; } @@ -212,13 +212,7 @@ wtmp_helper_entry_generator (GHashTable *users, const gchar * wtmp_helper_get_path_for_monitor (void) { -#if defined(WTMPX_FILENAME) - return WTMPX_FILENAME; -#elif defined(__FreeBSD__) - return "/var/log/utx.log"; -#else -#error Do not know which filename to watch for wtmp changes -#endif + return PATH_WTMP; } #else /* HAVE_UTMPX_H */ -- 2.6.1