Blob Blame History Raw
From 0eb339c99a851f4b8358c034fb3069a3543732cd Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 24 Jan 2017 19:19:30 +0100
Subject: [PATCH 1/3] summary: Move stamp file creation to a global function

This will be useful in other places. Note that the "done" stamp file
is now created in both existing user and new user modes.

https://bugzilla.gnome.org/show_bug.cgi?id=777707
---
 gnome-initial-setup/gnome-initial-setup.c          | 21 +++++++++++++++++
 gnome-initial-setup/gnome-initial-setup.h          |  2 ++
 .../pages/summary/gis-summary-page.c               | 26 +---------------------
 3 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 396bbea..2ec91b9 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -242,3 +242,24 @@ main (int argc, char *argv[])
   g_option_context_free (context);
   return status;
 }
+
+void
+gis_ensure_stamp_files (void)
+{
+  gchar *file;
+  GError *error = NULL;
+
+  file = g_build_filename (g_get_user_config_dir (), "run-welcome-tour", NULL);
+  if (!g_file_set_contents (file, "yes", -1, &error)) {
+      g_warning ("Unable to create %s: %s", file, error->message);
+      g_clear_error (&error);
+  }
+  g_free (file);
+
+  file = g_build_filename (g_get_user_config_dir (), "gnome-initial-setup-done", NULL);
+  if (!g_file_set_contents (file, "yes", -1, &error)) {
+      g_warning ("Unable to create %s: %s", file, error->message);
+      g_clear_error (&error);
+  }
+  g_free (file);
+}
diff --git a/gnome-initial-setup/gnome-initial-setup.h b/gnome-initial-setup/gnome-initial-setup.h
index 6dce853..dc5cf60 100644
--- a/gnome-initial-setup/gnome-initial-setup.h
+++ b/gnome-initial-setup/gnome-initial-setup.h
@@ -35,5 +35,7 @@ typedef struct _GisPage      GisPage;
 #include "gis-page.h"
 #include "gis-keyring.h"
 
+void gis_ensure_stamp_files (void);
+
 #endif /* __GNOME_INITIAL_SETUP_H__ */
 
diff --git a/gnome-initial-setup/pages/summary/gis-summary-page.c b/gnome-initial-setup/pages/summary/gis-summary-page.c
index db54924..6260181 100644
--- a/gnome-initial-setup/pages/summary/gis-summary-page.c
+++ b/gnome-initial-setup/pages/summary/gis-summary-page.c
@@ -214,32 +214,9 @@ log_user_in (GisSummaryPage *page)
 }
 
 static void
-add_setup_done_file (void)
-{
-  gchar *gis_done_path;
-  GError *error = NULL;
-
-  gis_done_path = g_build_filename (g_get_user_config_dir (),
-                                    "gnome-initial-setup-done",
-                                    NULL);
-
-  if (!g_file_set_contents (gis_done_path, "yes", -1, &error)) {
-      g_warning ("Unable to create %s: %s", gis_done_path, error->message);
-      g_clear_error (&error);
-  }
-
-  g_free (gis_done_path);
-}
-
-static void
 done_cb (GtkButton *button, GisSummaryPage *page)
 {
-  gchar *file;
-
-  /* the tour is triggered by $XDG_CONFIG_HOME/run-welcome-tour */
-  file = g_build_filename (g_get_user_config_dir (), "run-welcome-tour", NULL);
-  g_file_set_contents (file, "yes", -1, NULL);
-  g_free (file);
+  gis_ensure_stamp_files ();
 
   switch (gis_driver_get_mode (GIS_PAGE (page)->driver))
     {
@@ -248,7 +225,6 @@ done_cb (GtkButton *button, GisSummaryPage *page)
       log_user_in (page);
       break;
     case GIS_DRIVER_MODE_EXISTING_USER:
-      add_setup_done_file ();
       g_application_quit (G_APPLICATION (GIS_PAGE (page)->driver));
     default:
       break;
-- 
2.9.3

From 09dcc40cf61e68dddbe7720e3f60c639107ceb37 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 24 Jan 2017 19:22:09 +0100
Subject: [PATCH 2/3] copy-worker: Copy the "done" stamp file too

For consistency, instead of creating the "done" stamp file here, we
can let g-i-s handle that and just copy it along with all the others.

https://bugzilla.gnome.org/show_bug.cgi?id=777707
---
 gnome-initial-setup/gnome-initial-setup-copy-worker.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/gnome-initial-setup/gnome-initial-setup-copy-worker.c b/gnome-initial-setup/gnome-initial-setup-copy-worker.c
index 500d274..c041399 100644
--- a/gnome-initial-setup/gnome-initial-setup-copy-worker.c
+++ b/gnome-initial-setup/gnome-initial-setup-copy-worker.c
@@ -71,9 +71,7 @@ main (int    argc,
 {
   GFile *src;
   GFile *dest;
-  GError *error = NULL;
   char *initial_setup_homedir;
-  gchar *gis_done_file_path;
 
   initial_setup_homedir = get_gnome_initial_setup_home_dir ();
   if (initial_setup_homedir == NULL)
@@ -90,17 +88,11 @@ main (int    argc,
 #define FILE(path) \
   move_file_from_homedir (src, dest, path);
 
+  FILE (".config/gnome-initial-setup-done");
   FILE (".config/run-welcome-tour");
   FILE (".config/dconf/user");
   FILE (".config/goa-1.0/accounts.conf");
   FILE (".local/share/keyrings/login.keyring");
 
-  gis_done_file_path = g_build_filename (g_get_user_config_dir (),
-                                         "gnome-initial-setup-done",
-                                         NULL);
-
-  if (!g_file_set_contents (gis_done_file_path, "yes", -1, &error))
-    g_warning ("Unable to create %s: %s", gis_done_file_path, error->message);
-
   return EXIT_SUCCESS;
 }
-- 
2.9.3

From 76e7cb35eab553e555aecb481bc6c791ce8f53fc Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Mon, 23 Jan 2017 19:42:44 +0100
Subject: [PATCH 3/3] Exit gracefully if we are disabled systemwide

Sysadmins might want to disable any kind of initial setup for their
users, perhaps because they pre-configure their environments. We
should provide an easy way to do it.

At least the anaconda installer provides an option to skip any kind
post-install setup tools so, for now we're only adding support for
that but more might be added in the future.

https://bugzilla.gnome.org/show_bug.cgi?id=777707
---
 gnome-initial-setup/gnome-initial-setup.c | 34 +++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 2ec91b9..0338aa0 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -186,6 +186,31 @@ get_mode (void)
     return GIS_DRIVER_MODE_NEW_USER;
 }
 
+static gboolean
+initial_setup_disabled_by_anaconda (void)
+{
+  GKeyFile *key_file;
+  const gchar *file_name = "/etc/sysconfig/anaconda";
+  gboolean disabled = FALSE;
+  GError *error = NULL;
+
+  key_file = g_key_file_new ();
+  if (!g_key_file_load_from_file (key_file, file_name, G_KEY_FILE_NONE, &error)) {
+    if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT) &&
+        !g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND)) {
+      g_warning ("Could not read %s: %s", file_name, error->message);
+    }
+    g_error_free (error);
+    goto out;
+  }
+
+  disabled = g_key_file_get_boolean (key_file, "General",
+                                     "post_install_tools_disabled", NULL);
+ out:
+  g_key_file_unref (key_file);
+  return disabled;
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -226,6 +251,15 @@ main (int argc, char *argv[])
 
   mode = get_mode ();
 
+  /* We only do this in existing-user mode, because if gdm launches us
+   * in new-user mode and we just exit, gdm's special g-i-s session
+   * never terminates. */
+  if (initial_setup_disabled_by_anaconda () &&
+      mode == GIS_DRIVER_MODE_EXISTING_USER) {
+    gis_ensure_stamp_files ();
+    exit (EXIT_SUCCESS);
+  }
+
   /* When we are running as the gnome-initial-setup user we
    * dont have a normal user session and need to initialize
    * the keyring manually so that we can pass the credentials
-- 
2.9.3