54fb002
From fa5733788ae5f8e8caeb07e956be370e96f9b6b1 Mon Sep 17 00:00:00 2001
54fb002
From: Rui Matos <tiagomatos@gmail.com>
54fb002
Date: Mon, 23 Jan 2017 20:19:51 +0100
54fb002
Subject: [PATCH] Honor initial setup being disabled by distro installer
54fb002
54fb002
Sysadmins might want to disable any kind of initial setup for their
54fb002
users, perhaps because they pre-configure their environments. We
54fb002
already provide a configuration file option for this but distro
54fb002
installers might have their own way of requesting this.
54fb002
54fb002
At least the anaconda installer provides an option to skip any kind
54fb002
post-install setup tools so, for now we're only adding support for
54fb002
that but more might be added in the future.
54fb002
54fb002
https://bugzilla.gnome.org/show_bug.cgi?id=777708
54fb002
---
54fb002
 daemon/Makefile.am   |  1 +
54fb002
 daemon/gdm-display.c | 29 +++++++++++++++++++++++++++++
54fb002
 2 files changed, 30 insertions(+)
54fb002
54fb002
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
54fb002
index ab5dda0..786e0c5 100644
54fb002
--- a/daemon/Makefile.am
54fb002
+++ b/daemon/Makefile.am
54fb002
@@ -14,6 +14,7 @@ AM_CPPFLAGS = \
54fb002
 	-DLOCALSTATEDIR=\"$(localstatedir)\"		\
54fb002
 	-DLOGDIR=\"$(logdir)\"				\
54fb002
 	-DSBINDIR=\"$(sbindir)\"			\
54fb002
+	-DSYSCONFDIR=\"$(sysconfdir)\"			\
54fb002
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"	\
54fb002
 	-DGDM_RUN_DIR=\"$(GDM_RUN_DIR)\"		\
54fb002
 	-DGDM_XAUTH_DIR=\"$(GDM_XAUTH_DIR)\"		\
54fb002
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
54fb002
index 0057e2c..2af8e13 100644
54fb002
--- a/daemon/gdm-display.c
54fb002
+++ b/daemon/gdm-display.c
54fb002
@@ -1456,6 +1456,31 @@ can_create_environment (const char *session_id)
54fb002
 }
54fb002
 
54fb002
 static gboolean
54fb002
+initial_setup_disabled_by_anaconda (void)
54fb002
+{
54fb002
+        GKeyFile *key_file;
54fb002
+        const gchar *file_name = SYSCONFDIR "/sysconfig/anaconda";
54fb002
+        gboolean disabled = FALSE;
54fb002
+        GError *error = NULL;
54fb002
+
54fb002
+        key_file = g_key_file_new ();
54fb002
+        if (!g_key_file_load_from_file (key_file, file_name, G_KEY_FILE_NONE, &error)) {
54fb002
+                if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT) &&
54fb002
+                    !g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND)) {
54fb002
+                        g_warning ("Could not read %s: %s", file_name, error->message);
54fb002
+                }
54fb002
+                g_error_free (error);
54fb002
+                goto out;
54fb002
+        }
54fb002
+
54fb002
+        disabled = g_key_file_get_boolean (key_file, "General",
54fb002
+                                           "post_install_tools_disabled", NULL);
54fb002
+ out:
54fb002
+        g_key_file_unref (key_file);
54fb002
+        return disabled;
54fb002
+}
54fb002
+
54fb002
+static gboolean
54fb002
 wants_initial_setup (GdmDisplay *self)
54fb002
 {
54fb002
         gboolean enabled = FALSE;
54fb002
@@ -1480,6 +1505,10 @@ wants_initial_setup (GdmDisplay *self)
54fb002
                 return FALSE;
54fb002
         }
54fb002
 
54fb002
+        if (initial_setup_disabled_by_anaconda ()) {
54fb002
+                return FALSE;
54fb002
+        }
54fb002
+
54fb002
         return enabled;
54fb002
 }
54fb002
 
54fb002
-- 
54fb002
2.9.3
54fb002