From 5bbfac13e2a5c8d769251e1519db16537a824a64 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Fri, 5 Apr 2013 13:28:45 +0200 Subject: [PATCH] daemon: Add wtmp file monitor https://bugzilla.gnome.org/show_bug.cgi?id=697040 --- src/daemon.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/daemon.c b/src/daemon.c index c7457d2..f1d0a83 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_UTMPX _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 *utmpx_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_UTMPX); setutxent (); #endif *state = g_new (WTmpGeneratorState, 1); @@ -773,6 +779,14 @@ daemon_init (Daemon *daemon) NULL, &error); g_object_unref (file); +#ifdef HAVE_UTMPX_H + file = g_file_new_for_path (PATH_UTMPX); + daemon->priv->utmpx_monitor = g_file_monitor_file (file, + G_FILE_MONITOR_NONE, + NULL, + &error); + g_object_unref (file); +#endif if (daemon->priv->passwd_monitor != NULL) { g_signal_connect (daemon->priv->passwd_monitor, @@ -801,6 +815,17 @@ daemon_init (Daemon *daemon) g_warning ("Unable to monitor %s: %s", PATH_GDM_CUSTOM, error->message); g_error_free (error); } +#ifdef HAVE_UTMPX_H + if (daemon->priv->utmpx_monitor != NULL) { + g_signal_connect (daemon->priv->utmpx_monitor, + "changed", + G_CALLBACK (on_passwd_monitor_changed), + daemon); + } else { + g_warning ("Unable to monitor %s: %s", PATH_UTMPX, error->message); + g_error_free (error); + } +#endif queue_reload_users (daemon); queue_reload_autologin (daemon); -- 1.8.1.4