Back to index

wims  3.65+svn20090927
Functions
wrap.c File Reference
#include <unistd.h>
#include <string.h>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 23 of file wrap.c.

{
    char *args[1024];
    int i, uid1, uid2, gid1, gid2;
    
    if(argc<2) return 0;
    for(i=0;i<1000 && i<argc; i++) args[i]=argv[i+1];
    args[i]=NULL;
    uid1=geteuid(); uid2=getuid(); gid1=getegid(); gid2=getgid();
    if(strchr(args[0],'/')) {
       setreuid(uid1,uid2); setregid(gid1,gid2); 
       execv(args[0],args);
    }
    else {
       setreuid(uid1,uid1); setregid(gid1,gid1); 
       execvp(args[0],args);
    }
    return 127;
}