24 lines
400 B
C
24 lines
400 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
int main(const int argc, const char **argv) {
|
|
if (argc < 3) {
|
|
printf("chroot [dir] [\"command arg\"]\n");
|
|
return 0;
|
|
}
|
|
|
|
if (chroot(argv[1]) == -1) {
|
|
fprintf(stderr, "chroot: %s\n", strerror(errno));
|
|
return 1;
|
|
}
|
|
|
|
chdir("/");
|
|
for (int i = 1; i < argc; i++)
|
|
system(argv[i]);
|
|
|
|
return 0;
|
|
}
|