File gdm-desktop-session-env-pam.patch of Package gdm

Index: gdm-3.3.92.1/daemon/gdm-session-worker.c
===================================================================
--- gdm-3.3.92.1.orig/daemon/gdm-session-worker.c
+++ gdm-3.3.92.1/daemon/gdm-session-worker.c
@@ -148,6 +148,8 @@ struct GdmSessionWorkerPrivate
 
         GdmSessionAuditor  *auditor;
         GdmSessionSettings *user_settings;
+
+        char             *suse_session_name;
 };
 
 enum {
@@ -166,6 +168,11 @@ static void     gdm_session_worker_set_e
 static void     queue_state_change              (GdmSessionWorker      *worker);
 
 
+static void
+gdm_session_worker_set_environment_variable (GdmSessionWorker *worker,
+                                             const char       *key,
+                                             const char       *value);
+
 typedef int (* GdmSessionWorkerPamNewMessagesFunc) (int,
                                                     const struct pam_message **,
                                                     struct pam_response **,
@@ -1196,6 +1203,9 @@ gdm_session_worker_initialize_pam (GdmSe
         }
 #endif
 
+        if (worker->priv->suse_session_name)
+                gdm_session_worker_set_environment_variable (worker, "DESKTOP_SESSION", worker->priv->suse_session_name);
+
         g_debug ("GdmSessionWorker: state SETUP_COMPLETE");
         worker->priv->state = GDM_SESSION_WORKER_STATE_SETUP_COMPLETE;
 
@@ -2051,11 +2061,26 @@ static void
 gdm_session_worker_set_session_name (GdmSessionWorker *worker,
                                      const char       *session_name)
 {
+        if (worker->priv->pam_handle != NULL)
+                gdm_session_worker_set_environment_variable (worker, "DESKTOP_SESSION", session_name);
+        g_free (worker->priv->suse_session_name);
+        worker->priv->suse_session_name = g_strdup (session_name);
+
         gdm_session_settings_set_session_name (worker->priv->user_settings,
                                                session_name);
 }
 
 static void
+gdm_session_worker_set_default_session_name (GdmSessionWorker *worker,
+                                             const char       *session_name)
+{
+        if (worker->priv->pam_handle != NULL)
+                gdm_session_worker_set_environment_variable (worker, "DESKTOP_SESSION", session_name);
+        g_free (worker->priv->suse_session_name);
+        worker->priv->suse_session_name = g_strdup (session_name);
+}
+
+static void
 on_set_session_name (GdmSessionWorker *worker,
                      DBusMessage      *message)
 {
@@ -2108,6 +2133,28 @@ on_set_session_type (GdmSessionWorker *w
 }
 
 static void
+on_set_default_session_name (GdmSessionWorker *worker,
+                             DBusMessage      *message)
+{
+        DBusError   error;
+        const char *session_name;
+        dbus_bool_t res;
+
+        dbus_error_init (&error);
+        res = dbus_message_get_args (message,
+                                     &error,
+                                     DBUS_TYPE_STRING, &session_name,
+                                     DBUS_TYPE_INVALID);
+        if (res) {
+                g_debug ("GdmSessionWorker: default session name changed; session name set to %s", session_name);
+                gdm_session_worker_set_default_session_name (worker, session_name);
+        } else {
+                g_warning ("Unable to get arguments: %s", error.message);
+                dbus_error_free (&error);
+        }
+}
+
+static void
 gdm_session_worker_set_language_name (GdmSessionWorker *worker,
                                       const char       *language_name)
 {
@@ -2830,6 +2877,8 @@ worker_dbus_handle_message (DBusConnecti
                 on_set_session_name (worker, message);
         } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "SetSessionType")) {
                 on_set_session_type (worker, message);
+        } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "SetDefaultSessionName")) {
+                on_set_default_session_name (worker, message);
         } else {
                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
         }
@@ -3001,6 +3050,8 @@ gdm_session_worker_finalize (GObject *ob
         g_free (worker->priv->server_address);
         g_strfreev (worker->priv->arguments);
 
+        g_free (worker->priv->suse_session_name);
+
         G_OBJECT_CLASS (gdm_session_worker_parent_class)->finalize (object);
 }
 
Index: gdm-3.3.92.1/daemon/gdm-session-direct.c
===================================================================
--- gdm-3.3.92.1.orig/daemon/gdm-session-direct.c
+++ gdm-3.3.92.1/daemon/gdm-session-direct.c
@@ -135,6 +135,8 @@ G_DEFINE_TYPE_WITH_CODE (GdmSessionDirec
                          G_IMPLEMENT_INTERFACE (GDM_TYPE_SESSION,
                                                 gdm_session_iface_init))
 
+static const char *get_session_name (GdmSessionDirect *session);
+
 static gboolean
 send_dbus_message (GdmSessionConversation *conversation,
                    DBusMessage            *message)
@@ -774,10 +776,27 @@ get_default_session_name (GdmSessionDire
 static void
 gdm_session_direct_defaults_changed (GdmSessionDirect *session)
 {
+        GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+        GHashTableIter iter;
+        gpointer key, value;
+        const char *text;
+
         _gdm_session_default_language_name_changed (GDM_SESSION (session),
                                                     get_default_language_name (session));
         _gdm_session_default_session_name_changed (GDM_SESSION (session),
                                                    get_default_session_name (session));
+
+        text = get_session_name (impl);
+
+        g_hash_table_iter_init (&iter, impl->priv->conversations);
+        while (g_hash_table_iter_next (&iter, &key, &value)) {
+                GdmSessionConversation *conversation;
+
+                conversation = (GdmSessionConversation *) value;
+
+                send_dbus_string_signal (conversation, "SetDefaultSessionName",
+                                         text);
+        }
 }
 
 static void
@@ -1230,11 +1249,28 @@ gdm_session_direct_handle_saved_session_
 
         if (strcmp (session_name,
                     get_default_session_name (session)) != 0) {
+                GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+                GHashTableIter iter;
+                gpointer key, value;
+                const char *text;
+
                 g_free (session->priv->saved_session);
                 session->priv->saved_session = g_strdup (session_name);
 
                 _gdm_session_default_session_name_changed (GDM_SESSION (session),
                                                            session_name);
+
+                text = get_session_name (impl);
+
+                g_hash_table_iter_init (&iter, impl->priv->conversations);
+                while (g_hash_table_iter_next (&iter, &key, &value)) {
+                        GdmSessionConversation *conversation;
+
+                        conversation = (GdmSessionConversation *) value;
+
+                        send_dbus_string_signal (conversation, "SetDefaultSessionName",
+                                                 text);
+                }
         }
  out:
         return DBUS_HANDLER_RESULT_HANDLED;
@@ -1434,6 +1470,9 @@ do_introspect (DBusConnection *connectio
                                "    <signal name=\"SetSessionType\">\n"
                                "      <arg name=\"session_type\" type=\"s\"/>\n"
                                "    </signal>\n"
+                               "    <signal name=\"SetDefaultSessionName\">\n"
+                               "      <arg name=\"session_name\" type=\"s\"/>\n"
+                               "    </signal>\n"
                                "    <signal name=\"StartProgram\">\n"
                                "      <arg name=\"command\" type=\"s\"/>\n"
                                "    </signal>\n"