File: chroot.c

package info (click to toggle)
proot 5.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,012 kB
  • sloc: ansic: 18,627; sh: 1,662; python: 108; asm: 41; makefile: 16; awk: 6
file content (19 lines) | stat: -rw-r--r-- 248 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv)
{
	if (argc < 2)
		exit(1);

	if (chroot(argv[1]))
		exit(1);

	if (argc >= 3)
		execvp(argv[2], &argv[2]);
	else
		execlp("sh", "sh", NULL);

	/* unreachable */
	return 1;
}