|
|
b39623 |
From 08fb8316b4ac42fe74c1fa5ca0ac593222cdf81a Mon Sep 17 00:00:00 2001
|
|
|
b39623 |
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
|
|
|
b39623 |
Date: Wed, 3 Jul 2019 14:55:24 +0200
|
|
|
b39623 |
Subject: [PATCH] tools,install-script: Add --config-file (-f) option
|
|
|
b39623 |
MIME-Version: 1.0
|
|
|
b39623 |
Content-Type: text/plain; charset=UTF-8
|
|
|
b39623 |
Content-Transfer-Encoding: 8bit
|
|
|
b39623 |
|
|
|
b39623 |
Let's add a new option so users can set their config from a file,
|
|
|
b39623 |
instead of directly passing the values via command-line.
|
|
|
b39623 |
|
|
|
b39623 |
CVE-2019-13313
|
|
|
b39623 |
Libosinfo: osinfo-install-script option leaks password via command line
|
|
|
b39623 |
argument. 'osinfo-install-script' is used to generate a script for
|
|
|
b39623 |
automated guest installations. It accepts user and admin passwords via
|
|
|
b39623 |
command line arguments, thus leaking them via process listing.
|
|
|
b39623 |
|
|
|
b39623 |
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
|
|
|
b39623 |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
b39623 |
---
|
|
|
b39623 |
tools/osinfo-install-script.c | 103 +++++++++++++++++++++++++++++++++-
|
|
|
b39623 |
1 file changed, 102 insertions(+), 1 deletion(-)
|
|
|
b39623 |
|
|
|
b39623 |
diff --git a/tools/osinfo-install-script.c b/tools/osinfo-install-script.c
|
|
|
b39623 |
index 15af48d..af58440 100644
|
|
|
b39623 |
--- a/tools/osinfo-install-script.c
|
|
|
b39623 |
+++ b/tools/osinfo-install-script.c
|
|
|
b39623 |
@@ -37,6 +37,34 @@ static gboolean list_profile = FALSE;
|
|
|
b39623 |
static gboolean list_inj_method = FALSE;
|
|
|
b39623 |
static gboolean quiet = FALSE;
|
|
|
b39623 |
|
|
|
b39623 |
+static const gchar *configs[] = {
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_HARDWARE_ARCH,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_L10N_TIMEZONE,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_L10N_LANGUAGE,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_L10N_KEYBOARD,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_ADMIN_PASSWORD,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_USER_PASSWORD,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_USER_LOGIN,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_USER_REALNAME,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_USER_AUTOLOGIN,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_USER_ADMIN,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_REG_LOGIN,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_REG_PASSWORD,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_REG_PRODUCTKEY,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_HOSTNAME,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_TARGET_DISK,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_SCRIPT_DISK,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_AVATAR_LOCATION,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_AVATAR_DISK,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_PRE_INSTALL_DRIVERS_DISK,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_PRE_INSTALL_DRIVERS_LOCATION,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_POST_INSTALL_DRIVERS_DISK,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_POST_INSTALL_DRIVERS_LOCATION,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_DRIVER_SIGNING,
|
|
|
b39623 |
+ OSINFO_INSTALL_CONFIG_PROP_INSTALLATION_URL,
|
|
|
b39623 |
+ NULL
|
|
|
b39623 |
+};
|
|
|
b39623 |
+
|
|
|
b39623 |
static OsinfoInstallConfig *config;
|
|
|
b39623 |
|
|
|
b39623 |
static gboolean handle_config(const gchar *option_name G_GNUC_UNUSED,
|
|
|
b39623 |
@@ -65,6 +93,47 @@ static gboolean handle_config(const gchar *option_name G_GNUC_UNUSED,
|
|
|
b39623 |
}
|
|
|
b39623 |
|
|
|
b39623 |
|
|
|
b39623 |
+static gboolean handle_config_file(const gchar *option_name G_GNUC_UNUSED,
|
|
|
b39623 |
+ const gchar *value,
|
|
|
b39623 |
+ gpointer data G_GNUC_UNUSED,
|
|
|
b39623 |
+ GError **error)
|
|
|
b39623 |
+{
|
|
|
b39623 |
+ GKeyFile *key_file = NULL;
|
|
|
b39623 |
+ gchar *val = NULL;
|
|
|
b39623 |
+ gsize i;
|
|
|
b39623 |
+ gboolean ret = FALSE;
|
|
|
b39623 |
+
|
|
|
b39623 |
+ key_file = g_key_file_new();
|
|
|
b39623 |
+ if (!g_key_file_load_from_file(key_file, value, G_KEY_FILE_NONE, error))
|
|
|
b39623 |
+ goto error;
|
|
|
b39623 |
+
|
|
|
b39623 |
+ for (i = 0; configs[i] != NULL; i++) {
|
|
|
b39623 |
+ val = g_key_file_get_string(key_file, "install-script", configs[i], error);
|
|
|
b39623 |
+ if (val == NULL) {
|
|
|
b39623 |
+ if (g_error_matches(*error, G_KEY_FILE_ERROR,
|
|
|
b39623 |
+ G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
|
|
|
b39623 |
+ g_clear_error(error);
|
|
|
b39623 |
+ continue;
|
|
|
b39623 |
+ }
|
|
|
b39623 |
+
|
|
|
b39623 |
+ goto error;
|
|
|
b39623 |
+ }
|
|
|
b39623 |
+
|
|
|
b39623 |
+ osinfo_entity_set_param(OSINFO_ENTITY(config),
|
|
|
b39623 |
+ configs[i],
|
|
|
b39623 |
+ val);
|
|
|
b39623 |
+ g_free(val);
|
|
|
b39623 |
+ }
|
|
|
b39623 |
+
|
|
|
b39623 |
+ ret = TRUE;
|
|
|
b39623 |
+
|
|
|
b39623 |
+error:
|
|
|
b39623 |
+ g_key_file_unref(key_file);
|
|
|
b39623 |
+
|
|
|
b39623 |
+ return ret;
|
|
|
b39623 |
+}
|
|
|
b39623 |
+
|
|
|
b39623 |
+
|
|
|
b39623 |
static GOptionEntry entries[] =
|
|
|
b39623 |
{
|
|
|
b39623 |
{ "profile", 'p', 0, G_OPTION_ARG_STRING, (void*)&profile,
|
|
|
b39623 |
@@ -78,6 +147,9 @@ static GOptionEntry entries[] =
|
|
|
b39623 |
{ "config", 'c', 0, G_OPTION_ARG_CALLBACK,
|
|
|
b39623 |
handle_config,
|
|
|
b39623 |
N_("Set configuration parameter"), "key=value" },
|
|
|
b39623 |
+ { "config-file", 'f', 0, G_OPTION_ARG_CALLBACK,
|
|
|
b39623 |
+ handle_config_file,
|
|
|
b39623 |
+ N_("Set configuration parameters"), "file:///path/to/config/file" },
|
|
|
b39623 |
{ "list-config", '\0', 0, G_OPTION_ARG_NONE, (void*)&list_config,
|
|
|
b39623 |
N_("List configuration parameters"), NULL },
|
|
|
b39623 |
{ "list-profiles", '\0', 0, G_OPTION_ARG_NONE, (void*)&list_profile,
|
|
|
b39623 |
@@ -448,6 +520,15 @@ script. Defaults to C<media>, but can also be C<network>.
|
|
|
b39623 |
|
|
|
b39623 |
Set the configuration parameter C<key> to C<value>.
|
|
|
b39623 |
|
|
|
b39623 |
+=item B<--config-file=config-file>
|
|
|
b39623 |
+
|
|
|
b39623 |
+Set the configurations parameters according to the config-file passed.
|
|
|
b39623 |
+
|
|
|
b39623 |
+Note that use of --config-file is strongly recommended if the user or
|
|
|
b39623 |
+admin passwords need to be set. Providing passwords directly using
|
|
|
b39623 |
+B<--config=> is insecure as the password is visible to all processes
|
|
|
b39623 |
+and users on the same host.
|
|
|
b39623 |
+
|
|
|
b39623 |
=back
|
|
|
b39623 |
|
|
|
b39623 |
=head1 CONFIGURATION KEYS
|
|
|
b39623 |
@@ -510,9 +591,29 @@ The software registration user password
|
|
|
b39623 |
|
|
|
b39623 |
=back
|
|
|
b39623 |
|
|
|
b39623 |
+=head1 CONFIGURATION FILE FORMAT
|
|
|
b39623 |
+
|
|
|
b39623 |
+The configuration file must consist in a file which contains a
|
|
|
b39623 |
+`install-script` group and, under this group, C<key>=C<value>
|
|
|
b39623 |
+pairs, as shown below:
|
|
|
b39623 |
+
|
|
|
b39623 |
+[install-script]
|
|
|
b39623 |
+l10n-timezone=GMT
|
|
|
b39623 |
+l10n-keyboard=uk
|
|
|
b39623 |
+l10n-language=en_GB
|
|
|
b39623 |
+admin-password=123456
|
|
|
b39623 |
+user-login=berrange
|
|
|
b39623 |
+user-password=123456
|
|
|
b39623 |
+user-realname="Daniel P Berrange"
|
|
|
b39623 |
+
|
|
|
b39623 |
=head1 EXAMPLE USAGE
|
|
|
b39623 |
|
|
|
b39623 |
-The following usage generates a Fedora 16 kickstart script
|
|
|
b39623 |
+The following usages generates a Fedora 16 kickstart script
|
|
|
b39623 |
+
|
|
|
b39623 |
+ # osinfo-install-script \
|
|
|
b39623 |
+ --profile jeos \
|
|
|
b39623 |
+ --config-file /path/to/config/file \
|
|
|
b39623 |
+ fedora16
|
|
|
b39623 |
|
|
|
b39623 |
# osinfo-install-script \
|
|
|
b39623 |
--profile jeos \
|
|
|
b39623 |
--
|
|
|
b39623 |
2.21.0
|
|
|
b39623 |
|