summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-10-27 14:56:05 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-11-24 11:42:25 +1100
commita055f6714fd06aa3b633b1bc44a8dbf42a0eedb0 (patch)
tree6223076e8bcfe2c828f4b40d6a4fb8760f520c7b /discover
parent1dd51e986202e5e111c1042f148867bd08c2bedc (diff)
downloadtalos-petitboot-a055f6714fd06aa3b633b1bc44a8dbf42a0eedb0.tar.gz
talos-petitboot-a055f6714fd06aa3b633b1bc44a8dbf42a0eedb0.zip
Support HTTP(S) proxies when downloading resources
Allow the user to specify a HTTP and HTTPS proxy server. The discover server will set the http_proxy and https_proxy environment variables, enabling the proxy servers for any further HTTP(S) requests. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover')
-rw-r--r--discover/platform-powerpc.c29
-rw-r--r--discover/platform.c7
2 files changed, 36 insertions, 0 deletions
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index a4b13e4..77e8824 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -60,6 +60,8 @@ static const char *known_params[] = {
"petitboot,write?",
"petitboot,snapshots?",
"petitboot,console",
+ "petitboot,http_proxy",
+ "petitboot,https_proxy",
NULL,
};
@@ -525,6 +527,19 @@ static void populate_bootdev_config(struct platform_powerpc *platform,
config->n_autoboot_opts = 1;
}
+static void set_proxy_variables(struct config *config)
+{
+ if (config->http_proxy)
+ setenv("http_proxy", config->http_proxy, 1);
+ else
+ unsetenv("http_proxy");
+
+ if (config->https_proxy)
+ setenv("https_proxy", config->https_proxy, 1);
+ else
+ unsetenv("https_proxy");
+}
+
static void populate_config(struct platform_powerpc *platform,
struct config *config)
{
@@ -573,6 +588,14 @@ static void populate_config(struct platform_powerpc *platform,
/* If a full path is already set we don't want to override it */
config->manual_console = config->boot_console &&
!strchr(config->boot_console, '[');
+
+ val = get_param(platform, "petitboot,http_proxy");
+ if (val)
+ config->http_proxy = talloc_strdup(config, val);
+ val = get_param(platform, "petitboot,https_proxy");
+ if (val)
+ config->https_proxy = talloc_strdup(config, val);
+ set_proxy_variables(config);
}
static char *iface_config_str(void *ctx, struct interface_config *config)
@@ -754,6 +777,12 @@ static int update_config(struct platform_powerpc *platform,
update_string_config(platform, "petitboot,console", val);
}
+ val = config->http_proxy ?: "";
+ update_string_config(platform, "petitboot,http_proxy", val);
+ val = config->https_proxy ?: "";
+ update_string_config(platform, "petitboot,https_proxy", val);
+ set_proxy_variables(config);
+
update_network_config(platform, config);
update_bootdev_config(platform, config);
diff --git a/discover/platform.c b/discover/platform.c
index 93cd057..cc6306f 100644
--- a/discover/platform.c
+++ b/discover/platform.c
@@ -87,6 +87,11 @@ static void dump_config(struct config *config)
if (config->manual_console)
pb_log(" (Manually set)\n");
+ if (config->http_proxy)
+ pb_log(" HTTP Proxy: %s\n", config->http_proxy);
+ if (config->https_proxy)
+ pb_log(" HTTPS Proxy: %s\n", config->https_proxy);
+
pb_log(" language: %s\n", config->lang ?: "");
}
@@ -121,6 +126,8 @@ void config_set_defaults(struct config *config)
config->network.n_interfaces = 0;
config->network.dns_servers = NULL;
config->network.n_dns_servers = 0;
+ config->http_proxy = NULL;
+ config->https_proxy = NULL;
config->safe_mode = false;
config->allow_writes = true;
config->disable_snapshots = false;
OpenPOWER on IntegriCloud