From 65eec11fc22e0cc673c9dc246235a991e601a86a Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Sun, 13 Dec 2015 16:45:09 +0100 Subject: [PATCH] +NetBSD --- configure.ac | 25 +++++++++++++++++++++++-- src/wtmp-helper.c | 45 ++++++++++++++++++++++++++++++--------------- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/configure.ac b/configure.ac index db4559c..ac4d0af 100644 --- a/configure.ac +++ b/configure.ac @@ -289,6 +289,29 @@ if test "x$with_systemdsystemunitdir" != "xno"; then fi AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != "xno" ]) +dnl --------------------------------------------------------------------------- +dnl - check OS +dnl --------------------------------------------------------------------------- +AC_MSG_CHECKING([checking OS type]) +case "$host_os" in + *freebsd*) + AC_MSG_RESULT([FreeBSD]) + AC_DEFINE([HAVE_FREEBSD], 1, [Is this a FreeBSD system?]) + ;; + *linux*) + AC_MSG_RESULT([Linux]) + AC_DEFINE([HAVE_LINUX], 1, [Is this a Linux system?]) + ;; + *netbsd*) + AC_MSG_RESULT([NetBSD]) + AC_DEFINE([HAVE_NETBSD], 1, [Is this a NetBSD system?]) + ;; + *solaris*) + AC_MSG_RESULT([Solaris]) + AC_DEFINE([HAVE_SOLARIS], 1, [Is this a Solaris system?]) + ;; +esac + AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([ Makefile @@ -313,5 +336,3 @@ else fi AC_MSG_NOTICE([** Administrator group: $enable_admin_group]) echo - - diff --git a/src/wtmp-helper.c b/src/wtmp-helper.c index 0c29d82..59b49b8 100644 --- a/src/wtmp-helper.c +++ b/src/wtmp-helper.c @@ -56,21 +56,32 @@ user_previous_login_free (UserPreviousLogin *previous_login) static gboolean wtmp_helper_start (void) { -#if defined(UTXDB_LOG) - if (setutxdb (UTXDB_LOG, NULL) != 0) { - return FALSE; - } -#elif defined(WTMPX_FILENAME) - if (utmpxname (WTMPX_FILENAME) != 0) { - return FALSE; - } +#if HAVE_FREEBSD + if (setutxdb (UTXDB_LOG, NULL) != 0) { + return FALSE; + } +#elif HAVE_LINUX + if (utmpxname (WTMPX_FILENAME) != 0) { + return FALSE; + } + + setutxent (); +#elif HAVE_NETBSD + if (utmpxname (_PATH_WTMPX) != 0) { + return FALSE; + } - setutxent (); + setutxent (); +#elif HAVE_SOLARIS + if (utmpxname (WTMPX_FILE) != 0) { + return FALSE; + } + + setutxent (); #else #error You have utmpx.h, but no known way to use it for wtmp entries #endif - - return TRUE; + return TRUE; } struct passwd * @@ -212,12 +223,16 @@ 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__) +#if HAVE_FREEBSD return "/var/log/utx.log"; +#elif HAVE_LINUX + return WTMPX_FILENAME; +#elif HAVE_NETBSD + return _PATH_WTMPX; +#elif HAVE_SOLARIS + return WTMPX_FILE; #else -#error Do not know which filename to watch for wtmp changes +#error You have utmpx.h, but no known way to use it for wtmp entries #endif } -- 2.6.3