Using The Common Gateway Interface: User CGI Guidelines

Perl Scripts

If it's a Perl script, check to be sure the first line is:

#!/usr/local/bin/perl -wT

File Permissions and the suexec Wrapper

The WPI Web servers managed by the CCC, www.wpi.edu and users.wpi.edu, support CGI programs. This is done using the suexec wrapper which comes with Apache. This wrapper runs the CGI program as your user ID instead of the user ID of the web server. You should be very cautious as your CGI program has the potential to destroy your account if you are not careful. Also note that all CGI programs must abide by the regulations in the WPI Acceptable Use Policy.

The following limitations are placed on user CGI programs to work with the suexec wrapper:

  1. User executing the wrapper must be a valid user on this system.
  2. The command that the request wishes to execute must not contain a /.
  3. The current working directory must be a directory.
  4. The current working directory must not be writable by group or other.
  5. The command being executed cannot be a symbolic link.
  6. The command being executed cannot be writable by group or other.
  7. The command being executed cannot be a setuid or setgid program.
  8. The target UID and GID must be a valid user and group on this system.
  9. The target UID and GID to execute as, must match the UID and GID of the directory.
  10. The target UID and GID to execute as, must match the UID and GID of the user.
  11. The target execution UID and GID must not be the privileged ID 0.

File and directory permissions should look like this, where user should be your username and 1234 should be your GID:

drwxr-xr-x   16 user      1234        20480 Apr 14 00:49 .
drwxr-xr-x   22 user      1234        90112 Apr 14 00:55 ..
-rwxr-xr-x    1 user      1234        13006 Apr 11 19:30 script.cgi

To achieve these file permissions, you would type:

chmod 0755 .
chmod 0755 script.cgi

Storing CGI Programs

Your CGI program must reside in or in a directory under your public_html directory and must have a filename which ends in .cgi, for example: counter.cgi. Your web pages would call this script just as a normal CGI program. Below are a couple of examples:

<A HREF="cgi-bin/test.cgi">Click here.</A>

<FORM METHOD=POST ACTION=cgi-bin/getname.cgi>
Name: <INPUT SIZE=50 NAME=Name>
<INPUT TYPE=SUBMIT VALUE=Submit>
</FORM>

Both of these examples assume that you have placed your CGI programs in ~/public_html/cgi-bin/.

Questions & Problems

Questions about authoring CGI programs should be addressed to helpdesk@wpi.edu.

Maintained by webmaster@wpi.edu
Last modified: Jan 10, 2005, 10:46 EST
[WPI] [Home] [Back] [Top]