diff options
author | Ray Strode <rstrode@redhat.com> | 2015-10-15 16:07:22 -0400 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2015-10-16 22:30:18 +0200 |
commit | bf560bd195919d79a59a8642923ccac80c437bb1 (patch) | |
tree | 0394313074ca0e7459903d8e2ab959cecf5bd913 | |
parent | ac9492a929d364685da8c8cb4152bf2534ddfb6f (diff) | |
download | gnome-keyring-bf560bd195919d79a59a8642923ccac80c437bb1.tar.gz |
daemon: Kill off foreground proceses when session dies
Right now gnome-keyring will keep processes around forever
in some cases. They need to die when the session goes away,
at least.
Signed-off-by: Cosimo Cecchi <cosimoc@gnome.org>
* Don't leak a DBus connection
Signed-off-by: Stef Walter <stefw@gnome.org>
* Print error message if we cannot connect to bus
* Wait for gnome-keyring-daemon when --foreground
https://bugzilla.gnome.org/show_bug.cgi?id=756059
-rw-r--r-- | daemon/gkd-main.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/daemon/gkd-main.c b/daemon/gkd-main.c index af22cfc7..28758edf 100644 --- a/daemon/gkd-main.c +++ b/daemon/gkd-main.c @@ -827,6 +827,14 @@ on_login_timeout (gpointer data) return FALSE; } +static void +on_vanished_quit_loop (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + g_main_loop_quit (user_data); +} + int main (int argc, char *argv[]) { @@ -850,6 +858,9 @@ main (int argc, char *argv[]) * predictable startup. */ + GDBusConnection *connection = NULL; + GError *error = NULL; + /* * Before we do ANYTHING, we drop privileges so we don't become * a security issue ourselves. @@ -913,8 +924,20 @@ main (int argc, char *argv[]) */ print_environment (); close (parent_wakeup_fd); - if (run_foreground) - while (sleep(0x08000000) == 0); + if (run_foreground) { + connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + if (error) { + g_warning ("Couldn't connect to session bus: %s", error->message); + g_clear_error (&error); + } + loop = g_main_loop_new (NULL, FALSE); + g_bus_watch_name (G_BUS_TYPE_SESSION, "org.gnome.keyring", + G_BUS_NAME_WATCHER_FLAGS_NONE, + NULL, on_vanished_quit_loop, loop, NULL); + g_main_loop_run (loop); + g_clear_pointer (&loop, g_main_loop_unref); + g_clear_object (&connection); + } cleanup_and_exit (0); } |