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

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