3 * Execute script under it's owner's privileges
4 * CopyLefted by: Harvie 2oo9
10 #include <sys/types.h>
15 #define INTERPRETER "/usr/bin/php-cgi"
16 //#define INTERPRETER "/usr/bin/perl"
19 puts("Error: Permission denied!\n");
23 int main(int argc
, char **argv
, char **environ
) {
24 if(argc
!= 2) { //Do not accept more than one argument
26 "SetUID wrapper for %s interpretter\n"
27 "Usage: %s script\n\n",
33 if(!stat(argv
[1], &st
)) {
36 if(!(pw
= getpwuid(st
.st_uid
))) auth_fail();
38 if(initgroups(pw
->pw_name
, pw
->pw_gid
)) auth_fail();
40 if(setgid(pw
->pw_gid
)) auth_fail();
41 if(setegid(pw
->pw_gid
)) auth_fail();
42 if(setuid(pw
->pw_uid
)) auth_fail();
43 if(seteuid(pw
->pw_uid
)) auth_fail();
44 //Fail if still have root privileges
45 if(getuid() == 0 || getgid() == 0) auth_fail();
47 return(execve(INTERPRETER
, argv
, environ
));
49 printf("Error: Can't stat file: %s\n\n", argv
[1]);
This page took 0.371922 seconds and 4 git commands to generate.