>Number:         1621
>Category:       mod_cgi
>Synopsis:       CGI scripts can have a #! that is another script.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Sat Jan  3 22:50:00 PST 1998
>Last-Modified:
>Originator:     [EMAIL PROTECTED]
>Organization:
apache
>Release:        1.2.4
>Environment:
Linux 2.0.32 (RedHat 5.0)
Glibc 2.0.5c
gcc 2.7.2.3
>Description:
It appears that apache can't run a CGI script which has another script as
its interpreter, as specified in the shebang (#!) line.  They must point
to a true executable.  I'm fairly certain this hasn't always been the case.
>How-To-Repeat:
Try this:

File: /usr/local/bin/interpret.sh
#!/usr/bin/sh
echo "Content-type: text/plain"
echo
cat $1

File: /usr/local/etc/httpd/test.cgi
#!/usr/local/bin/interpret.sh
This is a test CGI
It worked!

If test.cgi is run from the command line, it works fine.  However, if run
as a script through Apache, it errors with an "Exec format error (errno = 8)"
in the error log.
>Fix:
Not sure how to fix it, but as a work around, you have to alter the CGI
shebang so that it calls the ultimate executable.  For instance:

Instead of '#!/usr/local/bin/interpret.sh', you have to use
'#!/usr/bin/sh /usr/local/bin/interpret.sh'.  Kind of a pain, but it
does work
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <[EMAIL PROTECTED]> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]



Reply via email to