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

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