Skip to content

Instantly share code, notes, and snippets.

@seebs
Created January 16, 2017 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seebs/10dcb7ed22281a880f93daa035fb223c to your computer and use it in GitHub Desktop.
Save seebs/10dcb7ed22281a880f93daa035fb223c to your computer and use it in GitHub Desktop.
int
main(void) {
int root = open("/", O_RDONLY);
int rc;
printf("root fd: %d\n", root);
rc = chroot("f");
printf("chroot(f): %d\n", rc);
rc = fchdir(root);
printf("fchdir(root): %d\n", rc);
rc = chroot(".");
printf("chroot(.): %d\n", rc);
int r2 = open("/", O_RDONLY);
printf("root fd 2: %d\n", r2);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment