Zillionbucks logo

UNIX Perl: Setting CGI Permissions

Zillionbucks allows all users to implement their own CGI/Perl scripts. Each site is equipped with it's own CGI-local folder. All CGI files need to be placed into this folder with the exception of a few that operate in a shared capacity.

This "CGI-local" folder, as well as the scripts within, will need to have "permissions" set in order for the scripts to operate properly.

The biggest stumbling block to using CGI scripts is understanding the concept of "permissions." Each file on your website, and every folder has two types of permissions. One is for the ownership of the file. The other (which has more do do with CGI scripts) is read/write/execute permission. These permissions tell the server who may view or execute (run) a CGI script and who is allowed to overwrite the file.

This same permission structure is behind why some directories show you the files contained within, and others prompt you for a username and password or don't allow entry. It's also the most common thing to go wrong when installing a script for the first time.

Most FTP applications allow you to set the permissions of the files that you upload to your server. Generally your scripts will live in the directory labeled /cgi-local/.

For your script to operate properly you want the visitor to your site to be able to execute the script, but you don't want them to have the right to overwrite the file. For most scripts you want permissions to be set for rwxr-xr-x(755). You can read/write/execute, but the visitor can only execute.

This may seem cryptic at first glance, but it's not that hard. Break the code down by viewing it as a set of the same three commands stated for each state, "owner", "group", "everyone." Translate the first three letters as representing read, write, execute for the "owner" of the script (you). Then read, no-write, execute permissions for the "group" and also for "everyone." There are also some Unix codes that correspond to each of these standard "modes" which are summaried below. .

Permission  Command
rwxrwxrwx   chmod 777
rwxrwxr-x   chmod 775
rwxr-xr-x   chmod 755
rw-rw-rw-   chmod 666
rw-rw-r--   chmod 664
rw-r--r--   chmod 644

So in the above the mode 666 (often used for script data files) the owner, the group and the visitor would all have read/write permission to take data and write it to a database, but no one would "see" the data from their web browser.

To indicate which permissions a file is given take a look at your help menu for your FTP application under "set permissions."

With WS-FTP you simply right click on the file or folder in the window, after you have uploaded it to your site.

Then choose "chmod" and a window will appear that looks like this. This window has permissions set to 755, (read, write, execute; read, no write, execute; read, no write, execute).

There are also ways to set permissions using a telnet connection if you are interested in learning UNIX commands.

 

©1999-2001, Zillionbucks
Send Mail to support@Zillionbucks.com for Web Site Assistance