summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2014-03-08 18:21:47 -0500
committerRyan Lortie <desrt@desrt.ca>2014-03-19 09:46:48 -0400
commitde240b9b2e819e4befe320e74bc8bf2f758f1685 (patch)
tree9011202d8fc957d83918ec4ccf459ceb6a3e370e
parentf94afeb0865cbaeaed17ef9bf949d90ad6255824 (diff)
downloadaccountsservice-de240b9b2e819e4befe320e74bc8bf2f758f1685.tar.gz
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. https://bugs.freedesktop.org/show_bug.cgi?id=75938
-rw-r--r--src/wtmp-helper.c18
1 files 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 <utmpx.h>
-#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 */