2021-07-23 15:41:40 +00:00
|
|
|
From 7a39e99348a3ca8988c8542126f82012f81135af Mon Sep 17 00:00:00 2001
|
2020-10-14 22:48:53 +00:00
|
|
|
From: Rui Matos <tiagomatos@gmail.com>
|
|
|
|
Date: Mon, 23 Jan 2017 20:19:51 +0100
|
|
|
|
Subject: [PATCH] Honor initial setup being disabled by distro installer
|
|
|
|
|
|
|
|
Sysadmins might want to disable any kind of initial setup for their
|
|
|
|
users, perhaps because they pre-configure their environments. We
|
|
|
|
already provide a configuration file option for this but distro
|
|
|
|
installers might have their own way of requesting this.
|
|
|
|
|
|
|
|
At least the anaconda installer provides an option to skip any kind
|
|
|
|
post-install setup tools so, for now we're only adding support for
|
|
|
|
that but more might be added in the future.
|
|
|
|
|
|
|
|
https://bugzilla.gnome.org/show_bug.cgi?id=777708
|
|
|
|
---
|
|
|
|
daemon/gdm-display.c | 29 +++++++++++++++++++++++++++++
|
2021-07-23 15:41:40 +00:00
|
|
|
daemon/gdm-manager.c | 11 +++++------
|
|
|
|
daemon/gdm-session.c | 2 +-
|
|
|
|
3 files changed, 35 insertions(+), 7 deletions(-)
|
2020-10-14 22:48:53 +00:00
|
|
|
|
|
|
|
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
|
2021-07-23 15:41:40 +00:00
|
|
|
index 46d5a773..c7a8028b 100644
|
2020-10-14 22:48:53 +00:00
|
|
|
--- a/daemon/gdm-display.c
|
|
|
|
+++ b/daemon/gdm-display.c
|
2021-07-23 15:41:40 +00:00
|
|
|
@@ -1621,103 +1621,132 @@ kernel_cmdline_initial_setup_force_state (gboolean *force_state)
|
|
|
|
GError *error = NULL;
|
|
|
|
gchar *contents = NULL;
|
|
|
|
gchar *setup_argument = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (force_state != NULL, FALSE);
|
|
|
|
|
|
|
|
if (!g_file_get_contents ("/proc/cmdline", &contents, NULL, &error)) {
|
|
|
|
g_debug ("GdmDisplay: Could not check kernel parameters, not forcing initial setup: %s",
|
|
|
|
error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_debug ("GdmDisplay: Checking kernel command buffer %s", contents);
|
|
|
|
|
|
|
|
if (!kernel_cmdline_initial_setup_argument (contents, &setup_argument, &error)) {
|
|
|
|
g_debug ("GdmDisplay: Failed to read kernel commandline: %s", error->message);
|
|
|
|
g_clear_pointer (&contents, g_free);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_clear_pointer (&contents, g_free);
|
|
|
|
|
|
|
|
/* Poor-man's check for truthy or falsey values */
|
|
|
|
*force_state = setup_argument[0] == '1';
|
|
|
|
|
|
|
|
g_free (setup_argument);
|
2020-10-14 22:48:53 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static gboolean
|
|
|
|
+initial_setup_disabled_by_anaconda (void)
|
|
|
|
+{
|
|
|
|
+ GKeyFile *key_file;
|
|
|
|
+ const gchar *file_name = SYSCONFDIR "/sysconfig/anaconda";
|
|
|
|
+ gboolean disabled = FALSE;
|
|
|
|
+ GError *error = NULL;
|
|
|
|
+
|
|
|
|
+ key_file = g_key_file_new ();
|
|
|
|
+ if (!g_key_file_load_from_file (key_file, file_name, G_KEY_FILE_NONE, &error)) {
|
|
|
|
+ if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT) &&
|
|
|
|
+ !g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND)) {
|
|
|
|
+ g_warning ("Could not read %s: %s", file_name, error->message);
|
|
|
|
+ }
|
|
|
|
+ g_error_free (error);
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ disabled = g_key_file_get_boolean (key_file, "General",
|
|
|
|
+ "post_install_tools_disabled", NULL);
|
|
|
|
+ out:
|
|
|
|
+ g_key_file_unref (key_file);
|
|
|
|
+ return disabled;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static gboolean
|
|
|
|
wants_initial_setup (GdmDisplay *self)
|
|
|
|
{
|
2021-07-23 15:41:40 +00:00
|
|
|
GdmDisplayPrivate *priv;
|
|
|
|
gboolean enabled = FALSE;
|
|
|
|
gboolean forced = FALSE;
|
|
|
|
|
|
|
|
priv = gdm_display_get_instance_private (self);
|
|
|
|
|
|
|
|
if (already_done_initial_setup_on_this_boot ()) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kernel_cmdline_initial_setup_force_state (&forced)) {
|
|
|
|
if (forced) {
|
|
|
|
g_debug ("GdmDisplay: Forcing gnome-initial-setup");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_debug ("GdmDisplay: Forcing no gnome-initial-setup");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't run initial-setup on remote displays
|
|
|
|
*/
|
|
|
|
if (!priv->is_local) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't run if the system has existing users */
|
|
|
|
if (priv->have_existing_user_accounts) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't run if initial-setup is unavailable */
|
|
|
|
if (!can_create_environment ("gnome-initial-setup")) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gdm_settings_direct_get_boolean (GDM_KEY_INITIAL_SETUP_ENABLE, &enabled)) {
|
2020-10-14 22:48:53 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (initial_setup_disabled_by_anaconda ()) {
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
2021-07-23 15:41:40 +00:00
|
|
|
void
|
|
|
|
gdm_display_start_greeter_session (GdmDisplay *self)
|
|
|
|
{
|
|
|
|
GdmDisplayPrivate *priv;
|
|
|
|
GdmSession *session;
|
|
|
|
char *display_name;
|
|
|
|
char *seat_id;
|
|
|
|
char *hostname;
|
|
|
|
char *auth_file = NULL;
|
|
|
|
|
|
|
|
priv = gdm_display_get_instance_private (self);
|
|
|
|
g_return_if_fail (g_strcmp0 (priv->session_class, "greeter") == 0);
|
|
|
|
|
|
|
|
g_debug ("GdmDisplay: Running greeter");
|
|
|
|
|
|
|
|
display_name = NULL;
|
|
|
|
seat_id = NULL;
|
|
|
|
hostname = NULL;
|
|
|
|
|
|
|
|
g_object_get (self,
|
|
|
|
"x11-display-name", &display_name,
|
|
|
|
"seat-id", &seat_id,
|
|
|
|
"remote-hostname", &hostname,
|
|
|
|
NULL);
|
|
|
|
if (priv->access_file != NULL) {
|
|
|
|
auth_file = gdm_display_access_file_get_path (priv->access_file);
|
|
|
|
}
|
|
|
|
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
|
|
|
|
index e433acf3..f8dce936 100644
|
|
|
|
--- a/daemon/gdm-manager.c
|
|
|
|
+++ b/daemon/gdm-manager.c
|
|
|
|
@@ -2278,86 +2278,85 @@ on_session_reauthentication_started (GdmSession *session,
|
|
|
|
|
|
|
|
if (invocation != NULL) {
|
|
|
|
g_hash_table_steal (manager->priv->open_reauthentication_requests,
|
|
|
|
source_tag);
|
|
|
|
gdm_dbus_manager_complete_open_reauthentication_channel (GDM_DBUS_MANAGER (manager),
|
|
|
|
invocation,
|
|
|
|
address);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clean_user_session (GdmSession *session)
|
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (session), "gdm-display", NULL);
|
|
|
|
g_object_unref (session);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_user_session_for_display (GdmManager *manager,
|
|
|
|
GdmDisplay *display,
|
|
|
|
uid_t allowed_user)
|
|
|
|
{
|
|
|
|
GdmSession *session;
|
|
|
|
gboolean display_is_local = FALSE;
|
|
|
|
char *display_name = NULL;
|
|
|
|
char *display_device = NULL;
|
|
|
|
char *remote_hostname = NULL;
|
|
|
|
char *display_auth_file = NULL;
|
|
|
|
char *display_seat_id = NULL;
|
|
|
|
char *display_id = NULL;
|
|
|
|
-#if defined(ENABLE_WAYLAND_SUPPORT) && defined(ENABLE_USER_DISPLAY_SERVER)
|
|
|
|
- g_autofree char *display_session_type = NULL;
|
|
|
|
-#endif
|
|
|
|
+ g_auto (GStrv) supported_session_types = NULL;
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (display),
|
|
|
|
"id", &display_id,
|
|
|
|
"x11-display-name", &display_name,
|
|
|
|
"is-local", &display_is_local,
|
|
|
|
"remote-hostname", &remote_hostname,
|
|
|
|
"x11-authority-file", &display_auth_file,
|
|
|
|
"seat-id", &display_seat_id,
|
|
|
|
-#if defined(ENABLE_WAYLAND_SUPPORT) && defined(ENABLE_USER_DISPLAY_SERVER)
|
|
|
|
- "session-type", &display_session_type,
|
|
|
|
-#endif
|
|
|
|
+ "supported-session-types", &supported_session_types,
|
|
|
|
NULL);
|
|
|
|
display_device = get_display_device (manager, display);
|
|
|
|
|
|
|
|
session = gdm_session_new (GDM_SESSION_VERIFICATION_MODE_LOGIN,
|
|
|
|
allowed_user,
|
|
|
|
display_name,
|
|
|
|
remote_hostname,
|
|
|
|
display_device,
|
|
|
|
display_seat_id,
|
|
|
|
display_auth_file,
|
|
|
|
display_is_local,
|
|
|
|
NULL);
|
|
|
|
+ g_object_set (G_OBJECT (session),
|
|
|
|
+ "supported-session-types", supported_session_types,
|
|
|
|
+ NULL);
|
|
|
|
|
|
|
|
g_debug ("GdmSession: Created user session for user %d on display %s (seat %s)",
|
|
|
|
(int) allowed_user,
|
|
|
|
display_id,
|
|
|
|
display_seat_id);
|
|
|
|
|
|
|
|
g_free (display_name);
|
|
|
|
g_free (remote_hostname);
|
|
|
|
g_free (display_auth_file);
|
|
|
|
g_free (display_seat_id);
|
|
|
|
|
|
|
|
g_signal_connect (session,
|
|
|
|
"reauthentication-started",
|
|
|
|
G_CALLBACK (on_session_reauthentication_started),
|
|
|
|
manager);
|
|
|
|
g_signal_connect (session,
|
|
|
|
"reauthenticated",
|
|
|
|
G_CALLBACK (on_session_reauthenticated),
|
|
|
|
manager);
|
|
|
|
g_signal_connect (session,
|
|
|
|
"client-ready-for-session-to-start",
|
|
|
|
G_CALLBACK (on_session_client_ready_for_session_to_start),
|
|
|
|
manager);
|
|
|
|
g_signal_connect (session,
|
|
|
|
"client-connected",
|
|
|
|
G_CALLBACK (on_session_client_connected),
|
|
|
|
manager);
|
|
|
|
g_signal_connect (session,
|
|
|
|
"client-disconnected",
|
|
|
|
G_CALLBACK (on_session_client_disconnected),
|
|
|
|
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
|
|
|
|
index 2cd9c323..5c225445 100644
|
|
|
|
--- a/daemon/gdm-session.c
|
|
|
|
+++ b/daemon/gdm-session.c
|
|
|
|
@@ -2562,61 +2562,61 @@ gdm_session_send_environment (GdmSession *self,
|
|
|
|
g_return_if_fail (GDM_IS_SESSION (self));
|
|
|
|
|
|
|
|
conversation = find_conversation_by_name (self, service_name);
|
|
|
|
if (conversation != NULL) {
|
|
|
|
send_environment (self, conversation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
get_session_name (GdmSession *self)
|
|
|
|
{
|
|
|
|
/* FIXME: test the session names before we use them? */
|
|
|
|
|
|
|
|
if (self->selected_session != NULL) {
|
|
|
|
return self->selected_session;
|
|
|
|
}
|
|
|
|
|
|
|
|
return get_default_session_name (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
get_session_command (GdmSession *self)
|
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
char *command;
|
|
|
|
const char *session_name;
|
|
|
|
|
|
|
|
session_name = get_session_name (self);
|
|
|
|
|
|
|
|
command = NULL;
|
|
|
|
- res = get_session_command_for_name (self, session_name, NULL, &command);
|
|
|
|
+ res = get_session_command_for_name (self, session_name, self->session_type, &command);
|
|
|
|
if (! res) {
|
|
|
|
g_critical ("Cannot find a command for specified session: %s", session_name);
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return command;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
get_session_desktop_names (GdmSession *self)
|
|
|
|
{
|
|
|
|
gchar *filename;
|
|
|
|
GKeyFile *keyfile;
|
|
|
|
gchar *desktop_names = NULL;
|
|
|
|
|
|
|
|
if (self->selected_program != NULL) {
|
|
|
|
return g_strdup ("GNOME-Greeter:GNOME");
|
|
|
|
}
|
|
|
|
|
|
|
|
filename = g_strdup_printf ("%s.desktop", get_session_name (self));
|
|
|
|
g_debug ("GdmSession: getting desktop names for file '%s'", filename);
|
|
|
|
keyfile = load_key_file_for_file (self, filename, NULL, NULL);
|
|
|
|
if (keyfile != NULL) {
|
|
|
|
gchar **names;
|
|
|
|
|
|
|
|
names = g_key_file_get_string_list (keyfile, G_KEY_FILE_DESKTOP_GROUP,
|
|
|
|
"DesktopNames", NULL, NULL);
|
|
|
|
if (names != NULL) {
|
|
|
|
desktop_names = g_strjoinv (":", names);
|
|
|
|
|
2020-10-14 22:48:53 +00:00
|
|
|
--
|
2021-07-23 15:41:40 +00:00
|
|
|
2.32.0
|
2020-10-14 22:48:53 +00:00
|
|
|
|