Listing 2: realdo.c--A utility which allows execution as the real user
/************************************
* realdo.c Realdo - do as user
*************************************/
#include <stdio.h>
#include <unistd.h>
int main(argc, argv)
int argc;
char* argv[];
{
int rc;
if (argc < 3)
{
fprintf(stderr, "usage: realdo uid \"command\"\n");
exit(4);
}
/* argv[1] contains the user id to use.
* unless you are root, you can only
* become yourself.
*/
setuid(atoi(argv[1]));
/* Don't have to worry about PATH,
* assume already set in suFirewall.
*/
rc=system(argv[2]);
rc=rc>>8;
exit(rc);
}
|