File gnome-keyring-check-session.patch of Package gnome-keyring

Index: gnome-keyring-3.10.1/pam/gkr-pam-module.c
===================================================================
--- gnome-keyring-3.10.1.orig/pam/gkr-pam-module.c
+++ gnome-keyring-3.10.1/pam/gkr-pam-module.c
@@ -91,10 +91,53 @@ 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, lxdm or
+ * lightdm, 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, "gdm-password") != 0 &&
+	    strcmp (service, "lxdm") != 0 &&
+	    strcmp (service, "lightdm") != 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, "gnome-classic") == 0)
+		return 1;
+	if (strcmp (session, "sle-classic") == 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)
 {
@@ -867,7 +910,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;
@@ -939,7 +982,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;