X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=4e1b3ca77fc0f447bfd0febfdf66db22c7121ed6;hp=94a3f1c847f09fd3c26e22c88edbfb42ac365924;hb=b9b5fa357e5921eb752e62f7146339007d9f767f;hpb=37feda62bd2835eabc779d275301a9b763521f7a diff --git a/discover/device-handler.c b/discover/device-handler.c index 94a3f1c..4e1b3ca 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -338,6 +339,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 +379,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); @@ -375,6 +394,7 @@ void device_handler_reinit(struct device_handler *handler) { struct discover_boot_option *opt, *tmp; struct ramdisk_device *ramdisk; + struct config *config; unsigned int i; device_handler_cancel_default(handler); @@ -420,6 +440,16 @@ void device_handler_reinit(struct device_handler *handler) discover_server_notify_plugins_remove(handler->server); + set_env_variables(config_get()); + + /* If the safe mode warning was active disable it now */ + if (config_get()->safe_mode) { + config = config_copy(handler, config_get()); + config->safe_mode = false; + config_set(config); + discover_server_notify_config(handler->server, config); + } + device_handler_reinit_sources(handler); } @@ -1563,6 +1593,10 @@ static void device_handler_update_lang(const char *lang) static int device_handler_init_sources(struct device_handler *handler) { /* init our device sources: udev, network and user events */ + handler->user_event = user_event_init(handler, handler->waitset); + if (!handler->user_event) + return -1; + handler->network = network_init(handler, handler->waitset, handler->dry_run); if (!handler->network) @@ -1572,10 +1606,6 @@ static int device_handler_init_sources(struct device_handler *handler) if (!handler->udev) return -1; - handler->user_event = user_event_init(handler, handler->waitset); - if (!handler->user_event) - return -1; - return 0; }