Kozea / Radicale

A simple CalDAV (calendar) and CardDAV (contact) server.
https://radicale.org
GNU General Public License v3.0
3.39k stars 444 forks source link

problem discovering calendars with radicale in non-root of Apache (with fix) #147

Closed jheidemann closed 10 years ago

jheidemann commented 10 years ago

radicale's listing multiple calendars under a single user doesn't work when radicale runs using apache for configuration, IF radicale is not at the root of a virtual server. (e.g., if it is at www.example.com/caldav/ instead of caldav.example.com/).

What happens? giving www.example.com/caldav/user/ to acal (on android) checks out as caldav, but it doesn't list any sub-calendars, even if www.example.com/caldav/user/foo.ics/ and www.example.com/caldav/user/bar.ics/ exist.

What should happen? In acal, "list calendars" should find foo.ics and bar.ics.

why? apache strips off the /caldav/ base prefix. Radicale then returns entries with short href's (/user/, /user/foo.ics/, /user/bar.ics/) in response to the PROPFIND Depth: 1 query during discovery.

But these hrefs are wrong... they're missing /caldav/.

One might think fixing this by putting base_prefix=/caldav/ in /etc/radicale/config would do the trick, but no: because Apache strips that off, this config fails the check "Path not starting with prefix" in radicale.init.

Suggested fix:

add a new config parameter: can_skip_base_prefix that avoids this check. It all then works, provided this goes in the config: base_prefix=/caldav/ can_skip_base_prefix=True

Patch:

--- __init__.py-    2013-07-12 08:45:26.000000000 -0700
+++ __init__.py 2014-04-19 11:10:43.791856360 -0700
@@ -252,6 +252,8 @@
             environ["PATH_INFO"] = self.sanitize_uri(
                 "/%s" % environ["PATH_INFO"][len(base_prefix):])
             log.LOGGER.debug("Sanitized path: %s", environ["PATH_INFO"])
+        elif config.get("server", "can_skip_base_prefix"):
+            log.LOGGER.debug("skipped already sanitized path: %s", environ["PATH_INFO"])
         else:
             # Request path not starting with base_prefix, not allowed
             log.LOGGER.debug(
--- config.py-  2014-04-19 11:01:38.655498852 -0700
+++ config.py   2014-04-19 11:06:04.930683289 -0700
@@ -47,6 +47,7 @@
         "key": "/etc/apache2/ssl/server.key",
         "dns_lookup": "True",
         "base_prefix": "/",
+        "can_skip_base_prefix": "False",
         "realm": "Radicale - Password Required"},
     "encoding": {
         "request": "utf-8",

against radicale-0.8-7.fc20.noarch Other patches are of course possible and perhaps cleaner; this one works for me.

This fix addresses two issues on http://radicale.org/user_documentation/#idapache-and-mod-wsgi

  1. the statement: "The [server] part of the configuration is ignored." is not true. Giving a base_prefix is enforced.
  2. The statement "You should use the root of the (sub)domain (WSGIScriptAlias /), else some CalDAV features may not work." is true and is the limitation I hit. With the patch, this statement should change to : "If you have a non-empty base_prefix, then you MUST set "can_skip_base_prefix=True" in your config or some CalDAV features (like discovering calendars) will not work.
liZe commented 10 years ago

The bug is fixed, the documentation must be updated when 0.9 is released.