/*

Simple wrapper program to allow people to suid to their own user id.
Version 2.0b

Directions:

0) Edit the text below for the_file file name variable.

1) Compile this C program (use cc if you don't have gcc):

     gcc -o wrap_mgr.o wrap_mgr.c

2) Set permissions on the wrapper so it runs under your id:

     chmod 555 wrap_mgr.o
     chmod a+s wrap_mgr.o

3) Manager.cgi 3.1+ will detect the wrapper and use it automatically if it
   is properly placed in the same directory.

*/

#include <unistd.h>
#include "stdio.h"
main()
{
FILE *fp;
char the_file[75] = "/full/path/to/manager.cgi";

if((fp=fopen(the_file,"r"))==NULL)
{
printf("Content-type: text/html\n\nCannot open the file %s\n",the_file);
exit();
}
fclose(fp);

/* Set the real id to the value of the effective id, may help GPG */

if (setreuid(geteuid(),-1) == -1)
{
 printf("Content-type: text/html\n\nCannot set real UID to %d\n",
        (int)geteuid());
 exit();
}

 execl(the_file,the_file,"nowrap",NULL); /* */

}


