You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by PV...@nworks.dk on 2002/02/20 20:31:05 UTC

FollowSymLinks and .cgi scripts ..

Hi all,

********************
 Brief
********************
I've been trying to understand how FollowSymLinks works. It seems to work
fine with e.g. .html and .php files, but I can't get it to work with cgi
scripts that are symbolic links.

The reference documentation I have found is:
http://httpd.apache.org/docs/mod/core.html#options. I have of course read
and reread it. This is _not_ about +'s and -'s... I (think I) understand
that part. Assume
Options ExecCGI FollowSymLinks
for all relevant dirs. (See details later)

Q1) What I have figured out is that if lhello.cgi is a softlink pointing to
hello.cgi (lhello.cgi -> hello.cgi) you can HTTP GET hello.cgi, hello or
lhello, but not lhello.cgi. Why is that?

Q2) Also, in my /~pvm/test dir, I have a softlink to ../test2 and one to
/tmp. I can run .cgi scripts in ../test2 (though I'm not sure why - I
didn't think I could) but not in /tmp even though I have set "Option
+ExecCGI" lines "everywhere" for /tmp...

Q3) I also tried adding my own extensions with "AddHandler cgi-script .bob"
and then creating bhello.bob and (lbhello.bob -> bhello.bob). Now I can see
bhello.bob, and bhello, but neither lbhello.bob nor lbhello... What is the
difference between my .bob extension and the existing .cgi extension? I can
find nothing peculiar about the .cgi extension in httpd.conf

(These examples come from having narrowed down the problem enough to
explain it. I don't want to run stuff from /tmp in the long run...)

Although I am absolutely no closer to solving my softlink mystery, I now
have a better understanding of the httpd.conf, so thats alone is good! But
I would like to understand this softlink business.

********************
 Details
********************

Here is a snippet from my httpd.conf. It contains everything having to do
with /home.

<IfModule mod_userdir.c>
    UserDir public_html
</IfModule>

ScriptAlias /test/ "/home/pvm/public_html/test/"
<Directory /home/*/public_html/test >
    Options +ExecCGI +FollowSymLinks
</Directory>

<Location /~pvm/test/tmp >
    Options +ExecCGI +FollowSymLinks
</Location>

<Directory /tmp/ >
    Options +ExecCGI +FollowSymLinks
</Directory>

Now, in the /home/pvm/public_html/test directory, I have:
total 12
-rwxr-xr-x    1 pvm users  188 Feb 20 17:53 hello.cgi
-rw-r--r--    1 pvm users   99 Feb 20 18:27 hello.html
-rw-r--r--    1 pvm users  116 Feb 20 18:47 hello.php
lrwxrwxrwx    1 pvm users    9 Feb 20 17:53 lhello.cgi -> hello.cgi
lrwxrwxrwx    1 pvm users   10 Feb 20 18:27 lhello.html -> hello.html
lrwxrwxrwx    1 pvm users    9 Feb 20 18:47 lhello.php -> hello.php
lrwxrwxrwx    1 pvm users    4 Feb 20 18:23 tmp -> /tmp
lrwxrwxrwx    1 pvm users   28 Feb 20 19:08 anotherDir ->
/home/pvm/public_html/test2/

All of hello* are helloWorld style 2 liners. They all work.

In ./tmp (== /tmp) and in ./anotherDir == (../test2) I have the real files
hello.cgi.

QUESTION 1)

>From my browser, I can see all of them under ~pvm/test except lhello.cgi.

So for lhello.html and lhello.php apache FollowSymLinks to hello.html and
hello.php... But not for lhello.cgi. Why not?

Under /test/ (using the ScriptAlias) I can see all of them ALSO INCLUDING
lhello.cgi. It puzzles me that apache can follow the lhello.cgi softlink
when under /test/ but not when under /~pvm/test...

Also, if I GET lhello (without the .cgi extention) it works. But not if I
GET lhello.cgi then I get the ScriptLog entry below.

Why is that? I am confused, to say the least.

QUESTION 2)
Note that the httpd.conf snippet should not allow access to
~/public_html/test2. (Not to my reading, at least.) And if it should
because it is treated logically as ~/public_html/test/test2, then why
aren't scripts under /tmp working for the exact same reason?

************************************************************
* Error When GETting fails....
************************************************************

These are the error log entries I get when apache can not follow a
softlink. I have checked. The script does not get called at all. (Tried
appending to a log file.)

It looks to me like Apache decides the script does not produce any output
for some reason.

>From the ServerLog:

%% [Wed Feb 20 18:58:19 2002] GET /~pvm/test/lhello.cgi HTTP/1.1
%% 500 /home/pvm/public_html/test/lhello.cgi
%request
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-powerpoint, application/vnd.ms-excel,
application/msword, */*
Accept-Encoding: gzip, deflate
Accept-Language: en-us
Connection: Keep-Alive
Cookie: foo=bar; ost=gummiost; PLATFORM=TestProduct;
VERSION-TestProduct=other; LASTORDER=bugs.bug_id
Host: pvmcap
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; Hotbar 3.0)
%response

and therefore this errorLog entry:
[Wed Feb 20 18:58:19 2002] [error] [client 10.10.10.140] Premature end of
script headers: /home/pvm/public_html/test/lhello.cgi

But hello.cgi contains:
#!/usr/bin/perl -w

print "Content-Type: text/html\n\n";

print "<HTML><HEAD><TITLE>Hello</TITLE> </HEAD><BODY>World</BODY></HTML>
\n";


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org