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

f42647
From d4f6b620c4c1b56e7e6421cc470eb711d7faa0eb Mon Sep 17 00:00:00 2001
2fc437
From: Rui Matos <tiagomatos@gmail.com>
2fc437
Date: Mon, 23 Jan 2017 20:19:51 +0100
2fc437
Subject: [PATCH] Honor initial setup being disabled by distro installer
2fc437
2fc437
Sysadmins might want to disable any kind of initial setup for their
2fc437
users, perhaps because they pre-configure their environments. We
2fc437
already provide a configuration file option for this but distro
2fc437
installers might have their own way of requesting this.
2fc437
2fc437
At least the anaconda installer provides an option to skip any kind
2fc437
post-install setup tools so, for now we're only adding support for
2fc437
that but more might be added in the future.
2fc437
2fc437
https://bugzilla.gnome.org/show_bug.cgi?id=777708
2fc437
---
2fc437
 daemon/Makefile.am   |  1 +
2fc437
 daemon/gdm-display.c | 29 +++++++++++++++++++++++++++++
2fc437
 2 files changed, 30 insertions(+)
2fc437
2fc437
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
f42647
index 5e9eb5e0..3b1b1512 100644
2fc437
--- a/daemon/Makefile.am
2fc437
+++ b/daemon/Makefile.am
f42647
@@ -1,47 +1,48 @@
f42647
 NULL =
f42647
 
f42647
 AM_CPPFLAGS = \
f42647
 	-I.						\
f42647
 	-I..						\
f42647
 	-I$(top_srcdir)/common				\
f42647
 	-I$(top_srcdir)/pam-extensions			\
f42647
 	-I$(top_builddir)/common			\
f42647
 	-DBINDIR=\"$(bindir)\"				\
f42647
 	-DDATADIR=\"$(datadir)\"			\
f42647
 	-DDMCONFDIR=\"$(dmconfdir)\"			\
f42647
 	-DGDMCONFDIR=\"$(gdmconfdir)\"			\
f42647
 	-DLIBDIR=\"$(libdir)\"				\
f42647
 	-DLIBEXECDIR=\"$(libexecdir)\"			\
2fc437
 	-DLOCALSTATEDIR=\"$(localstatedir)\"		\
2fc437
 	-DLOGDIR=\"$(logdir)\"				\
2fc437
 	-DSBINDIR=\"$(sbindir)\"			\
2fc437
+	-DSYSCONFDIR=\"$(sysconfdir)\"			\
2fc437
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"	\
2fc437
 	-DGDM_RUN_DIR=\"$(GDM_RUN_DIR)\"		\
2fc437
 	-DGDM_XAUTH_DIR=\"$(GDM_XAUTH_DIR)\"		\
f42647
 	-DGDM_SCREENSHOT_DIR=\"$(GDM_SCREENSHOT_DIR)\"		\
f42647
 	-DGDM_CACHE_DIR=\""$(localstatedir)/cache/gdm"\"	\
f42647
 	-DGDM_SESSION_DEFAULT_PATH=\"$(GDM_SESSION_DEFAULT_PATH)\" \
f42647
 	$(DISABLE_DEPRECATED_CFLAGS)			\
f42647
 	$(DAEMON_CFLAGS)				\
f42647
 	$(XLIB_CFLAGS)					\
f42647
 	$(WARN_CFLAGS)					\
f42647
 	$(DEBUG_CFLAGS)					\
f42647
 	$(SYSTEMD_CFLAGS)				\
f42647
 	$(JOURNALD_CFLAGS)				\
f42647
 	$(LIBSELINUX_CFLAGS)	 			\
f42647
 	-DLANG_CONFIG_FILE=\"$(LANG_CONFIG_FILE)\"	\
f42647
 	$(NULL)
f42647
 
f42647
 BUILT_SOURCES =					\
f42647
 	gdm-display-glue.h			\
f42647
 	gdm-manager-glue.h			\
f42647
 	gdm-local-display-glue.h		\
f42647
 	gdm-local-display-factory-glue.h	\
f42647
 	gdm-session-glue.h			\
f42647
 	gdm-session-worker-glue.h		\
f42647
 	gdm-session-enum-types.h		\
f42647
 	$(NULL)
f42647
 
f42647
 gdm-session-enum-types.h: gdm-session-enum-types.h.in gdm-session.h
f42647
 	$(AM_V_GEN) glib-mkenums --template $^ > $@
f42647
 
2fc437
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
f42647
index 6a3984a9..30723da0 100644
2fc437
--- a/daemon/gdm-display.c
2fc437
+++ b/daemon/gdm-display.c
f42647
@@ -1522,100 +1522,129 @@ kernel_cmdline_initial_setup_force_state (gboolean *force_state)
f42647
         GError *error = NULL;
f42647
         gchar *contents = NULL;
f42647
         gchar *setup_argument = NULL;
f42647
 
f42647
         g_return_val_if_fail (force_state != NULL, FALSE);
f42647
 
f42647
         if (!g_file_get_contents ("/proc/cmdline", &contents, NULL, &error)) {
f42647
                 g_debug ("GdmDisplay: Could not check kernel parameters, not forcing initial setup: %s",
f42647
                           error->message);
f42647
                 g_clear_error (&error);
f42647
                 return FALSE;
f42647
         }
f42647
 
f42647
         g_debug ("GdmDisplay: Checking kernel command buffer %s", contents);
f42647
 
f42647
         if (!kernel_cmdline_initial_setup_argument (contents, &setup_argument, &error)) {
f42647
                 g_debug ("GdmDisplay: Failed to read kernel commandline: %s", error->message);
f42647
                 g_clear_pointer (&contents, g_free);
f42647
                 return FALSE;
f42647
         }
f42647
 
f42647
         g_clear_pointer (&contents, g_free);
f42647
 
f42647
         /* Poor-man's check for truthy or falsey values */
f42647
         *force_state = setup_argument[0] == '1';
f42647
 
f42647
         g_free (setup_argument);
f42647
         return TRUE;
2fc437
 }
2fc437
 
f42647
+static gboolean
2fc437
+initial_setup_disabled_by_anaconda (void)
2fc437
+{
2fc437
+        GKeyFile *key_file;
2fc437
+        const gchar *file_name = SYSCONFDIR "/sysconfig/anaconda";
2fc437
+        gboolean disabled = FALSE;
2fc437
+        GError *error = NULL;
2fc437
+
2fc437
+        key_file = g_key_file_new ();
2fc437
+        if (!g_key_file_load_from_file (key_file, file_name, G_KEY_FILE_NONE, &error)) {
2fc437
+                if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT) &&
2fc437
+                    !g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND)) {
2fc437
+                        g_warning ("Could not read %s: %s", file_name, error->message);
2fc437
+                }
2fc437
+                g_error_free (error);
2fc437
+                goto out;
2fc437
+        }
2fc437
+
2fc437
+        disabled = g_key_file_get_boolean (key_file, "General",
2fc437
+                                           "post_install_tools_disabled", NULL);
2fc437
+ out:
2fc437
+        g_key_file_unref (key_file);
2fc437
+        return disabled;
2fc437
+}
2fc437
+
f42647
 static gboolean
2fc437
 wants_initial_setup (GdmDisplay *self)
2fc437
 {
2fc437
         gboolean enabled = FALSE;
f42647
         gboolean forced = FALSE;
f42647
 
f42647
         if (already_done_initial_setup_on_this_boot ()) {
f42647
                 return FALSE;
f42647
         }
f42647
 
f42647
         if (kernel_cmdline_initial_setup_force_state (&forced)) {
f42647
                 if (forced) {
f42647
                         g_debug ("GdmDisplay: Forcing gnome-initial-setup");
f42647
                         return TRUE;
f42647
                 }
f42647
 
f42647
                 g_debug ("GdmDisplay: Forceing no gnome-initial-setup");
f42647
                 return FALSE;
f42647
         }
f42647
 
f42647
         /* don't run initial-setup on remote displays
f42647
          */
f42647
         if (!self->priv->is_local) {
f42647
                 return FALSE;
f42647
         }
f42647
 
f42647
         /* don't run if the system has existing users */
f42647
         if (self->priv->have_existing_user_accounts) {
f42647
                 return FALSE;
f42647
         }
f42647
 
f42647
         /* don't run if initial-setup is unavailable */
f42647
         if (!can_create_environment ("gnome-initial-setup")) {
f42647
                 return FALSE;
f42647
         }
f42647
 
f42647
         if (!gdm_settings_direct_get_boolean (GDM_KEY_INITIAL_SETUP_ENABLE, &enabled)) {
2fc437
                 return FALSE;
2fc437
         }
2fc437
 
2fc437
+        if (initial_setup_disabled_by_anaconda ()) {
2fc437
+                return FALSE;
2fc437
+        }
2fc437
+
2fc437
         return enabled;
2fc437
 }
2fc437
 
f42647
 void
f42647
 gdm_display_start_greeter_session (GdmDisplay *self)
f42647
 {
f42647
         GdmSession    *session;
f42647
         char          *display_name;
f42647
         char          *seat_id;
f42647
         char          *hostname;
f42647
         char          *auth_file = NULL;
f42647
 
f42647
         g_return_if_fail (g_strcmp0 (self->priv->session_class, "greeter") == 0);
f42647
 
f42647
         g_debug ("GdmDisplay: Running greeter");
f42647
 
f42647
         display_name = NULL;
f42647
         seat_id = NULL;
f42647
         hostname = NULL;
f42647
 
f42647
         g_object_get (self,
f42647
                       "x11-display-name", &display_name,
f42647
                       "seat-id", &seat_id,
f42647
                       "remote-hostname", &hostname,
f42647
                       NULL);
f42647
         if (self->priv->access_file != NULL) {
f42647
                 auth_file = gdm_display_access_file_get_path (self->priv->access_file);
f42647
         }
f42647
 
f42647
         g_debug ("GdmDisplay: Creating greeter for %s %s", display_name, hostname);
2fc437
-- 
f42647
2.14.2
2fc437