librelist archives

« back to archive

silent error 500

silent error 500

From:
Dmitry Borodaenko
Date:
2011-10-19 @ 13:04
Trying to PUT a calendar entry with curl gives me an error 500 without
anything useful in the logs:

$ curl --no-keepalive -vnkT test.ics http://127.0.0.1:5232/angdraug/calendar
* About to connect() to 127.0.0.1 port 5232 (#0)
*   Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 5232 (#0)
* Server auth using Basic with user 'angdraug'
PUT request at /angdraug/calendar received
> PUT /angdraug/calendar HTTP/1.1
> Authorization: Basic (removed)
> User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 
OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
> Host: 127.0.0.1:5232
> Accept: */*
> Content-Length: 3222
> Expect: 100-continue
>
* Done waiting for 100-continue
Checking rights for calendar owned by angdraug
angdraug allowed
* HTTP 1.0, assume close after body
< HTTP/1.0 500 Dude, this is whack!
< Date: Wed, 19 Oct 2011 12:45:59 GMT
< Server: WSGIServer/0.1 Python/2.6.6
< Content-Type: text/plain
< Content-Length: 59
<
* we are done reading and this is set to close, stop send
* Closing connection #0
A server error occurred.  Please contact the administrator.

Log contents:

2011-10-19 13:45:58,026 - INFO: PUT request at /angdraug/calendar received
2011-10-19 13:45:58,028 - DEBUG: Request headers:
{'CONTENT_LENGTH': '3222',
 'CONTENT_TYPE': 'text/plain',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': '*/*',
 'HTTP_AUTHORIZATION': 'Basic (removed)',
 'HTTP_EXPECT': '100-continue',
 'HTTP_HOST': '127.0.0.1:5232',
 'HTTP_USER_AGENT': 'curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0
OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6',
 'PATH_INFO': '/angdraug/calendar',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '127.0.0.1',
 'REMOTE_HOST': 'localhost',
 'REQUEST_METHOD': 'PUT',
 'SCRIPT_NAME': '',
 'SERVER_NAME': 'localhost',
 'SERVER_PORT': '5232',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.6.6',
 'wsgi.errors': <open file '/dev/null', mode 'w' at 0xaa0f60>,
 'wsgi.file_wrapper': <class wsgiref.util.FileWrapper at 0x7ff3a3f75ef0>,
 'wsgi.input': <socket._fileobject object at 0xb2c5d0>,
 'wsgi.multiprocess': False,
 'wsgi.multithread': True,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)}
2011-10-19 13:45:58,028 - DEBUG: Sanitized path: /angdraug/calendar
2011-10-19 13:45:59,030 - DEBUG: Request content:
BEGIN:VCALENDAR
...
END:VCALENDAR

2011-10-19 13:45:59,030 - INFO: Checking rights for calendar owned by angdraug
2011-10-19 13:45:59,030 - INFO: angdraug allowed

Happens with any calendar file I got. The system is Debian/squeeze.

How do I make it write errors anywhere useful (looks like it defaults
to dumping them to /dev/null)? Generally would be nice if at least
when log level is set to DEBUG, exceptions are dumped into the same
log...

--
Dmitry Borodaenko

Re : [radicale] silent error 500

From:
Vincent Cadet
Date:
2011-10-19 @ 13:54

Hi Dimitri.

[...]


>Happens with any calendar file I got. The system is Debian/squeeze.
>
>How do I make it write errors anywhere useful (looks like it defaults
>to dumping them to /dev/null)? Generally would be nice if at least
>when log level is set to DEBUG, exceptions are dumped into the same
>log...


I found Python errors were sent to apache log, /var/log/apache2/ssl_errors
in my case but it depends on your apache configuration for the error log.

Cheers,
Vince C.

Re: Re : [radicale] silent error 500

From:
Dmitry Borodaenko
Date:
2011-10-19 @ 14:27
On Wed, Oct 19, 2011 at 16:54, Vincent Cadet <v_cadet@yahoo.fr> wrote:
> I found Python errors were sent to apache log, 
/var/log/apache2/ssl_errors in my case but it depends on your apache 
configuration for the error log.

Thanks! This means it goes to stderr, so all I had to do to get to it
was disable daemon mode:

IOError: [Errno 21] Is a directory: '/var/lib/radicale/calendars/angdraug'

Now I just need to figure out why, when I remove that directory,
instead of 500 I get 401:

PUT request at /angdraug/calendar received
Checking rights for calendar owned by nobody
angdraug refused

--
Dmitry Borodaenko

Re: Re : [radicale] silent error 500

From:
Dmitry Borodaenko
Date:
2011-10-19 @ 15:53
On Wed, Oct 19, 2011 at 17:27, Dmitry Borodaenko <angdraug@gmail.com> wrote:
> IOError: [Errno 21] Is a directory: '/var/lib/radicale/calendars/angdraug'
>
> Now I just need to figure out why, when I remove that directory,
> instead of 500 I get 401:
>
> PUT request at /angdraug/calendar received
> Checking rights for calendar owned by nobody
> angdraug refused

After a quick look at ical.py, I'm getting the impression that I'm hit
by a double whammy of two bugs: radicale shouldn't crash if the
/angdraug/calendar directory does exist, and it should be able to
figure out it's owned by user angdraug, not nobody, when the directory
doesn't exist.

Can anyone more familiar with the code come up with a fix for these?
Or fix for the documentation, in case I'm doing anything wrong?

In case it helps to replicate these bugs, here's what I changed in the
default config:

--- config      2011-10-04 05:42:08.000000000 +0100
+++ /etc/radicale/config        2011-10-19 15:33:36.127436040 +0100
@@ -37,18 +37,18 @@
 [acl]
 # Access method
 # Value: None | htpasswd | LDAP | PAM | courier
-type = None
+type = htpasswd

 # Usernames used for public calendars, separated by a comma
-public_users = public
+public_users =
 # Usernames used for private calendars, separated by a comma
-private_users = private
+private_users = angdraug

 # Htpasswd filename
 htpasswd_filename = /etc/radicale/users
 # Htpasswd encryption method
 # Value: plain | sha1 | crypt
-htpasswd_encryption = crypt
+htpasswd_encryption = sha1

 # LDAP server URL, with protocol and port
 ldap_url = ldap://localhost:389/
@@ -71,7 +71,7 @@

 [storage]
 # Folder for storing local calendars, created if not present
-folder = ~/.config/radicale/calendars
+folder = /var/lib/radicale/calendars


 [logging]


Thanks,

--
Dmitry Borodaenko

Re: Re : [radicale] silent error 500

From:
Guillaume Ayoub
Date:
2011-10-19 @ 16:22
Le mercredi 19 octobre 2011 à 18:53 +0300, Dmitry Borodaenko a écrit :
> On Wed, Oct 19, 2011 at 17:27, Dmitry Borodaenko <angdraug@gmail.com> wrote:
> > IOError: [Errno 21] Is a directory: '/var/lib/radicale/calendars/angdraug'
> >
> > Now I just need to figure out why, when I remove that directory,
> > instead of 500 I get 401:
> >
> > PUT request at /angdraug/calendar received
> > Checking rights for calendar owned by nobody
> > angdraug refused
> 
> After a quick look at ical.py, I'm getting the impression that I'm hit
> by a double whammy of two bugs: radicale shouldn't crash if the
> /angdraug/calendar directory does exist, and it should be able to
> figure out it's owned by user angdraug, not nobody, when the directory
> doesn't exist.
> 
> Can anyone more familiar with the code come up with a fix for these?
> Or fix for the documentation, in case I'm doing anything wrong?
> 
> In case it helps to replicate these bugs, here's what I changed in the
> default config: […]

Hello Dmitry,

Radicale is really bad at handling the requests not sent by a "real"
CalDAV client. And if you wonder: it's not a bug, it's a feature!

http://radicale.org/technical_choices/#oriented-to-calendar-user-agents

Radicale is *full* of bugs like this one. They will not be fixed as it
would multiply the number of lines by 10 (at least) :).

Quick and dirty solution: adding a slash at the end of your curl URL
should work (curl --no-keepalive -vnkT test.ics
http://127.0.0.1:5232/angdraug/calendar/). Radicale relies on this
trailing slash, even if it shouldn't.

I hope that it'll help!

Regards,
-- 
Guillaume

Re: Re : [radicale] silent error 500

From:
Dmitry Borodaenko
Date:
2011-10-21 @ 09:30
Guillaume,

Thanks for the advice, adding slash did help!

Even if curl is not a proper CalDAV client, I think it's worth
documenting how to make it work with Radicale. After all, Radicale
with its simple setup and minimalistic implementation is a perfect fit
for people like me who use mutt for email.

Here's how I use it, maybe other people find it useful too:

~/.mutt/muttrc:
macro attach C '|~/bin/mutt-upload-calendar
https://calendarserver:5232/angdraug/calendar/'\n

~/bin/mutt-upload-calendar:
#!/bin/sh
URL=$1
ICAL=`tempfile -pmutt-`
cat > "$ICAL"
curl --no-keepalive -nkT "$ICAL" "$URL"
rm "$ICAL"

~/.netrc:
machine calendarserver
    login angdraug
    password secret

When viewing an email with a calendar event in Mutt, press 'v' to view
the list of attachments, select the 'text/calendar' attachment and
press 'C' to send the event to your Radicale server.

You might also want to drop the -k option to curl so that it validates
the server certificate, otherwise you would be susceptible to a MitM
attack.

--
Dmitry Borodaenko


On Wed, Oct 19, 2011 at 19:22, Guillaume Ayoub <guillaume.ayoub@kozea.fr> wrote:
> Le mercredi 19 octobre 2011 à 18:53 +0300, Dmitry Borodaenko a écrit :
>> On Wed, Oct 19, 2011 at 17:27, Dmitry Borodaenko <angdraug@gmail.com> wrote:
>> > IOError: [Errno 21] Is a directory: '/var/lib/radicale/calendars/angdraug'
>> >
>> > Now I just need to figure out why, when I remove that directory,
>> > instead of 500 I get 401:
>> >
>> > PUT request at /angdraug/calendar received
>> > Checking rights for calendar owned by nobody
>> > angdraug refused
>>
>> After a quick look at ical.py, I'm getting the impression that I'm hit
>> by a double whammy of two bugs: radicale shouldn't crash if the
>> /angdraug/calendar directory does exist, and it should be able to
>> figure out it's owned by user angdraug, not nobody, when the directory
>> doesn't exist.
>>
>> Can anyone more familiar with the code come up with a fix for these?
>> Or fix for the documentation, in case I'm doing anything wrong?
>>
>> In case it helps to replicate these bugs, here's what I changed in the
>> default config: […]
>
> Hello Dmitry,
>
> Radicale is really bad at handling the requests not sent by a "real"
> CalDAV client. And if you wonder: it's not a bug, it's a feature!
>
> http://radicale.org/technical_choices/#oriented-to-calendar-user-agents
>
> Radicale is *full* of bugs like this one. They will not be fixed as it
> would multiply the number of lines by 10 (at least) :).
>
> Quick and dirty solution: adding a slash at the end of your curl URL
> should work (curl --no-keepalive -vnkT test.ics
> http://127.0.0.1:5232/angdraug/calendar/). Radicale relies on this
> trailing slash, even if it shouldn't.
>
> I hope that it'll help!
>
> Regards,
> --
> Guillaume
>