[PATCH sandbox v5 18/20] init-common: Exporting custom environment variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Eren Yagdiran <erenyagdiran@xxxxxxxxx>

Common-init reads config file and exports custom environment
variables from config file and applies them to the running sandbox.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 libvirt-sandbox/libvirt-sandbox-init-common.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/libvirt-sandbox/libvirt-sandbox-init-common.c b/libvirt-sandbox/libvirt-sandbox-init-common.c
index e3e14a3..42beadc 100644
--- a/libvirt-sandbox/libvirt-sandbox-init-common.c
+++ b/libvirt-sandbox/libvirt-sandbox-init-common.c
@@ -348,6 +348,21 @@ static gboolean setup_network(GVirSandboxConfig *config, GError **error)
 }
 
 
+static gboolean setup_custom_env(GVirSandboxConfig *config, GError **error)
+{
+    gboolean ret = FALSE;
+    GHashTableIter iter;
+    gpointer key, value;
+    g_hash_table_iter_init (&iter, gvir_sandbox_config_get_envs(config));
+    while (g_hash_table_iter_next (&iter, &key, &value)){
+        if(setenv(key,value,1)!=0)
+            goto cleanup;
+    }
+    ret = TRUE;
+  cleanup:
+    return ret;
+}
+
 static int change_user(const gchar *user,
                        uid_t uid,
                        gid_t gid,
@@ -1436,6 +1451,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.4.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]