PDA

View Full Version : CGI's in other directory (not /cgi-bin)


rjimmink
10-01-2001, 12:08 PM
Hi,

I'm trying to get some CGIs to work that need to read/write to files in the current directory. That means they can't be installed in /cgi-bin as that is a 'magic' directory treating all files as executable scripts.

So I am now trying to install in a sub-dir of the html-root. I have used .htaccess with the follwoing lines:

Options +ExecCGI
AddHandler cgi-script cgi
AddHandler cgi-script pl

And that seems to work fine for scripts with the extension .cgi and .pl

But how do I add a handler for scripts that do not have an extension in their name? e.g. script_name (as opposed to script_name.cgi or script_name.pl)

Also, I found out that the directory holding the scripts should have the permissions set to 755. In an attempt to get it to work I set this to 777, but then scripts refuse to be executed (even in /cgi-bin). (not to say that using 777 is not wise at all, but when desparate...)

Any ideas welcome!

Ronald

dank
10-01-2001, 12:16 PM
I'm trying to get some CGIs to work that need to read/write to files in the current directory. That means they can't be installed in /cgi-bin as that is a 'magic' directory treating all files as executable scripts.
Not true. I'm not sure what all the restrictions are, but I believe it has to do with file type and what is considered to be only executable or writable. .txt and .log files can definitely be written to in the cgi-bin, as can others I'm sure, so long as permissions are set to 666 or 777.

Dan

Terra
10-01-2001, 12:42 PM
so long as permissions are set to 666 or 777.
Not true as CGI runs under the suEXEC wrapper and switches to your user and group ID on the fly...

suEXEC will refuse to run any scripts from a directory with either the 'Group or World' write bit set...

A file could be: writeme.txt rw------- (600)
and the CGI script would be able to write to it since it is owned by you anyways...

For more information on running within the suEXEC environment, please (carefully) read:
http://httpd.apache.org/docs/suexec.html

--
Terra
--Painstaking detail went into our entire CGI subsystem--
FutureQuest

dank
10-01-2001, 12:50 PM
suEXEC will refuse to run any scripts from a directory with either the 'Group or World' write bit set...
Huh? Are we talking about files or directories?

Dan

Terra
10-01-2001, 01:38 PM
We had an Service Incident earlier today where the site owner changed their /cgi-bin/ to mode 777...

I was only noting that part to be complete...

My bottom line is that you own any file created by a CGI script, so it can be as restrictive on permissions as you would like it to be... Many installation scripts will tell you to set your directories to '777', however that is for the *cough*other*cough* web hosts that don't have an advanced CGI environment... ;)

--
Terra
--One of the rare times the excuse: "Well, it used to work at my old host" is valid, we just simply show them there is a more secure way--
FutureQuest