HTML Server Side Includes: Permission problems |
|
Sometimes a SSI (Server Side Includes) script, as executed by a <!--#exec...--> SSI tag, will need to write to a file.
Because SSI scripts run as user ``nobody,'' they will not have the same permissions as they would if they were run by you. (See `Controlling access to your files' for background information about permissions.)
So if a script needs to write to a file, you have two choices:
If the program you want to execute from SSI is in a compiled language such as C or C++, you must observe these precautions:
chmod 4755 binary
where binary is the executable form of your program.
The application you want to execute from SSI may be in a scripting language such as bash, Python, Perl, or the like (with its first line having the form "#!pathname").
If the script does not need the setuid permission, and can run as user ``nobody,'' there is no problem.
However, due to security considerations, our Web server disregards the setuid permission for all scripts executed from SSI #exec tags or as CGI scripts. So even if you add the setuid permission to your script, it will still run as nobody.
In this case, you can still get the script to run as setuid, but you must supply a ``wrapper'' program in a compiled language, and add the setuid permission on the compiled form of this wrapper program.
Here is a complete, simple wrapper program in C that will do the job:
main (argc,argv)
int argc;
char **argv;
{
execv("path",argv);
}
where path is the absolute pathname of the script.
To set up the wrapper:
gcc run.c -o run
chmod 4755 run