[klibc] chroot: Fix expected behaviour
/usr/lib/klibc/bin/chroot / sh
execve: No such file or directory
/usr/lib/klibc/bin/chroot / /bin/pwd
/home/max
./src/klibc/usr/utils/static/chroot / pwd
/
Cc: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: maximilian attems <max@stro.at>
diff --git a/usr/utils/chroot.c b/usr/utils/chroot.c
index e3e6791..bc1b94f 100644
--- a/usr/utils/chroot.c
+++ b/usr/utils/chroot.c
@@ -16,8 +16,13 @@
return 1;
}
- if (execve(argv[2], argv + 2, envp) == -1) {
- perror("execve");
+ if (chdir("/") == -1) {
+ perror("chdir");
+ return 1;
+ }
+
+ if (execvp(argv[2], argv + 2) == -1) {
+ perror("execvp");
return 1;
}