File gnome-keyring-check-session.patch of Package gnome-keyring
diff -urp gnome-keyring-2.32.1.orig/pam/gkr-pam-module.c gnome-keyring-2.32.1/pam/gkr-pam-module.c
--- gnome-keyring-2.32.1.orig/pam/gkr-pam-module.c 2010-09-05 23:50:15.000000000 +0200
+++ gnome-keyring-2.32.1/pam/gkr-pam-module.c 2011-01-14 12:20:37.000000000 +0100
@@ -91,10 +91,49 @@ enum {
#endif
#endif
+static const char* get_any_env (pam_handle_t *ph, const char *name);
+
/* -----------------------------------------------------------------------------
* HELPERS
*/
-
+
+/* We don't want to start the keyring if the session is not GNOME, Xfce
+ * or LXDE. Note that this only works if the service is gdm or lxdm,
+ * so we return TRUE in all other cases. */
+static int
+starting_supported_desktop (pam_handle_t *ph)
+{
+ const char *session = NULL;
+ const void *service = NULL;
+
+ if (pam_get_item (ph, PAM_SERVICE, &service) != PAM_SUCCESS)
+ return 1;
+
+ if (!service)
+ return 1;
+
+ if (strcmp (service, "gdm") != 0 &&
+ strcmp (service, "lxdm") != 0)
+ return 1;
+
+ session = get_any_env (ph, "DESKTOP_SESSION");
+ if (!session)
+ return 0;
+
+ if (strcmp (session, "gnome") == 0)
+ return 1;
+ if (strcmp (session, "gnome3") == 0)
+ return 1;
+ if (strcmp (session, "smeegol") == 0)
+ return 1;
+ if (strcmp (session, "xfce") == 0)
+ return 1;
+ if (strcmp (session, "LXDE") == 0)
+ return 1;
+
+ return 0;
+}
+
static void
close_safe (int fd)
{
@@ -833,7 +872,7 @@ pam_sm_authenticate (pam_handle_t *ph, i
started_daemon = 0;
/* Should we start the daemon? */
- if (args & ARG_AUTO_START) {
+ if ((args & ARG_AUTO_START) && starting_supported_desktop (ph)) {
ret = start_daemon_if_necessary (ph, pwd, password, &started_daemon);
if (ret != PAM_SUCCESS)
return ret;
@@ -905,7 +944,7 @@ pam_sm_open_session (pam_handle_t *ph, i
started_daemon = 0;
/* Should we start the daemon? */
- if (args & ARG_AUTO_START) {
+ if ((args & ARG_AUTO_START) && starting_supported_desktop (ph)) {
ret = start_daemon_if_necessary (ph, pwd, password, &started_daemon);
if (ret != PAM_SUCCESS)
return ret;