mod_ruby and mod_autoindex
Shu-yu Guo <[email protected]>
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I am using 1.0.7 and I have noticed that when setting a location's handler to be ruby-object, mod_autoindex breaks if you are trying to view a directory from within that location (assuming you returned DECLINED from the Ruby handler, of course). As best as I understand it, what happens is this 1) Somewhere the filetype gets set to APR_DIR if the URI points to a directory 2) If no handlers are set and the filetype is APR_DIR, mod_dir's fixup handler sets the handler to DIR_MAGIC_TYPE 3) mod_autoindex's handler sees that the handler is DIR_MAGIC_TYPE, and generates the index Since with mod_ruby I set the handler to be ruby-object, the handler no longer gets set to DIR_MAGIC_TYPE, and mod_autoindex no longer processes it. So when my handler returns DECLINED (because it's not its job to serve that particular URI or whatever), the handler remains ruby-object, and mod_autoindex (if it happens to be hooked after mod_ruby, which is not even guaranteed) returns DECLINED as well. This goes all the way to the core, until Apache decides that it shouldn't do raw IO on a directory, returns 404, and logs an error about attempting to serve the directory. I have attached a patch to 1.0.7 (hack is more like it) that re-sets the handler to DIR_MAGIC_TYPE if the filetype is APR_DIR and the ruby handler returned DECLINED. It also ensures that mod_ruby's handlers are called *before* mod_autoindex. This fixes what I was describing. This looks like a problem with autoindex's design more than anything. Does anyone know of a "proper" way of fixing this? - -- Lo-lee-ta: the tip of the tongue taking a trip of three steps down the palate to tap, at three, on the teeth. Lo. Lee. Ta. GUO Shu-yu <[email protected]> -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQE/8FbRTrIPVeT9UA0RAvE9AKCGSz2fgR5eC0j2FnJEQNqJsVs5+wCeN6VS GcTYMbknGEpdtRY0GobnCeg= =NSLz -----END PGP SIGNATURE-----
mod_ruby.c.diff
(text/x-diff, 1.1 KB)
--- mod_ruby.c.orig Mon Sep 8 03:23:34 2003
+++ mod_ruby.c Sun Dec 28 16:33:10 2003
@@ -162,8 +162,9 @@
static void ruby_register_hooks(pool *p)
{
+ static const char *const post[] = {"mod_autoindex.c", NULL};
ap_hook_post_config(ruby_startup, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_handler(ruby_object_handler, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_handler(ruby_object_handler, NULL, post, APR_HOOK_MIDDLE);
ap_hook_translate_name(ruby_trans_handler, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_check_user_id(ruby_authen_handler, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_auth_checker(ruby_authz_handler, NULL, NULL, APR_HOOK_MIDDLE);
@@ -972,9 +973,14 @@
static int ruby_object_handler(request_rec *r)
{
+ int retval;
+
ruby_dir_config *dconf = get_dir_config(r);
- return ruby_handler(r, dconf->ruby_handler, rb_intern("handler"), 0, 1);
+ retval = ruby_handler(r, dconf->ruby_handler, rb_intern("handler"), 0, 1);
+ if(retval == DECLINED && r->finfo.filetype == APR_DIR)
+ r->handler = DIR_MAGIC_TYPE;
+ return retval;
}
static int ruby_trans_handler(request_rec *r)