From 20c34a4312ef5f08850f1c7b22fe6d67ea8d5723 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Sat, 26 Mar 2016 11:39:36 +0800 Subject: [PATCH 1/3] set HOME environment Signed-off-by: Lai Jiangshan --- src/container.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/container.c b/src/container.c index 4d4d31b..06a9097 100644 --- a/src/container.c +++ b/src/container.c @@ -348,6 +348,9 @@ static int hyper_container_init(void *data) goto fail; } + // set additinal env before config so that the config can overwrite it + setenv("HOME", "/root", 1); + if (hyper_setup_env(container->envs, container->envs_num) < 0) { fprintf(stdout, "setup env failed\n"); goto fail; From 50928fc1ef26b946ae278ca6d15209a93594f169 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Sat, 26 Mar 2016 11:44:37 +0800 Subject: [PATCH 2/3] set/unset TERM environment based on tty config Signed-off-by: Lai Jiangshan --- src/container.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/container.c b/src/container.c index 06a9097..71bd9e4 100644 --- a/src/container.c +++ b/src/container.c @@ -350,6 +350,10 @@ static int hyper_container_init(void *data) // set additinal env before config so that the config can overwrite it setenv("HOME", "/root", 1); + if (container->exec.tty) + setenv("TERM", "xterm", 1); + else + unsetenv("TERM"); if (hyper_setup_env(container->envs, container->envs_num) < 0) { fprintf(stdout, "setup env failed\n"); From 04689c4138b3af7492135cd59bf29a7443c25243 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Sat, 26 Mar 2016 12:03:15 +0800 Subject: [PATCH 3/3] set HOSTNAME environment Signed-off-by: Lai Jiangshan --- src/container.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/container.c b/src/container.c index 71bd9e4..8959875 100644 --- a/src/container.c +++ b/src/container.c @@ -316,6 +316,7 @@ static int hyper_rescan_scsi(void) struct hyper_container_arg { struct hyper_container *c; + struct hyper_pod *pod; int ipcns; int utsns; int pipe[2]; @@ -350,6 +351,7 @@ static int hyper_container_init(void *data) // set additinal env before config so that the config can overwrite it setenv("HOME", "/root", 1); + setenv("HOSTNAME", arg->pod->hostname, 1); if (container->exec.tty) setenv("TERM", "xterm", 1); else @@ -504,6 +506,7 @@ int hyper_start_container(struct hyper_container *container, int stacksize = getpagesize() * 4; struct hyper_container_arg arg = { .c = container, + .pod = pod, .utsns = utsns, .ipcns = ipcns, .pipe = {-1, -1},