[PATCHv2] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

Peter Korsgaard jacmet at sunsite.dk
Sun Dec 18 20:57:14 UTC 2011


>>>>> "Denys" == Denys Vlasenko <vda.linux at googlemail.com> writes:

Hi,

 Denys> I propose to move it to the site of aforementioned appending:

 Denys> This way, it's more obvoius, and only done when needed (=> only
 Denys> for dirs).

Yes, that makes sense.

 Denys> However, there is another problem. Check
 Denys> /usr/srcdevel/bbox/fix/busybox.3/networking/httpd_indexcgi.c
 Denys> See how it is determining _which directory_ to list.
 Denys> It looks at $QUERY_STRING.

 Denys> IOW: "g_query = urlcopy;" assignment you nuked wasn't a quick fix
 Denys> for "query string is overwritten" bug. It was a way to give
 Denys> cgi-bin/index.cgi a way to find the directory it is meant to list.

Ahh, I didn't know that. I do find the
pass-original-request-in-QUERY_STRING quite nonstandard and limiting
(E.G. it means you cannot easily support Apache-style selectable
directory sorting by DIR/?..). I personally don't use the
/cgi-bin/index.cgi fallback for directory listing, but simply to have a
nicer looking URL for the main (CGI based) webpage, without having to
mess with a dummy index.html and a HTML level redirect.

I think a better approach would be to let REQUEST_URI be the original
(DIR/) location requested, and then leave QUERY_STRING for arguments
like normal. Alternatively we could add SCRIPT_URL, which seems to be
what Apache's mod_rewrite provides:

https://httpd.apache.org/docs/current/mod/mod_rewrite.html#EnvVar

Let me know what you prefer and I'll cook up a patch to add an
additional orig_uri argument to send_cgi_and_exit() and use it to set
the environment variable correctly.

-- 
Bye, Peter Korsgaard


More information about the busybox mailing list