/*
    wrapper for setuid script -
    Copyright (c) 1996 Steffen Beyer, <sb@sdm.de>
    software design & management GmbH & Co. KG
*/

#include <stdio.h>
#include <string.h>
#include <stdarg.h>

#include <sys/types.h>
#ifdef SOL2
#include <sys/systeminfo.h>
#endif
#include <pwd.h>
#include <grp.h>


int main(int argc, char **argv)
{

/* define here the path and name of the script to execute with setuid: */

    char cmd[4096] = "/opt/bin/my_pr.suid";

    int i;

    /* if parameters are passed, concatenate them: */

    if (argc > 1)
    {
        for (i=1; i < argc; i++)
        {
            strcat(cmd, " ");
/*
            if (index(argv[i], ' ') != NULL && index(argv[i], '"') == NULL)
            {
*/
            if (index(argv[i], '"') == NULL)
            {
                strcat(cmd, "\"");
                strcat(cmd, argv[i]);
                strcat(cmd, "\"");
            }
            else
            {
                strcat(cmd, "'");
                strcat(cmd, argv[i]);
                strcat(cmd, "'");
            }
        }
    }
    /* (else no parameters at all) */

    setuid(0);
    setgid(0);

    return(system(cmd));
}

