/* * This is a simple script meant to help debug scripts supposed to run in chroot. * stuff run in chroot usually isn't run as root, but it can be hard to debug * such stuff. By using this small util you can execute what you want, with the * uid of your choice. * * How to compile: * gcc -static -o /glftpd/bin/droproot droproot.c * * How to run: * chroot /glftpd /bin/droproot "something to run" * * Number must be between 1 and 65535. * The "" is only needed if you wish to pass args to the script you wish to * test. * Examples: * chroot /glftpd /bin/droproot 200 /bin/my_script.sh <- valid - no args * chroot /glftpd /bin/droproot 200 /bin/my_script.sh l33tuser <- invalid - arg will not be passed. * chroot /glftpd /bin/droproot 200 "/bin/my_script.sh l33tuser" <- valid - arg will be passed. */ #include #include #include #include int main(int argc, char **argv) { int number; if ( argc < 3 ) { printf("syntax: %s \"\"\n", argv[0]); return 1; } number = atoi(argv[1]); if ( number <1 || number >65535 ) { printf("syntax: %s \"\"\n", argv[0]); printf(" must be between 1 and 65535\n"); return 1; } setuid(number); setgid(number); seteuid(number); setegid(number); return system(argv[2]); }