[Tutor] Strange magic...

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Fri, 18 Jan 2002 00:03:24 -0800 (PST)


On Fri, 18 Jan 2002, kirk Bailey wrote:

> THIS MESSAGE CONTAINS LINES OF POLITICALLY INCORRECT LENGTH.
> ok, here is the print statement:(Ware word wrap!)
> print '<a href="http://www.python.org" target="_new"><img
> src="./pythonpowered.gif" width="110" height="44" border="0" 
> alt="click to visit the python language website!"></a>'
> 
> 
> and here is the error report:(DITTO!)
> [Fri Jan 18 01:03:19 2002] [error] [client 63.208.204.126] file
> permissions deny server execution:
> /www/www.tinylist.org/cgi-bin/pythonpowered.gif


Ok, now that's more like it!  I think I have a reasonable hypothesis!
Here's my guess: if a file is within the /cgi-bin/ directory, perhaps a
file request for a file in the cgi-bin directory causes Apache to try
executing the file.


I don't think this has anything to do with Python, as the error message
you're showing me,

###
> [Fri Jan 18 01:12:00 2002] [error] (8)Exec format error: exec of
> /www/www.tinylist.org/cgi-bin/pythonpowered.gif failed
> [Fri Jan 18 01:12:00 2002] [error] [client 63.208.204.126] Premature
> end of script headers: /www/www.tinylist.org/cgi-bin/pythonpowered.gif
###

implies that Apache itself is trying to execute 'pythonpowered.gif'.  


According to the Apache documentation at:

    http://httpd.apache.org/docs/mod/mod_alias.html

any requests to files in a "ScriptAliased" directory like "/cgi-bin"
triggers CGI handling.  Despite the fact that 'pythonpowered.gif' has the
extension of 'gif', Apache has no way of knowing the context of this!  
It'll just execute it.

(And in fact, one can take advantage of this strangeness by writing a
Python script that has a "gif" extension, but actually generates dynamic
gif images.)


But I'd better stop guessing.  *grin* Let's test this hypothesis out.  
How about moving your pythonpowered.gif file somewhere else like 'icons/',
outside your cgi directory?