summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-08-22 11:41:09 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-08-22 15:17:42 +1000
commit3132110c344c60bbe648b5e1b0473bdec101d111 (patch)
tree52870fbeb249cebde279cecc4143761ed2b12573 /discover/device-handler.c
parentefcff0996d8c9a42e3bbef4a805ff65974684ff0 (diff)
downloadtalos-petitboot-3132110c344c60bbe648b5e1b0473bdec101d111.zip
talos-petitboot-3132110c344c60bbe648b5e1b0473bdec101d111.tar.gz
discover: Update env vars at init and suppress LVM warnings
Environment variables are not platform-specific so move set_proxy_variables to device-handler and call it at handler init. At the same time set LVM_SUPPRESS_FD_WARNINGS to ignore the "file descriptor leaked" warnings when calling LVM-utilities, since we must keep some file descriptors open in lib/process. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index f1270c8..ce3fc46 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -338,6 +338,22 @@ const char *discover_device_get_param(struct discover_device *device,
return NULL;
}
+static void set_env_variables(const 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");
+
+ /* Reduce noise in the log from LVM listing open file descriptors */
+ setenv("LVM_SUPPRESS_FD_WARNINGS", "1", 1);
+}
+
struct device_handler *device_handler_init(struct discover_server *server,
struct waitset *waitset, int dry_run)
{
@@ -362,6 +378,8 @@ struct device_handler *device_handler_init(struct discover_server *server,
if (config_get()->safe_mode)
return handler;
+ set_env_variables(config_get());
+
rc = device_handler_init_sources(handler);
if (rc) {
talloc_free(handler);
@@ -420,6 +438,8 @@ void device_handler_reinit(struct device_handler *handler)
discover_server_notify_plugins_remove(handler->server);
+ set_env_variables(config_get());
+
device_handler_reinit_sources(handler);
}
OpenPOWER on IntegriCloud