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

Index: gdm-2.23.92/daemon/gdm-session-worker.c
===================================================================
--- gdm-2.23.92.orig/daemon/gdm-session-worker.c
+++ gdm-2.23.92/daemon/gdm-session-worker.c
@@ -1926,11 +1926,28 @@ static void
 gdm_session_worker_set_session_name (GdmSessionWorker *worker,
                                      const char       *session_name)
 {
+        char *env;
+
+        env = g_strdup_printf ("DESKTOP_SESSION=%s", session_name);
+        pam_putenv (worker->priv->pam_handle, env);
+        g_free (env);
+
         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)
+{
+        char *env;
+
+        env = g_strdup_printf ("DESKTOP_SESSION=%s", session_name);
+        pam_putenv (worker->priv->pam_handle, env);
+        g_free (env);
+}
+
+static void
 on_set_session_name (GdmSessionWorker *worker,
                      DBusMessage      *message)
 {
@@ -1953,6 +1970,28 @@ on_set_session_name (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)
 {
@@ -2527,6 +2566,8 @@ worker_dbus_handle_message (DBusConnecti
                 on_set_layout_name (worker, message);
         } else if (dbus_message_is_signal (message, GDM_SESSION_DBUS_INTERFACE, "SetSessionName")) {
                 on_set_session_name (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;
         }
Index: gdm-2.23.92/daemon/gdm-session-direct.c
===================================================================
--- gdm-2.23.92.orig/daemon/gdm-session-direct.c
+++ gdm-2.23.92/daemon/gdm-session-direct.c
@@ -115,6 +115,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 (DBusConnection *connection,
                    DBusMessage    *message)
@@ -668,12 +670,16 @@ get_default_session_name (GdmSessionDire
 static void
 gdm_session_direct_defaults_changed (GdmSessionDirect *session)
 {
+        GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+
         _gdm_session_default_language_name_changed (GDM_SESSION (session),
                                                     get_default_language_name (session));
         _gdm_session_default_layout_name_changed (GDM_SESSION (session),
                                                   get_default_layout_name (session));
         _gdm_session_default_session_name_changed (GDM_SESSION (session),
                                                    get_default_session_name (session));
+        send_dbus_string_signal (impl, "SetDefaultSessionName",
+                                 get_session_name (impl));
 }
 
 static void
@@ -1111,11 +1117,16 @@ gdm_session_direct_handle_saved_session_
 
         if (strcmp (session_name,
                     get_default_session_name (session)) != 0) {
+                GdmSessionDirect *impl = GDM_SESSION_DIRECT (session);
+
                 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);
+
+                send_dbus_string_signal (impl, "SetDefaultSessionName",
+                                         get_session_name (impl));
         }
  out:
         return DBUS_HANDLER_RESULT_HANDLED;
@@ -1306,6 +1317,9 @@ do_introspect (DBusConnection *connectio
                                "    <signal name=\"SetSessionName\">\n"
                                "      <arg name=\"session_name\" 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"
openSUSE Build Service is sponsored by