]> err.no Git - systemd/commitdiff
nspawn: reset environment and load login shell
authorLennart Poettering <lennart@poettering.net>
Mon, 14 Mar 2011 02:28:16 +0000 (03:28 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 14 Mar 2011 02:28:16 +0000 (03:28 +0100)
src/nspawn.c

index 82b0ce4f133bb318d49337bf1cba4208c0b45cb0..297bb61f63b480f5d01f888e38159152f82d4900 100644 (file)
@@ -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");