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

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