From 6fdc45aab4c52521c07aef6679021c3719308ad5 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Sat, 8 Mar 2014 18:21:47 -0500 Subject: [PATCH 3/4] wtmp: stop using private _PATH_WTMPX Instead of using this private macro, use WTMPX_FILENAME. Also, deal explicitly with the implications of this define being missing: throw an #error. This means that some systems that are currently broken (FreeBSD for example) will continue to be broken, but will throw an #error about it. Fixes coming in the following commits. --- src/wtmp-helper.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/wtmp-helper.c b/src/wtmp-helper.c index af460e6..c1c1ae2 100644 --- a/src/wtmp-helper.c +++ b/src/wtmp-helper.c @@ -29,8 +29,6 @@ #include -#define PATH_WTMP _PATH_WTMPX - typedef struct { guint64 frequency; gint64 time; @@ -58,16 +56,18 @@ user_previous_login_free (UserPreviousLogin *previous_login) static gboolean wtmp_helper_start (void) { -#ifdef UTXDB_LOG +#if defined(UTXDB_LOG) if (setutxdb (UTXDB_LOG, NULL) != 0) { return FALSE; } -#else - if (utmpxname (PATH_WTMP) != 0) { +#elif defined(WTMPX_FILENAME) + if (utmpxname (WTMPX_FILENAME) != 0) { return FALSE; } setutxent (); +#else +#error You have utmpx.h, but no known way to use it for wtmp entries #endif return TRUE; @@ -90,7 +90,7 @@ wtmp_helper_entry_generator (GHashTable *users, if (*state == NULL) { /* First iteration */ - if (!wtmp_helper_start ()) + if (!wtmp_helper_start ()) { return NULL; } @@ -212,7 +212,11 @@ wtmp_helper_entry_generator (GHashTable *users, const gchar * wtmp_helper_get_path_for_monitor (void) { - return PATH_WTMP; +#if defined(WTMPX_FILENAME) + return WTMPX_FILENAME; +#else +#error Do not know which filename to watch for wtmp changes +#endif } #else /* HAVE_UTMPX_H */ -- 1.8.5.3