Blame SOURCES/0001-Honor-initial-setup-being-disabled-by-distro-install.patch

1f0c33
From f6ebcec5d48aeff718a9db9b8ff812fd404a61ed Mon Sep 17 00:00:00 2001
39d8c7
From: Rui Matos <tiagomatos@gmail.com>
39d8c7
Date: Mon, 23 Jan 2017 20:19:51 +0100
39d8c7
Subject: [PATCH] Honor initial setup being disabled by distro installer
39d8c7
39d8c7
Sysadmins might want to disable any kind of initial setup for their
39d8c7
users, perhaps because they pre-configure their environments. We
39d8c7
already provide a configuration file option for this but distro
39d8c7
installers might have their own way of requesting this.
39d8c7
39d8c7
At least the anaconda installer provides an option to skip any kind
39d8c7
post-install setup tools so, for now we're only adding support for
39d8c7
that but more might be added in the future.
39d8c7
39d8c7
https://bugzilla.gnome.org/show_bug.cgi?id=777708
39d8c7
---
39d8c7
 daemon/gdm-display.c | 29 +++++++++++++++++++++++++++++
1f0c33
 1 file changed, 29 insertions(+)
39d8c7
39d8c7
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
1f0c33
index 34467856..9438fe72 100644
39d8c7
--- a/daemon/gdm-display.c
39d8c7
+++ b/daemon/gdm-display.c
1f0c33
@@ -1621,103 +1621,132 @@ kernel_cmdline_initial_setup_force_state (gboolean *force_state)
1f0c33
         GError *error = NULL;
1f0c33
         gchar *contents = NULL;
1f0c33
         gchar *setup_argument = NULL;
1f0c33
 
1f0c33
         g_return_val_if_fail (force_state != NULL, FALSE);
1f0c33
 
1f0c33
         if (!g_file_get_contents ("/proc/cmdline", &contents, NULL, &error)) {
1f0c33
                 g_debug ("GdmDisplay: Could not check kernel parameters, not forcing initial setup: %s",
1f0c33
                           error->message);
1f0c33
                 g_clear_error (&error);
1f0c33
                 return FALSE;
1f0c33
         }
1f0c33
 
1f0c33
         g_debug ("GdmDisplay: Checking kernel command buffer %s", contents);
1f0c33
 
1f0c33
         if (!kernel_cmdline_initial_setup_argument (contents, &setup_argument, &error)) {
1f0c33
                 g_debug ("GdmDisplay: Failed to read kernel commandline: %s", error->message);
1f0c33
                 g_clear_pointer (&contents, g_free);
1f0c33
                 return FALSE;
1f0c33
         }
1f0c33
 
1f0c33
         g_clear_pointer (&contents, g_free);
1f0c33
 
1f0c33
         /* Poor-man's check for truthy or falsey values */
1f0c33
         *force_state = setup_argument[0] == '1';
1f0c33
 
1f0c33
         g_free (setup_argument);
39d8c7
         return TRUE;
39d8c7
 }
39d8c7
 
39d8c7
+static gboolean
39d8c7
+initial_setup_disabled_by_anaconda (void)
39d8c7
+{
39d8c7
+        GKeyFile *key_file;
39d8c7
+        const gchar *file_name = SYSCONFDIR "/sysconfig/anaconda";
39d8c7
+        gboolean disabled = FALSE;
39d8c7
+        GError *error = NULL;
39d8c7
+
39d8c7
+        key_file = g_key_file_new ();
39d8c7
+        if (!g_key_file_load_from_file (key_file, file_name, G_KEY_FILE_NONE, &error)) {
39d8c7
+                if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT) &&
39d8c7
+                    !g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND)) {
39d8c7
+                        g_warning ("Could not read %s: %s", file_name, error->message);
39d8c7
+                }
39d8c7
+                g_error_free (error);
39d8c7
+                goto out;
39d8c7
+        }
39d8c7
+
39d8c7
+        disabled = g_key_file_get_boolean (key_file, "General",
39d8c7
+                                           "post_install_tools_disabled", NULL);
39d8c7
+ out:
39d8c7
+        g_key_file_unref (key_file);
39d8c7
+        return disabled;
39d8c7
+}
39d8c7
+
39d8c7
 static gboolean
39d8c7
 wants_initial_setup (GdmDisplay *self)
39d8c7
 {
1f0c33
         GdmDisplayPrivate *priv;
1f0c33
         gboolean enabled = FALSE;
1f0c33
         gboolean forced = FALSE;
1f0c33
 
1f0c33
         priv = gdm_display_get_instance_private (self);
1f0c33
 
1f0c33
         if (already_done_initial_setup_on_this_boot ()) {
1f0c33
                 return FALSE;
1f0c33
         }
1f0c33
 
1f0c33
         if (kernel_cmdline_initial_setup_force_state (&forced)) {
1f0c33
                 if (forced) {
1f0c33
                         g_debug ("GdmDisplay: Forcing gnome-initial-setup");
1f0c33
                         return TRUE;
1f0c33
                 }
1f0c33
 
1f0c33
                 g_debug ("GdmDisplay: Forcing no gnome-initial-setup");
1f0c33
                 return FALSE;
1f0c33
         }
1f0c33
 
1f0c33
         /* don't run initial-setup on remote displays
1f0c33
          */
1f0c33
         if (!priv->is_local) {
1f0c33
                 return FALSE;
1f0c33
         }
1f0c33
 
1f0c33
         /* don't run if the system has existing users */
1f0c33
         if (priv->have_existing_user_accounts) {
1f0c33
                 return FALSE;
1f0c33
         }
1f0c33
 
1f0c33
         /* don't run if initial-setup is unavailable */
1f0c33
         if (!can_create_environment ("gnome-initial-setup")) {
1f0c33
                 return FALSE;
1f0c33
         }
1f0c33
 
1f0c33
         if (!gdm_settings_direct_get_boolean (GDM_KEY_INITIAL_SETUP_ENABLE, &enabled)) {
39d8c7
                 return FALSE;
39d8c7
         }
39d8c7
 
39d8c7
+        if (initial_setup_disabled_by_anaconda ()) {
39d8c7
+                return FALSE;
39d8c7
+        }
39d8c7
+
39d8c7
         return enabled;
39d8c7
 }
39d8c7
 
1f0c33
 void
1f0c33
 gdm_display_start_greeter_session (GdmDisplay *self)
1f0c33
 {
1f0c33
         GdmDisplayPrivate *priv;
1f0c33
         GdmSession    *session;
1f0c33
         char          *display_name;
1f0c33
         char          *seat_id;
1f0c33
         char          *hostname;
1f0c33
         char          *auth_file = NULL;
1f0c33
 
1f0c33
         priv = gdm_display_get_instance_private (self);
1f0c33
         g_return_if_fail (g_strcmp0 (priv->session_class, "greeter") == 0);
1f0c33
 
1f0c33
         g_debug ("GdmDisplay: Running greeter");
1f0c33
 
1f0c33
         display_name = NULL;
1f0c33
         seat_id = NULL;
1f0c33
         hostname = NULL;
1f0c33
 
1f0c33
         g_object_get (self,
1f0c33
                       "x11-display-name", &display_name,
1f0c33
                       "seat-id", &seat_id,
1f0c33
                       "remote-hostname", &hostname,
1f0c33
                       NULL);
1f0c33
         if (priv->access_file != NULL) {
1f0c33
                 auth_file = gdm_display_access_file_get_path (priv->access_file);
1f0c33
         }
39d8c7
-- 
1f0c33
2.32.0
39d8c7