Index: xfce4-session/xfsm-compat-gnome.c =================================================================== --- xfce4-session/xfsm-compat-gnome.c (revision 27227) +++ xfce4-session/xfsm-compat-gnome.c (working copy) @@ -44,6 +44,9 @@ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_FCNTL_H +#include +#endif #include #include @@ -55,25 +58,48 @@ #ifdef HAVE_GNOME #include #endif +#ifdef HAVE_GNOME_KEYRING_LIBS +#include +#endif #include - #ifdef HAVE_GNOME #define ACCESSIBILITY_KEY "/desktop/gnome/interface/accessibility" #define AT_STARTUP_KEY "/desktop/gnome/accessibility/startup/exec_ats" +#define GNOME_KEYRING_DAEMON "gnome-keyring-daemon" static GConfClient *gnome_conf_client = NULL; #endif - +static int keyring_lifetime_pipe[2]; static pid_t gnome_keyring_daemon_pid = 0; static Window gnome_smproxy_window = None; +static void +child_setup (gpointer user_data) +{ + gint open_max; + gint fd; + char *fd_str; + open_max = sysconf (_SC_OPEN_MAX); + for (fd = 3; fd < open_max; fd++) + { + if (fd != keyring_lifetime_pipe[0]) + fcntl (fd, F_SETFD, FD_CLOEXEC); + } + + fd_str = g_strdup_printf ("%d", keyring_lifetime_pipe[0]); + g_setenv ("GNOME_KEYRING_LIFETIME_FD", fd_str, TRUE); +} + + static void gnome_keyring_daemon_startup (void) { + const char *old_keyring; + GError *error = NULL; gchar *sout; gchar **lines; @@ -81,11 +107,33 @@ long pid; gchar *pid_str; gchar *end; - - // FIXME: use async spawn! - g_spawn_command_line_sync ("gnome-keyring-daemon", - &sout, NULL, &status, &error); + char *argv[2]; + /* If there is already a working keyring, don't start a new daemon */ + old_keyring = g_getenv ("GNOME_KEYRING_SOCKET"); + if (old_keyring != NULL && access (old_keyring, R_OK | W_OK) == 0) + { +#ifdef HAVE_GNOME_KEYRING_LIBS + gnome_keyring_daemon_prepare_environment_sync (); +#endif + return; + } + + + /* Pipe to slave keyring lifetime to */ + pipe (keyring_lifetime_pipe); + + error = NULL; + argv[0] = GNOME_KEYRING_DAEMON; + argv[1] = NULL; + g_spawn_sync (NULL, argv, NULL, G_SPAWN_LEAVE_DESCRIPTORS_OPEN, + child_setup, NULL, + &sout, NULL, &status, &error); + + close (keyring_lifetime_pipe[0]); + /* We leave keyring_lifetime_pipe[1] open for the lifetime of the session, + in order to slave the keyring daemon lifecycle to the session. */ + if (error != NULL) { g_printerr ("Failed to run gnome-keyring-daemon: %s\n", @@ -112,6 +160,10 @@ } g_strfreev (lines); + +#ifdef HAVE_GNOME_KEYRING_LIBS + gnome_keyring_daemon_prepare_environment_sync (); +#endif } else { Index: xfce4-session/Makefile.am =================================================================== --- xfce4-session/Makefile.am (revision 27227) +++ xfce4-session/Makefile.am (working copy) @@ -46,6 +46,7 @@ xfce4_session_CFLAGS = \ $(GNOME_CFLAGS) \ + $(GNOME_KEYRING_CFLAGS) \ $(LIBSM_CFLAGS) \ $(LIBX11_CFLAGS) \ $(LIBXFCEGUI4_CFLAGS) \ @@ -67,7 +68,8 @@ $(LIBXFCEGUI4_LIBS) \ $(DBUS_LIBS) \ $(LIBWNCK_LIBS) \ - $(GNOME_LIBS) + $(GNOME_LIBS) \ + $(GNOME_KEYRING_LIBS) xfce4_session_DEPENDENCIES = \ $(top_builddir)/libxfsm/libxfsm-4.2.la Index: configure.in.in =================================================================== --- configure.in.in (revision 27227) +++ configure.in.in (working copy) @@ -81,6 +81,11 @@ dnl Check for gnome support XDT_CHECK_OPTIONAL_PACKAGE([GNOME], [gconf-2.0], [2.4.0], [gnome], [Assistive technologies support], [no]) +if test x"$GNOME_CFLAGS" != x"";then + XDT_CHECK_PACKAGE([GNOME_KEYRING], + [gnome-keyring-1], [2.22], AC_DEFINE([HAVE_GNOME_KEYRING_LIBS], [1], [Have a recent gnome keyring lib]), + AC_MSG_WARN([A recent version of gnome-keyring libraries was not found on your system])) +fi dnl Check for debugging support BM_DEBUG_SUPPORT()