Common-init reads config file and export custom environment variables from config file and apply them to the running sandbox. --- libvirt-sandbox/libvirt-sandbox-init-common.c | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libvirt-sandbox/libvirt-sandbox-init-common.c b/libvirt-sandbox/libvirt-sandbox-init-common.c index d35f760..0b0aa98 100644 --- a/libvirt-sandbox/libvirt-sandbox-init-common.c +++ b/libvirt-sandbox/libvirt-sandbox-init-common.c @@ -336,6 +336,33 @@ static gboolean setup_network(GVirSandboxConfig *config, GError **error) } +static gboolean setup_custom_env(GVirSandboxConfig *config, GError **error) +{ + GList *envs, *tmp; + gboolean ret = FALSE; + gchar *key = NULL; + gchar *value = NULL; + + envs = tmp = gvir_sandbox_config_get_envs(config); + + while (tmp) { + GVirSandboxConfigEnv *env = GVIR_SANDBOX_CONFIG_ENV(tmp->data); + key = g_strdup(gvir_sandbox_config_env_get_key(env)); + value = g_strdup(gvir_sandbox_config_env_get_value(env)); + if(setenv(key,value,1)!=0) + goto cleanup; + g_free(key); + g_free(value); + tmp = tmp->next; + } + + ret = TRUE; + cleanup: + g_list_foreach(envs, (GFunc)g_object_unref, NULL); + g_list_free(envs); + return ret; +} + static int change_user(const gchar *user, uid_t uid, gid_t gid, @@ -1262,6 +1289,9 @@ int main(int argc, char **argv) { if (!setup_disk_tags()) exit(EXIT_FAILURE); + if (!setup_custom_env(config, &error)) + goto error; + if (!setup_network(config, &error)) goto error; -- 2.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list