|
|
6b1540 |
From 738a10ca78e154ad4c3df9a1298eaad01516457e Mon Sep 17 00:00:00 2001
|
|
|
890c66 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
890c66 |
Date: Mon, 20 Aug 2018 14:30:59 -0400
|
|
|
890c66 |
Subject: [PATCH 4/4] daemon: handle upgrades from RHEL 7
|
|
|
890c66 |
|
|
|
890c66 |
RHEL 7 users need to stay on X if they were using X,
|
|
|
890c66 |
and they need to stay on gnome-classic if they were using
|
|
|
890c66 |
gnome-classic.
|
|
|
890c66 |
|
|
|
890c66 |
This commit examines the user's config to deduce whether
|
|
|
890c66 |
or not they were using RHEL 7 and in the event they were
|
|
|
890c66 |
try to get the right settings.
|
|
|
890c66 |
---
|
|
|
890c66 |
daemon/gdm-session-settings.c | 19 +++++++++++++++++++
|
|
|
3b7e70 |
daemon/gdm-session.c | 19 ++++++++-----------
|
|
|
3b7e70 |
2 files changed, 27 insertions(+), 11 deletions(-)
|
|
|
890c66 |
|
|
|
890c66 |
diff --git a/daemon/gdm-session-settings.c b/daemon/gdm-session-settings.c
|
|
|
6b1540 |
index a4b7f1a6..a84b2ffa 100644
|
|
|
890c66 |
--- a/daemon/gdm-session-settings.c
|
|
|
890c66 |
+++ b/daemon/gdm-session-settings.c
|
|
|
890c66 |
@@ -270,95 +270,114 @@ gdm_session_settings_get_property (GObject *object,
|
|
|
890c66 |
|
|
|
890c66 |
default:
|
|
|
890c66 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
890c66 |
}
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
890c66 |
GdmSessionSettings *
|
|
|
890c66 |
gdm_session_settings_new (void)
|
|
|
890c66 |
{
|
|
|
890c66 |
GdmSessionSettings *settings;
|
|
|
890c66 |
|
|
|
890c66 |
settings = g_object_new (GDM_TYPE_SESSION_SETTINGS,
|
|
|
890c66 |
NULL);
|
|
|
890c66 |
|
|
|
890c66 |
return settings;
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
890c66 |
gboolean
|
|
|
890c66 |
gdm_session_settings_is_loaded (GdmSessionSettings *settings)
|
|
|
890c66 |
{
|
|
|
890c66 |
if (settings->priv->user == NULL) {
|
|
|
890c66 |
return FALSE;
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
890c66 |
return act_user_is_loaded (settings->priv->user);
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
890c66 |
static void
|
|
|
890c66 |
load_settings_from_user (GdmSessionSettings *settings)
|
|
|
890c66 |
{
|
|
|
890c66 |
+ const char *system_id = NULL, *system_version_id = NULL;
|
|
|
890c66 |
const char *object_path;
|
|
|
890c66 |
const char *session_name;
|
|
|
890c66 |
const char *session_type;
|
|
|
890c66 |
const char *language_name;
|
|
|
890c66 |
|
|
|
890c66 |
if (!act_user_is_loaded (settings->priv->user)) {
|
|
|
890c66 |
g_warning ("GdmSessionSettings: trying to load user settings from unloaded user");
|
|
|
890c66 |
return;
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
890c66 |
object_path = act_user_get_object_path (settings->priv->user);
|
|
|
890c66 |
|
|
|
890c66 |
if (object_path != NULL) {
|
|
|
890c66 |
g_autoptr (GError) error = NULL;
|
|
|
890c66 |
settings->priv->user_system_proxy = gdm_accounts_service_user_system_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
|
|
890c66 |
G_DBUS_PROXY_FLAGS_NONE,
|
|
|
890c66 |
"org.freedesktop.Accounts",
|
|
|
890c66 |
object_path,
|
|
|
890c66 |
NULL,
|
|
|
890c66 |
&error);
|
|
|
890c66 |
if (error != NULL) {
|
|
|
890c66 |
g_debug ("GdmSessionSettings: couldn't retrieve user system proxy from accountsservice: %s",
|
|
|
890c66 |
error->message);
|
|
|
890c66 |
+ } else {
|
|
|
890c66 |
+ system_id = gdm_accounts_service_user_system_get_id (settings->priv->user_system_proxy);
|
|
|
890c66 |
+ system_version_id = gdm_accounts_service_user_system_get_version_id (settings->priv->user_system_proxy);
|
|
|
890c66 |
}
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
6b1540 |
|
|
|
6b1540 |
|
|
|
6b1540 |
|
|
|
890c66 |
|
|
|
890c66 |
session_type = act_user_get_session_type (settings->priv->user);
|
|
|
890c66 |
session_name = act_user_get_session (settings->priv->user);
|
|
|
890c66 |
|
|
|
890c66 |
g_debug ("GdmSessionSettings: saved session is %s (type %s)", session_name, session_type);
|
|
|
890c66 |
|
|
|
890c66 |
+ if (system_id == NULL || (g_strcmp0 (system_id, "rhel") == 0 && g_str_has_prefix (system_version_id, "7."))) {
|
|
|
890c66 |
+ /* if there's also no session name in the file and we're coming from RHEL 7,
|
|
|
890c66 |
+ * then we should assume classic session
|
|
|
890c66 |
+ */
|
|
|
890c66 |
+ if (session_name == NULL || session_name[0] == '\0')
|
|
|
890c66 |
+ session_name = "gnome-classic";
|
|
|
890c66 |
+
|
|
|
890c66 |
+ /* only presume wayland if the user specifically picked it in RHEL 7
|
|
|
890c66 |
+ */
|
|
|
890c66 |
+ if (g_strcmp0 (session_name, "gnome-wayland") == 0)
|
|
|
890c66 |
+ session_type = "wayland";
|
|
|
890c66 |
+ else
|
|
|
890c66 |
+ session_type = "x11";
|
|
|
890c66 |
+ }
|
|
|
890c66 |
+
|
|
|
890c66 |
if (session_type != NULL && session_type[0] != '\0') {
|
|
|
890c66 |
gdm_session_settings_set_session_type (settings, session_type);
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
890c66 |
if (session_name != NULL && session_name[0] != '\0') {
|
|
|
890c66 |
gdm_session_settings_set_session_name (settings, session_name);
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
890c66 |
language_name = act_user_get_language (settings->priv->user);
|
|
|
890c66 |
|
|
|
890c66 |
g_debug ("GdmSessionSettings: saved language is %s", language_name);
|
|
|
890c66 |
if (language_name != NULL && language_name[0] != '\0') {
|
|
|
890c66 |
gdm_session_settings_set_language_name (settings, language_name);
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
890c66 |
out:
|
|
|
890c66 |
g_object_notify (G_OBJECT (settings), "is-loaded");
|
|
|
890c66 |
}
|
|
|
890c66 |
|
|
|
890c66 |
static void
|
|
|
890c66 |
on_user_is_loaded_changed (ActUser *user,
|
|
|
890c66 |
GParamSpec *pspec,
|
|
|
890c66 |
GdmSessionSettings *settings)
|
|
|
890c66 |
{
|
|
|
890c66 |
if (act_user_is_loaded (settings->priv->user)) {
|
|
|
890c66 |
load_settings_from_user (settings);
|
|
|
890c66 |
g_signal_handlers_disconnect_by_func (G_OBJECT (settings->priv->user),
|
|
|
890c66 |
G_CALLBACK (on_user_is_loaded_changed),
|
|
|
890c66 |
settings);
|
|
|
890c66 |
}
|
|
|
3b7e70 |
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
|
|
|
6b1540 |
index d1e2c301..d4a46d87 100644
|
|
|
3b7e70 |
--- a/daemon/gdm-session.c
|
|
|
3b7e70 |
+++ b/daemon/gdm-session.c
|
|
|
6b1540 |
@@ -3207,98 +3207,95 @@ gdm_session_get_session_id (GdmSession *self)
|
|
|
3b7e70 |
return conversation->session_id;
|
|
|
3b7e70 |
}
|
|
|
3b7e70 |
|
|
|
3b7e70 |
const char *
|
|
|
3b7e70 |
gdm_session_get_conversation_session_id (GdmSession *self,
|
|
|
3b7e70 |
const char *service_name)
|
|
|
3b7e70 |
{
|
|
|
3b7e70 |
GdmSessionConversation *conversation;
|
|
|
3b7e70 |
|
|
|
3b7e70 |
g_return_val_if_fail (GDM_IS_SESSION (self), NULL);
|
|
|
3b7e70 |
|
|
|
3b7e70 |
conversation = find_conversation_by_name (self, service_name);
|
|
|
3b7e70 |
|
|
|
3b7e70 |
if (conversation == NULL) {
|
|
|
3b7e70 |
return NULL;
|
|
|
3b7e70 |
}
|
|
|
3b7e70 |
|
|
|
3b7e70 |
return conversation->session_id;
|
|
|
3b7e70 |
}
|
|
|
3b7e70 |
|
|
|
3b7e70 |
static char *
|
|
|
3b7e70 |
get_session_filename (GdmSession *self)
|
|
|
3b7e70 |
{
|
|
|
3b7e70 |
return g_strdup_printf ("%s.desktop", get_session_name (self));
|
|
|
3b7e70 |
}
|
|
|
3b7e70 |
|
|
|
3b7e70 |
#ifdef ENABLE_WAYLAND_SUPPORT
|
|
|
3b7e70 |
static gboolean
|
|
|
3b7e70 |
gdm_session_is_wayland_session (GdmSession *self)
|
|
|
3b7e70 |
{
|
|
|
3b7e70 |
- GKeyFile *key_file;
|
|
|
3b7e70 |
+ g_autoptr (GKeyFile) key_file = NULL;
|
|
|
3b7e70 |
gboolean is_wayland_session = FALSE;
|
|
|
3b7e70 |
- char *filename;
|
|
|
3b7e70 |
- char *full_path = NULL;
|
|
|
3b7e70 |
+ g_autofree char *filename = NULL;
|
|
|
3b7e70 |
+ g_autofree char *full_path = NULL;
|
|
|
3b7e70 |
|
|
|
3b7e70 |
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
3b7e70 |
g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
|
|
|
3b7e70 |
|
|
|
3b7e70 |
filename = get_session_filename (self);
|
|
|
3b7e70 |
|
|
|
3b7e70 |
if (supports_session_type (self, "wayland")) {
|
|
|
3b7e70 |
key_file = load_key_file_for_file (self, filename, NULL, &full_path);
|
|
|
3b7e70 |
|
|
|
3b7e70 |
if (key_file == NULL) {
|
|
|
3b7e70 |
goto out;
|
|
|
3b7e70 |
}
|
|
|
3b7e70 |
- }
|
|
|
3b7e70 |
|
|
|
3b7e70 |
- if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) {
|
|
|
3b7e70 |
- is_wayland_session = TRUE;
|
|
|
3b7e70 |
+ if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) {
|
|
|
3b7e70 |
+ is_wayland_session = TRUE;
|
|
|
3b7e70 |
+ }
|
|
|
3b7e70 |
}
|
|
|
3b7e70 |
- g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no");
|
|
|
3b7e70 |
|
|
|
3b7e70 |
out:
|
|
|
3b7e70 |
- g_clear_pointer (&key_file, g_key_file_free);
|
|
|
3b7e70 |
- g_free (filename);
|
|
|
3b7e70 |
+ g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no");
|
|
|
3b7e70 |
return is_wayland_session;
|
|
|
3b7e70 |
}
|
|
|
3b7e70 |
#endif
|
|
|
3b7e70 |
|
|
|
3b7e70 |
static void
|
|
|
3b7e70 |
update_session_type (GdmSession *self)
|
|
|
3b7e70 |
{
|
|
|
3b7e70 |
#ifdef ENABLE_WAYLAND_SUPPORT
|
|
|
3b7e70 |
gboolean is_wayland_session = FALSE;
|
|
|
3b7e70 |
|
|
|
3b7e70 |
- if (supports_session_type (self, "wayland"))
|
|
|
3b7e70 |
- is_wayland_session = gdm_session_is_wayland_session (self);
|
|
|
3b7e70 |
+ is_wayland_session = gdm_session_is_wayland_session (self);
|
|
|
3b7e70 |
|
|
|
3b7e70 |
if (is_wayland_session) {
|
|
|
3b7e70 |
set_session_type (self, "wayland");
|
|
|
3b7e70 |
} else {
|
|
|
3b7e70 |
set_session_type (self, NULL);
|
|
|
3b7e70 |
}
|
|
|
3b7e70 |
#endif
|
|
|
3b7e70 |
}
|
|
|
3b7e70 |
|
|
|
3b7e70 |
gboolean
|
|
|
3b7e70 |
gdm_session_session_registers (GdmSession *self)
|
|
|
3b7e70 |
{
|
|
|
3b7e70 |
g_autoptr(GError) error = NULL;
|
|
|
3b7e70 |
g_autoptr(GKeyFile) key_file = NULL;
|
|
|
3b7e70 |
gboolean session_registers = FALSE;
|
|
|
3b7e70 |
g_autofree char *filename = NULL;
|
|
|
3b7e70 |
|
|
|
3b7e70 |
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
3b7e70 |
g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
|
|
|
3b7e70 |
|
|
|
3b7e70 |
filename = get_session_filename (self);
|
|
|
3b7e70 |
|
|
|
3b7e70 |
key_file = load_key_file_for_file (self, filename, NULL, NULL);
|
|
|
3b7e70 |
|
|
|
3b7e70 |
session_registers = g_key_file_get_boolean (key_file,
|
|
|
3b7e70 |
G_KEY_FILE_DESKTOP_GROUP,
|
|
|
3b7e70 |
"X-GDM-SessionRegisters",
|
|
|
3b7e70 |
&error);
|
|
|
3b7e70 |
if (!session_registers &&
|
|
|
3b7e70 |
error != NULL &&
|
|
|
890c66 |
--
|
|
|
6b1540 |
2.33.1
|
|
|
890c66 |
|