Bug 58498 - Apache 2.4.17: Regression with mod_autoindex (in combination with Phusion Passenger)
Summary: Apache 2.4.17: Regression with mod_autoindex (in combination with Phusion Pas...
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_autoindex (show other bugs)
Version: 2.5-HEAD
Hardware: PC Linux
: P2 normal with 6 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-16 11:46 UTC by Timo Gurr
Modified: 2016-01-04 11:07 UTC (History)
3 users (show)



Attachments
httpd-2.4.17-autoindex-revert.patch (610 bytes, patch)
2015-10-16 11:46 UTC, Timo Gurr
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Timo Gurr 2015-10-16 11:46:49 UTC
Created attachment 33183 [details]
httpd-2.4.17-autoindex-revert.patch

There seems to be an issue with Phusion Passenger (5.0.20) caused by: http://svn.apache.org/viewvc?view=revision&revision=r1701436
which has been reported here:
https://groups.google.com/forum/#!topic/phusion-passenger/jiOpv9Isua4
By reverting the offending commit Phusion Passenger works fine with 2.4.17.
Comment 1 Eric Covener 2015-10-16 16:06:13 UTC
Can someone familiar with the passenger impl elaborate on what's going on?

If it's broken by this change -- I am assuming it operates as a handler at APR_HOOK_MIDDLE (or later), wants to operate on requests mapped to directories , but doesn't do anything to set a r->handler or run before mod_autoindex?

(I'd rather not just revert the fix that allows mod_autoindex to work without mod_mime)
Comment 2 Rainer Jung 2015-10-16 17:24:39 UTC
I'm not an expert on passenger, but one can see the hook registration at

https://github.com/phusion/passenger/blob/stable-5.0/src/apache2_module/Hooks.cpp

scrolling down to the end of the file.

The code in the file contains some handler juggling and also rules for ordering relative to mod_autoindex. Especially 

ap_hook_handler(start_blocking_mod_autoindex, NULL, autoindex_module, APR_HOOK_LAST);
ap_hook_handler(end_blocking_mod_autoindex, autoindex_module, NULL, APR_HOOK_FIRST);

points to

DEFINE_REQUEST_HOOK(start_blocking_mod_autoindex, startBlockingModAutoIndex)
DEFINE_REQUEST_HOOK(end_blocking_mod_autoindex, endBlockingModAutoIndex)

which brings the following functions into the game:

        int startBlockingModAutoIndex(request_rec *r) {
                RequestNote *note = getRequestNote(r);
                if (note != 0 && hasModAutoIndex()) {
                        note->handlerBeforeModAutoIndex = r->handler;
                        r->handler = "";
                }
                return DECLINED;
        }

        int endBlockingModAutoIndex(request_rec *r) {
                RequestNote *note = getRequestNote(r);
                if (note != 0 && hasModAutoIndex()) {
                        r->handler = note->handlerBeforeModAutoIndex;
                }
                return DECLINED;
        }


In front of them is a comment:

         * mod_autoindex will try to display a directory index for URIs that map to a directory.
         * This is undesired because of page caching semantics. Suppose that a Rails application
         * has an ImagesController which has page caching enabled, and thus also a 'public/images'
         * directory. When the visitor visits /images we'll want the request to be forwarded to
         * the Rails application, instead of displaying a directory index.
         *
         * So in this hook method, we temporarily change some fields in the request structure
         * in order to block mod_autoindex. In endBlockingModAutoIndex(), we restore the request
         * structure to its former state.

Not sure whether this is related.

Rainer
Comment 3 Eric Covener 2015-10-16 17:33:07 UTC
(moved to dev@)
Comment 4 Eric Covener 2015-10-18 01:06:36 UTC
I proposed on github that they set r->handler to a passenger-skip-autoindex string rather than "" which is what 2.4 uses as DEAULT_HANDLER_NAME