• Tag Archives as root
  • run cgi script as „root“

    If your cgi script needs root permissions to run (access to serial port …), you have to create a wrapper.

    DANGER ! Script runs with root permissions –> security !! 👿

    ———

    create wrapper.c

    #define REAL_PATH „/var/www/cgi-bin/test/my_script.cgi“
    main(ac, av)
    char **av;
    {
    execv(REAL_PATH, av);
    }

    ———

    compile it (as root)

    [root@acme test]# gcc -o wrapper.cgi wrapper.c

    [root@acme test]# chmod u+xs wrapper.cgi

    [root@acme test]# ls -la wrapper.cgi

    -rwsr-xr-x  1 root   root     6468 Oct 30 21:12 wrapper.cgi