From 76097f8c4f4632d8f37d6e7eb5940c0246fc25c1 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Fri, 5 Apr 2013 13:28:45 +0200 Subject: [PATCH 3/3] daemon: Add wtmp file monitor To reload users history. https://bugzilla.gnome.org/show_bug.cgi?id=697040 --- src/daemon.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/daemon.c b/src/daemon.c index 51e793e..7a003aa 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -50,6 +50,9 @@ #define PATH_NOLOGIN "/sbin/nologin" #define PATH_FALSE "/bin/false" #define PATH_GDM_CUSTOM "/etc/gdm/custom.conf" +#ifdef HAVE_UTMPX_H +#define PATH_WTMP _PATH_WTMPX +#endif static const char *default_excludes[] = { "bin", @@ -97,6 +100,9 @@ struct DaemonPrivate { GFileMonitor *passwd_monitor; GFileMonitor *shadow_monitor; GFileMonitor *gdm_monitor; +#ifdef HAVE_UTMPX_H + GFileMonitor *wtmp_monitor; +#endif guint reload_id; guint autologin_id; @@ -269,7 +275,7 @@ entry_generator_wtmp (GHashTable *users, return NULL; } #else - utmpxname (_PATH_WTMPX); + utmpxname (PATH_WTMP); setutxent (); #endif *state = g_new (WTmpGeneratorState, 1); @@ -787,6 +793,24 @@ daemon_init (Daemon *daemon) } g_object_unref (file); +#ifdef HAVE_UTMPX_H + file = g_file_new_for_path (PATH_WTMP); + daemon->priv->wtmp_monitor = g_file_monitor_file (file, + G_FILE_MONITOR_NONE, + NULL, + &error); + if (daemon->priv->wtmp_monitor != NULL) { + g_signal_connect (daemon->priv->wtmp_monitor, + "changed", + G_CALLBACK (on_users_monitor_changed), + daemon); + } else { + g_warning ("Unable to monitor %s: %s", PATH_WTMP, error->message); + g_error_free (error); + } + g_object_unref (file); +#endif + file = g_file_new_for_path (PATH_GDM_CUSTOM); daemon->priv->gdm_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, -- 1.8.1.4