]> git.ozlabs.org Git - petitboot/commitdiff
discover: Update env vars at init and suppress LVM warnings
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 22 Aug 2017 01:41:09 +0000 (11:41 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 22 Aug 2017 05:17:42 +0000 (15:17 +1000)
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>
discover/device-handler.c
discover/platform-powerpc.c

index f1270c8ca660b7c771f0e08023e4559345f1e5bc..ce3fc465ec03fadef829052eda8fe1ad8644ed7a 100644 (file)
@@ -338,6 +338,22 @@ const char *discover_device_get_param(struct discover_device *device,
        return NULL;
 }
 
        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)
 {
 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;
 
        if (config_get()->safe_mode)
                return handler;
 
+       set_env_variables(config_get());
+
        rc = device_handler_init_sources(handler);
        if (rc) {
                talloc_free(handler);
        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);
 
 
        discover_server_notify_plugins_remove(handler->server);
 
+       set_env_variables(config_get());
+
        device_handler_reinit_sources(handler);
 }
 
        device_handler_reinit_sources(handler);
 }
 
index a4b955ef6fd48e3c2daa72cf2696b4e6f9f8159d..02d9a207e707463424bb855fb20823f03bc0acc5 100644 (file)
@@ -492,19 +492,6 @@ static void populate_bootdev_config(struct platform_powerpc *platform,
        config->n_autoboot_opts = n_new;
 }
 
        config->n_autoboot_opts = n_new;
 }
 
-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)
 {
 static void populate_config(struct platform_powerpc *platform,
                struct config *config)
 {
@@ -560,7 +547,6 @@ static void populate_config(struct platform_powerpc *platform,
        val = get_param(platform, "petitboot,https_proxy");
        if (val)
                config->https_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)
 }
 
 static char *iface_config_str(void *ctx, struct interface_config *config)
@@ -740,7 +726,6 @@ static int update_config(struct platform_powerpc *platform,
        update_string_config(platform, "petitboot,http_proxy", val);
        val = config->https_proxy ?: "";
        update_string_config(platform, "petitboot,https_proxy", val);
        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_network_config(platform, config);