Next / Previous / Index / TCC Help System / Publications / Site map / NM Tech homepage

HTML Server Side Includes: Permission problems

Tech Computer Center logo

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:

Compiled programs

If the program you want to execute from SSI is in a compiled language such as C or C++, you must observe these precautions:

Scripting languages

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:
  1. Copy the above program to a file in the same directory as your script, and call it something like run.c.
  2. Substitute the name of your script in the execv(...) line.
  3. Make sure you are on a Linux platform for the compilation step below.
  4. Compile the program using a command like:
          gcc run.c -o run
  5. Give the executable setuid permission using something like:
          chmod 4755 run

See also: Using HTML Server Side Includes (SSI)
Previous: HTML Server Side Includes: exec
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Computer Center: Help System
TCC Publications
Home: About New Mexico Tech

John Shipman, john@nmt.edu

Last updated: 2000/07/28 22:51:14 UT
URL: http://www.nmt.edu/tcc/help/html/ssi_suid.html