mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
3f9e4cd24e
This program changes the current filesystem root and spawns a shell.
27 lines
442 B
C++
27 lines
442 B
C++
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
if (argc != 2) {
|
|
printf("usage: chroot <path>\n");
|
|
return 0;
|
|
}
|
|
|
|
if (chroot(argv[1]) < 0) {
|
|
perror("chroot");
|
|
return 1;
|
|
}
|
|
|
|
if (chdir("/") < 0) {
|
|
perror("chdir(/)");
|
|
return 1;
|
|
}
|
|
|
|
if (execl("/bin/Shell", "Shell", nullptr) < 0) {
|
|
perror("execl");
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|