You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Torsten Foertsch <to...@gmx.net> on 2008/06/27 18:14:52 UTC

Bug in ap_internal_fast_redirect

Hi dev,

on the modperl mailing list we had recently an interesting problem that has 
revealed a bug in ap_internal_fast_redirect, see

  https://issues.apache.org/bugzilla/show_bug.cgi?id=45297

Suppose this config:

DirectoryIndex index.shtml
Options Includes Indexes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

<Location /index.shtml>
    Require valid-user
    AuthType basic
    AuthName "Something very secret"
    AuthUserFile /path/to/htpasswd
</Location>

and an SSI document or an other handler that uses r->user as index.shtml:

<html>
<body>
<h1>Hello <!--#echo var="REMOTE_USER" --></h1>
</body>
</html>

If called directly as "/index.shtml" r->user is shown correctly. But if called 
via mod_dir as "/" the auth basic dialog appears but r->user is empty.

The problem lies in ap_internal_fast_redirect. It simply forgets to copy 
r->user from the subrequest.

I have attached a patch to the bug that "solves" the problem.

But ... ap_internal_fast_redirect seems to me like an ugly hack. The name is 
very misleading. It pretends that an internal redirect is done but that's not 
true. The function simply copies values from a subrequest to the main 
request.

It is called with 2 requests and one of them is a subreq and it practically 
overwrites the main req with the content of the subreq.

In mod_dir the function is called from the fixup hook when it decides to use a 
certain document as DirectoryIndex. A subreq was previously used to check if 
the document exists as a regular file.

So I am wondering wouldn't it be better to call ap_run_sub_req(subreq) to put 
out the response instead of that hack? I am trying to understand why 
ap_internal_fast_redirect is necessary at all?

Thanks,
Torsten

Re: Bug in ap_internal_fast_redirect

Posted by Torsten Foertsch <to...@gmx.net>.
On Fri 27 Jun 2008, William A. Rowe, Jr. wrote:
> It's legacy crap that should be evicted from httpd-trunk, I'll do so
> sometime in July depending on vacations and such.  You'll be able to
> review the patches to mod_dir and mod_negotiation and decide, should
> we actually push these into 2.2.

That's good to hear. I didn't intend to remove ap_internal_fast_redirect from 
the 2.2 code. I only wanted to understand it. I suspect the code is really 
ancient.

But please apply that little patch of mine to 2.2.

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net

Re: Bug in ap_internal_fast_redirect

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Torsten Foertsch wrote:
> 
> So I am wondering wouldn't it be better to call ap_run_sub_req(subreq) to put 
> out the response instead of that hack? I am trying to understand why 
> ap_internal_fast_redirect is necessary at all?

It's legacy crap that should be evicted from httpd-trunk, I'll do so
sometime in July depending on vacations and such.  You'll be able to
review the patches to mod_dir and mod_negotiation and decide, should
we actually push these into 2.2.

The answer though is probably -no-.  Module authors have developed their
modules around these quirky behaviors, so changing in 2.2 may substantially
break third party extensions.  Because of our ABI contracts, we try not
to do such things (fcgid on win32 being an obvious but necessary exception).

Bill