gnome-initial-setup/0004-gnome-initial-setup-Add-OEM-mode.patch

351 lines
12 KiB
Diff
Raw Normal View History

From 17d62c9450b38fa492c245ec3da8ebd5f9a001dc Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 13 Aug 2023 10:30:11 -0400
Subject: [PATCH 4/5] gnome-initial-setup: Add OEM mode
OEM mode is designed to get run when a site has imaged a bunch
of machines, and handed them off to the user.
In this scenario, the user never saw the installer, so we need to
ask the user questions that the installer would have normally
asked them already.
For example, the installer likely asks language, but if the user
never saw the installer, then we need to ask language again.
---
gnome-initial-setup/gis-driver.c | 1 +
gnome-initial-setup/gis-driver.h | 5 +++--
gnome-initial-setup/gnome-initial-setup.c | 22 ++++++++++++++--------
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/gnome-initial-setup/gis-driver.c b/gnome-initial-setup/gis-driver.c
index 75ceac76..d7a69fe1 100644
--- a/gnome-initial-setup/gis-driver.c
+++ b/gnome-initial-setup/gis-driver.c
@@ -20,60 +20,61 @@
*/
#include "config.h"
#include "gnome-initial-setup.h"
#include <errno.h>
#include <locale.h>
#include <stdlib.h>
#ifdef HAVE_WEBKITGTK_6_0
#include <webkit/webkit.h>
#else
#include <webkit2/webkit2.h>
#endif
#include "cc-common-language.h"
#include "gis-assistant.h"
/* Statically include this for now. Maybe later
* we'll generate this from glib-mkenums. */
GType
gis_driver_mode_get_type (void) {
static GType enum_type_id = 0;
if (G_UNLIKELY (!enum_type_id))
{
static const GFlagsValue values[] = {
{ GIS_DRIVER_MODE_NEW_USER, "GIS_DRIVER_MODE_NEW_USER", "new_user" },
{ GIS_DRIVER_MODE_EXISTING_USER, "GIS_DRIVER_MODE_EXISTING_USER", "existing_user" },
{ GIS_DRIVER_MODE_LIVE_USER, "GIS_DRIVER_MODE_LIVE_USER", "live_user" },
+ { GIS_DRIVER_MODE_OEM, "GIS_DRIVER_MODE_OEM", "oem" },
{ GIS_DRIVER_MODE_SYSTEM, "GIS_DRIVER_MODE_SYSTEM", "system" },
{ GIS_DRIVER_MODE_ALL, "GIS_DRIVER_MODE_ALL", "all" },
{ 0, NULL, NULL }
};
enum_type_id = g_flags_register_static("GisDriverMode", values);
}
return enum_type_id;
}
enum {
REBUILD_PAGES,
LOCALE_CHANGED,
LAST_SIGNAL,
};
static guint signals[LAST_SIGNAL];
typedef enum {
PROP_MODE = 1,
PROP_USERNAME,
PROP_SMALL_SCREEN,
PROP_PARENTAL_CONTROLS_ENABLED,
PROP_FULL_NAME,
PROP_AVATAR,
} GisDriverProperty;
static GParamSpec *obj_props[PROP_AVATAR + 1];
struct _GisDriver {
AdwApplication parent_instance;
diff --git a/gnome-initial-setup/gis-driver.h b/gnome-initial-setup/gis-driver.h
index aedb9a73..49639bef 100644
--- a/gnome-initial-setup/gis-driver.h
+++ b/gnome-initial-setup/gis-driver.h
@@ -18,62 +18,63 @@
* Written by:
* Jasper St. Pierre <jstpierre@mecheye.net>
*/
#ifndef __GIS_DRIVER_H__
#define __GIS_DRIVER_H__
#include "gis-assistant.h"
#include "gis-page.h"
#include <act/act-user-manager.h>
#include <gdm/gdm-client.h>
#include <adwaita.h>
G_BEGIN_DECLS
#define GIS_TYPE_DRIVER (gis_driver_get_type ())
#define GIS_TYPE_DRIVER_MODE (gis_driver_mode_get_type ())
G_DECLARE_FINAL_TYPE (GisDriver, gis_driver, GIS, DRIVER, AdwApplication)
typedef enum {
UM_LOCAL,
UM_ENTERPRISE,
NUM_MODES,
} UmAccountMode;
typedef enum {
GIS_DRIVER_MODE_NEW_USER = 1 << 0,
GIS_DRIVER_MODE_EXISTING_USER = 1 << 1,
GIS_DRIVER_MODE_LIVE_USER = 1 << 2,
- GIS_DRIVER_MODE_SYSTEM = (GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_LIVE_USER),
- GIS_DRIVER_MODE_ALL = (GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER | GIS_DRIVER_MODE_LIVE_USER),
+ GIS_DRIVER_MODE_OEM = 1 << 3,
+ GIS_DRIVER_MODE_SYSTEM = (GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_LIVE_USER | GIS_DRIVER_MODE_OEM),
+ GIS_DRIVER_MODE_ALL = (GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER | GIS_DRIVER_MODE_LIVE_USER | GIS_DRIVER_MODE_OEM),
} GisDriverMode;
GType gis_driver_mode_get_type (void);
GisAssistant *gis_driver_get_assistant (GisDriver *driver);
void gis_driver_set_user_permissions (GisDriver *driver,
ActUser *user,
const gchar *password);
void gis_driver_get_user_permissions (GisDriver *driver,
ActUser **user,
const gchar **password);
void gis_driver_set_parent_permissions (GisDriver *driver,
ActUser *parent,
const gchar *password);
void gis_driver_get_parent_permissions (GisDriver *driver,
ActUser **parent,
const gchar **password);
void gis_driver_set_account_mode (GisDriver *driver,
UmAccountMode mode);
UmAccountMode gis_driver_get_account_mode (GisDriver *driver);
void gis_driver_set_parental_controls_enabled (GisDriver *driver,
gboolean parental_controls_enabled);
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 68f00f47..3e4c2c03 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -24,90 +24,91 @@
#include "gnome-initial-setup.h"
#include <adwaita.h>
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
#include <glib/gi18n.h>
#include "pages/welcome/gis-welcome-page.h"
#include "pages/language/gis-language-page.h"
#include "pages/keyboard/gis-keyboard-page.h"
#include "pages/network/gis-network-page.h"
#include "pages/timezone/gis-timezone-page.h"
#include "pages/privacy/gis-privacy-page.h"
#include "pages/software/gis-software-page.h"
#include "pages/goa/gis-goa-page.h"
#include "pages/account/gis-account-pages.h"
#include "pages/parental-controls/gis-parental-controls-page.h"
#include "pages/password/gis-password-page.h"
#include "pages/summary/gis-summary-page.h"
#include "pages/install/gis-install-page.h"
#define VENDOR_PAGES_GROUP "pages"
#define VENDOR_SKIP_KEY "skip"
#define VENDOR_NEW_USER_ONLY_KEY "new_user_only"
#define VENDOR_EXISTING_USER_ONLY_KEY "existing_user_only"
#define VENDOR_LIVE_USER_ONLY_KEY "live_user_only"
static gboolean force_existing_user_mode;
static gboolean force_live_user_mode;
+static gboolean force_oem_mode;
static GPtrArray *skipped_pages;
typedef GisPage *(*PreparePage) (GisDriver *driver);
typedef struct {
const gchar *page_id;
PreparePage prepare_page_func;
GisDriverMode modes;
} PageData;
#define PAGE(name, modes) { #name, gis_prepare_ ## name ## _page, modes }
static PageData page_table[] = {
PAGE (welcome, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER),
PAGE (language, GIS_DRIVER_MODE_ALL),
PAGE (keyboard, GIS_DRIVER_MODE_ALL),
PAGE (network, GIS_DRIVER_MODE_ALL),
- PAGE (privacy, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER),
+ PAGE (privacy, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER | GIS_DRIVER_MODE_OEM),
PAGE (timezone, GIS_DRIVER_MODE_ALL),
- PAGE (software, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER),
- PAGE (goa, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER),
+ PAGE (software, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER | GIS_DRIVER_MODE_OEM),
+ PAGE (goa, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER | GIS_DRIVER_MODE_OEM),
/* In live user mode, the account page isn't displayed, it just quietly creates the live user */
- PAGE (account, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_LIVE_USER),
- PAGE (password, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_LIVE_USER),
+ PAGE (account, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_LIVE_USER | GIS_DRIVER_MODE_OEM),
+ PAGE (password, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_LIVE_USER | GIS_DRIVER_MODE_OEM),
#ifdef HAVE_PARENTAL_CONTROLS
- PAGE (parental_controls, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER),
- PAGE (parent_password, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER),
+ PAGE (parental_controls, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER | GIS_DRIVER_MODE_OEM),
+ PAGE (parent_password, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_EXISTING_USER | GIS_DRIVER_MODE_OEM),
#endif
- PAGE (summary, GIS_DRIVER_MODE_NEW_USER),
+ PAGE (summary, GIS_DRIVER_MODE_NEW_USER | GIS_DRIVER_MODE_OEM),
PAGE (install, GIS_DRIVER_MODE_LIVE_USER),
{ NULL },
};
#undef PAGE
static gboolean
should_skip_page (const gchar *page_id,
gchar **skip_pages)
{
guint i = 0;
/* special case welcome. We only want to show it if language
* is skipped
*/
if (strcmp (page_id, "welcome") == 0)
return !should_skip_page ("language", skip_pages);
/* check through our skip pages list for pages we don't want */
if (skip_pages) {
while (skip_pages[i]) {
if (g_strcmp0 (skip_pages[i], page_id) == 0)
return TRUE;
i++;
}
}
return FALSE;
}
@@ -292,81 +293,86 @@ static gboolean
initial_setup_disabled_by_anaconda (void)
{
const gchar *file_name = SYSCONFDIR "/sysconfig/anaconda";
g_autoptr(GError) error = NULL;
g_autoptr(GKeyFile) 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);
}
return FALSE;
}
return g_key_file_get_boolean (key_file, "General", "post_install_tools_disabled", NULL);
}
int
main (int argc, char *argv[])
{
GisDriver *driver;
int status;
GOptionContext *context;
GisDriverMode mode;
GOptionEntry entries[] = {
{ "existing-user", 0, 0, G_OPTION_ARG_NONE, &force_existing_user_mode,
_("Force existing user mode"), NULL },
{ "live-user", 0, 0, G_OPTION_ARG_NONE, &force_live_user_mode,
_("Force live user mode"), NULL },
+ { "oem", 0, 0, G_OPTION_ARG_NONE, &force_oem_mode,
+ _("Force OEM mode"), NULL },
{ NULL }
};
g_unsetenv ("GIO_USE_VFS");
/* By default, libadwaita reads settings from the Settings portal, which causes
* the portal to be started, which causes gnome-keyring to be started. This
* interferes with our attempt below to manually start gnome-keyring and set
* the login keyring password to a well-known value, which we overwrite with
* the user's password once they choose one.
*/
g_setenv ("ADW_DISABLE_PORTAL", "1", TRUE);
context = g_option_context_new (_("— GNOME initial setup"));
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
if (gis_kernel_command_line_has_argument ((const char *[]) { "rd.live.image", "endless.live_boot", NULL }))
force_live_user_mode = TRUE;
+ if (gis_kernel_command_line_has_argument ((const char *[]) { "gnome.oem_mode", NULL }))
+ force_oem_mode = TRUE;
+
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
g_message ("Starting gnome-initial-setup");
if (gis_get_mock_mode ())
g_message ("Mock mode: changes will not be saved to disk");
else
g_message ("Production mode: changes will be saved to disk");
skipped_pages = g_ptr_array_new_with_free_func (destroy_page);
mode = get_mode ();
/* 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
* along to the new user in the handoff.
*/
if (mode == GIS_DRIVER_MODE_NEW_USER && !gis_get_mock_mode ())
gis_ensure_login_keyring ();
driver = gis_driver_new (mode);
adw_style_manager_set_color_scheme (adw_style_manager_get_default (),
ADW_COLOR_SCHEME_PREFER_LIGHT);
/* On first login, GNOME Shell offers to run a tour. If we also run Initial
* Setup, the two immovable, centred windows will sit atop one another.
* Until we have the ability to run Initial Setup in the "kiosk" mode, like
* it does in new-user mode, disable Initial Setup for existing users.
*
--
2.41.0