[PATCH] httpd: Support configurable start page

Alex Landau landau_alex at yahoo.com
Sun Oct 21 00:39:23 PDT 2007


--- Denys Vlasenko <vda.linux at googlemail.com> wrote:

> On Thursday 18 October 2007 12:41, Alex Landau wrote:

> > > Regarding your question about whether the current index.cgi approach is enough for
> me, it 
> > isn't. Due to two reasons. First, it has to be a binary and be located in /cgi-bin/.
> I
> > want it to be a PHP script. That's the main reason for me. (I can try putting a
> > #!/bin/php at the top, but I think PHP will just display it...).
> 
> I cannot test this here, have no php installed. But even if it doesn't,
> 
> #!/bin/sh
> exec php something.php
> 
> should work.

It doesn't. It seems that PHP detects it is being run from a webserver (probably via some
env vars) and displays the page specified in SCRIPT_FILENAME. So, for it to work,
SCRIPT_FILENAME has to be set to the correct script before execing php. (I'm not saying
it's hard or impossible, just want the archives to have a working solution).

> 
> > Second, it's one page 
> > for the whole site, you can't decide that some directories have their own version of
> the
> > default page.
> 
> You can analyze $QUERY_STRING env var. For example:
> 
> #!/bin/sh
> 
> # Must start with /
> test x"${QUERY_STRING:0:1}" != x/ || exit 1
> 
> # Remove /
> QUERY_STRING="${QUERY_STRING:1:9990}"
> 
> # cd into $QUERY_STRING dir
> cd .. || exit 1
> test "$QUERY_STRING" && cd "$QUERY_STRING" || exit 1
> 
> # If index.php exists, run it
> test -f index.php && exec php index.php
> 
> ...
> 

Sure, it works, but it's a lot of shell processing just for arranging to run the right
script.

> Face it, httpd.c is already a mess. I'd rather not add even more.
> PROXY support can't be done with helper CGI, START_PAGE can.

I think this feature is useful, but I also agree that httpd.c is a mess.

> 
> I am committing PROXY support to svn.
> Note that code around fdprintf(proxy_fd...) has changed, needs testing.

That seems OK, but a typo was introduced in the config file parsing. See attached patch.

> If you want START_PAGE support too, explain a bit more
> why index.cgi cannot fulfil your needs.
> Testable example will be best.

I don't have counter-arguments to the "mess" one. For me, a CGI just for that is probably
an overkill, so I guess I'll stay with the index.html that redirects to index.php as it
used to be before.

> --
> vda
> 
Alex

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: httpd-proxy-typo.diff
Type: text/x-patch
Size: 406 bytes
Desc: 2510572674-httpd-proxy-typo.diff
Url : http://busybox.net/lists/busybox/attachments/20071021/4fbe1f90/attachment.bin 


More information about the busybox mailing list