You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Graham Leggett <mi...@sharp.fm> on 2013/12/30 15:48:51 UTC

mod_dav: Can dav be enabled in the root / location?

Hi all,

I am currently struggling to turn mod_dav on. In theory, it is just "Dav on", but in practice I am getting a 405 Method Not Allowed in response to PROPFIND, and nothing in the error_log to give a clue that anything is wrong.

So, before I go off and crank this up in a debugger to figure out why the on switch won't work, does anyone know whether hosting a dav drive from the root is even possible?

Config looks like this:

    DocumentRoot /var/www/combined

    <Directory /var/www/combined/>
      Options +FollowSymLinks +Indexes
      AllowOverride None
      Require all granted
    </Directory>

    <Location />
      Dav on
      Options +FollowSymLinks +Indexes
      AllowOverride None
… auth stuff ...
      require valid-user
    </Location>

Regards,
Graham
--


Re: mod_dav: Can dav be enabled in the root / location?

Posted by Stefan Fritsch <sf...@sfritsch.de>.
Am Montag, 30. Dezember 2013, 19:04:53 schrieb Graham Leggett:
> The first is there is no way to switch mod_dir off - you add the
> module that means "on". If you need the module "on" in one virtual
> host, but "off" in another you're stuffed.

Doesn't "DirectoryIndex disabled" do the trick?

Re: mod_dav: Can dav be enabled in the root / location?

Posted by Chris Darroch <ch...@pearsoncmg.com>.
Graham Leggett wrote:

> The second is that the module seems to want to respond to all methods,
> GET, POST, PROPFIND, etc when in theory it should only respond to GET.

   Yes, exactly.  The history here seems to be due to a change made for
PR 25435, which made it into 2.4.x but was vetoed for 2.2.x.[1-4]

   In short, if you set up a docroot with a file /dav/index.html,
set "Dav On" on /dav, and make a "PROPFIND /dav/" request, you get a 405
with 2.4.x/trunk, but a DAV response with 2.2.x.

   You can use "DirectoryIndex disabled" to defeat this problem in
2.4.x/trunk, but to me this looks like a regression, as a working 2.2.x
DAV configuration will be broken in 2.4.x.


   Digging in a bit, mod_dir's fixup hook for directories is runs LAST,
after mod_dav's fixups hook.  In mod_dav's hook, it sets r->handler for
its module, except when the method is GET or POST.

   In mod_dir, the fixups hook no longer bails out (after dealing with
no-trailing-slash cases) when r->handler is not DIR_MAGIC_TYPE, due to
the r233369 change, so it proceeds even in the case of PROPFIND or
another DAV method to go looking for index.html, etc., using
ap_sub_req_lookup_uri(), which runs its sub-request using GET.

   In those GET sub-requests, mod_dav's fixups hook does not set
r->handler, because of the method type.

   When index.html or some other DirectoryIndex file is found, mod_dir
overwrites the current request r with the sub-request using
ap_internal_fast_redirect().  This overwrites r->handler to NULL (as
mod_dav declined to take action during the GET sub-request), but does
not change r->method or r->method_number.

   Now the core default_handler() runs because r->handler == NULL,
sees the PROPFIND method in r, and responds with a 405.


   Here's a quick patch which I've pulled out of my long list, which
I believe resolves the problem by having mod_dir decline to take
action except on GET or POST.  See if this helps, and if so, I'll try
to get it cleaned up and into trunk as soon as I'm back to work:

===========================================================
--- mod_dir.c.orig      2013-12-30 10:32:45.222008348 -0800
+++ mod_dir.c   2013-12-30 10:33:17.219008863 -0800
@@ -260,6 +260,10 @@
         return HTTP_MOVED_PERMANENTLY;
     }
 
+    if (r->method_number != M_GET && r->method_number != M_POST) {
+        return DECLINED;
+    }
+
     if (d->index_names) {
         names_ptr = (char **)d->index_names->elts;
         num_names = d->index_names->nelts;
===========================================================

Chris.

1. https://issues.apache.org/bugzilla/show_bug.cgi?id=25435#c7
2. http://svn.apache.org/r233369
3. http://svn.apache.org/r327900
4. http://svn.apache.org/r327903


Re: mod_dav: Can dav be enabled in the root / location?

Posted by Graham Leggett <mi...@sharp.fm>.
On 30 Dec 2013, at 6:14 PM, Eric Covener <co...@gmail.com> wrote:

> there is also a PR potentially in the same neighborhood:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=53929
> 
> For a while I thought it was a "remove DefaultType" issue in 2.4.x but
> I think that is probably wrong.

A quick look at the mod_dir code shows two problems.

The first is there is no way to switch mod_dir off - you add the module that means "on". If you need the module "on" in one virtual host, but "off" in another you're stuffed.

The second is that the module seems to want to respond to all methods, GET, POST, PROPFIND, etc when in theory it should only respond to GET.

In theory, if there was a way to switch mod_dir off in directory we could avoid the second problem in a dav virtual host.

Regards,
Graham
--


Re: mod_dav: Can dav be enabled in the root / location?

Posted by Eric Covener <co...@gmail.com>.
> It looks like the issue is affecting me - I am using v2.4.7, and mod_dir is present (but I can't turn it off without affecting other virtual hosts). It seems to affect directories where a directoryindex is present. Do you have a copy of the patch? If so I can test it and confirm the problem goes away.
>

there is also a PR potentially in the same neighborhood:
https://issues.apache.org/bugzilla/show_bug.cgi?id=53929

For a while I thought it was a "remove DefaultType" issue in 2.4.x but
I think that is probably wrong.

Re: mod_dav: Can dav be enabled in the root / location?

Posted by Graham Leggett <mi...@sharp.fm>.
On 31 Dec 2013, at 5:36 PM, Chris Darroch <ch...@pearsoncmg.com> wrote:

>   By any chance, are you using 2.4.x/trunk and do you have mod_dir
> included in the build?  I have a patch for a regression in 2.4.x/trunk
> where mod_dir "hijacks" PROPFIND and triggers a 405.  Try taking mod_dir
> out and see if that helps; if so, let me know and I'll endeavour to get
> my patch into trunk pronto.

It looks like the issue is affecting me - I am using v2.4.7, and mod_dir is present (but I can't turn it off without affecting other virtual hosts). It seems to affect directories where a directoryindex is present. Do you have a copy of the patch? If so I can test it and confirm the problem goes away.

Regards,
Graham
--


Re: mod_dav: Can dav be enabled in the root / location?

Posted by Chris Darroch <ch...@pearsoncmg.com>.
Graham Leggett wrote:

> I am currently struggling to turn mod_dav on. In theory, it is just
> "Dav on", but in practice I am getting a 405 Method Not Allowed
> in response to PROPFIND

   By any chance, are you using 2.4.x/trunk and do you have mod_dir
included in the build?  I have a patch for a regression in 2.4.x/trunk
where mod_dir "hijacks" PROPFIND and triggers a 405.  Try taking mod_dir
out and see if that helps; if so, let me know and I'll endeavour to get
my patch into trunk pronto.

   In fact, I have a long list of mod_dav patches in a queue, waiting
for some spare time (ha ha).  More seriously, I'm waiting to debug a
memory consumption issue first, and then I'll try to start pushing them
into trunk.

Chris.

Re: mod_dav: Can dav be enabled in the root / location?

Posted by Stefan Fritsch <sf...@sfritsch.de>.
Am Montag, 30. Dezember 2013, 16:48:51 schrieb Graham Leggett:
> I am currently struggling to turn mod_dav on. In theory, it is just
> "Dav on", but in practice I am getting a 405 Method Not Allowed in
> response to PROPFIND, and nothing in the error_log to give a clue
> that anything is wrong.

Having Multiviews enabled can give very weird results with mod_dav. 
Not sure that this is your problem, but maybe you should doublecheck 
that Multiviews is not inherited from somewhere else in your 
configuration.