Created
July 21, 2014 19:01
-
-
Save kgadek/11895058c1c7405275c8 to your computer and use it in GitHub Desktop.
Chrooter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
const char newroot[] = "/home/buildbot_flowbox/jail-" JAIL_NAME; | |
const char cmd[] = "/bin/bash"; | |
char *args[2] = {"--init-file", "/home/buildbot_flowbox/initfile-jail-" JAIL_NAME}; | |
int main(int c, char **v, char **e) { | |
int rc; const char *m; | |
if ( (m = "chdir" ,rc = chdir(newroot) ) == 0 | |
&& (m = "chroot",rc = chroot(newroot) ) == 0 | |
&& (m = "setuid",rc = setuid(getuid())) == 0 ) | |
m="execve", execve(cmd,args,e); | |
perror(m); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment