summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-03-14 03:28:16 +0100
committerLennart Poettering <lennart@poettering.net>2011-03-14 03:28:16 +0100
commitda5b3bad1cadb9d9062d01a17056ec085fb725f9 (patch)
treef42deea7a919e2664536bab20f07b10e0e207d60 /src
parent124640f177c118b096ed2c531a4617d52a283395 (diff)
nspawn: reset environment and load login shell
Diffstat (limited to 'src')
-rw-r--r--src/nspawn.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/nspawn.c b/src/nspawn.c
index 82b0ce4f13..297bb61f63 100644
--- a/src/nspawn.c
+++ b/src/nspawn.c
@@ -390,6 +390,11 @@ int main(int argc, char *argv[]) {
if (pid == 0) {
const char *hn;
+ const char *envp[] = {
+ "HOME=/root",
+ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
+ NULL
+ };
/* child */
@@ -425,9 +430,11 @@ int main(int argc, char *argv[]) {
sethostname(hn, strlen(hn));
if (argc > optind)
- execvp(argv[optind], argv + optind);
- else
- execl("/bin/bash", "/bin/bash", NULL);
+ execvpe(argv[optind], argv + optind, (char**) envp);
+ else {
+ chdir("/root");
+ execle("/bin/bash", "-bash", NULL, (char**) envp);
+ }
log_error("execv() failed: %m");