Merge pull request #102 from laijs/HOME-env

set the HOME env correctly when it is not configured
This commit is contained in:
Lai Jiangshan
2016-05-20 07:57:27 +08:00
2 changed files with 13 additions and 6 deletions
+7 -6
View File
@@ -488,7 +488,7 @@ static int hyper_container_init(void *data)
goto fail;
}
// set additinal env before config so that the config can overwrite it
// set early env. the container env config can overwrite it
setenv("HOME", "/root", 1);
setenv("HOSTNAME", arg->pod->hostname, 1);
if (container->exec.tty)
@@ -496,11 +496,6 @@ static int hyper_container_init(void *data)
else
unsetenv("TERM");
if (hyper_setup_env(container->exec.envs, container->exec.envs_num) < 0) {
fprintf(stdout, "setup env failed\n");
goto fail;
}
if (mount("", "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) {
perror("mount SLAVE failed");
goto fail;
@@ -615,6 +610,12 @@ static int hyper_container_init(void *data)
goto fail;
}
// set the container env
if (hyper_setup_env(container->exec.envs, container->exec.envs_num) < 0) {
fprintf(stdout, "setup env failed\n");
goto fail;
}
hyper_send_type(arg->pipe[1], READY);
fflush(stdout);
+6
View File
@@ -271,6 +271,12 @@ int hyper_setup_exec_user(struct hyper_exec *exec)
perror("setuid() fails");
goto fail;
}
free(groups);
// set user related envs. the container env config can overwrite it
setenv("USER", pwd->pw_name, 1);
setenv("HOME", pwd->pw_dir, 1);
return 0;
fail: