8
int main(int argc, char* const argv[])
12
fprintf(stderr, "usage: %s <uid> <jail> <cwd> <interp> <script> [args...]\n", argv[0]);
16
if (strlen(argv[2]) < 1 || argv[2][0] != '/'
17
|| strstr(argv[2], "/..")
18
|| strncmp(argv[2], jail_base, strlen(jail_base)))
20
fprintf(stderr, "bad path: %s\n", argv[2]);
26
perror("could not chroot");
32
perror("could not chdir");
36
if (setuid(atoi(argv[1])))
38
perror("could not setuid");
42
execv(argv[4], argv + 5);
44
/* nb exec won't return unless there was an error */
45
perror("could not exec");