# WebDAV CGI: Troubleshooting Guide

## Client issues

- Speedy is supported since v0.5.3 but if you get "Out of memory" messages in your Apache error log you must set "MaxRuns", e.g. `#!/usr/bin/speedy -- -r20`
- Windows Web Folder tries to read folders without a trailing '/' and Apache responses with a redirect (Workaround: use Apache rewrite rule instead of direct folder access)
- Windows 7 does not support SSL with Web Folders (yet) and has some trouble with HTTP Basic authentication (`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters\BasicAuthLevel` should be `2`(DWORD))
- Amaya upload does not work yet in some configurations (works only with rewrites not with error handler)
- DAVExplorer has some trouble with XML parsing (PROPFIND) ... sometimes.
- nautilus cannot copy folders via clipboard
- more: see Client issues

Finder (MacOS X 10.x):

- ... is really slow because the MacOS X Finder generates a lot of requests to get Apple doubleheaders and to put .DS_Store files.
- a solution is to use CyberDuck instead of Finder
- or speed up the Finder a little bit: disable Finder previews and prevent .DS_Store file creation.

iCal:

- You must specifiy the server port, e.g. cal.example.org:80

Addressbook (MacOS X 10.6.x):

- WebDAV CGI must run in a root context (WebDAV CGI must handle the root of your (virtual) server)
- You must specify the server port, e.g. abook.example.org:80

iPhone/iPad:

- you must change the Account-URL to work with WebDAV CGI: it should be the same as your CalDAV folder URL or principal URL:
  1. Settings > Other > Add CalDAV Account
  2. Setup Server (e.g. https://www.example.org:443/webdav/caldav/), Username and Password
  3. Next > Advanced Settings > Account URL (e.g. https://www.example.org:443/webdav/caldav/)

Windows Vista/7:

- Slow response working with WebDAV resources on Windows Vista or Windows 7: see http://support.microsoft.com/kb/2445570 OR http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol

## Setup/Configuration issues

### Timeout

Maybe it helps to increase the `Timeout` value in your Apache configuration (300 is a good minimum value).
If a larger `Timeout` value does not fix the problem perhaps the Apache mod_reqtimeout is loaded. You should disable this module (Debian/Ubuntu: `a2dismod reqtimeout; /etc/init.d/apache2 restart`) or configure it with larger values.

### Apache error log: `Request exceeded the limit of X internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.`

This is a typical rewrite misconfiguration. A common mistake is to take the `.htaccess` rewrite rule example for the Apache configuration. A rule like `RewriteRule .* ...` in the Apache configuration runs into a 'endless' recursion only stopped by the Apache limit (`LimitInternalRecursion`). Please use a rule like `RewriteRule ^/ ...` to fix this problem. In a `.htaccess` makes the pattern `^/` no sense because this pattern will never match. Rewite rule patterns in a `.htaccess` have to be relative to the current path therefore `.*` works fine.
If this does not help put the following to your Apache configuration:

    RewriteLogLevel 3
    RewriteLog /var/log/apache2/rewrite.log

and analyze the `rewrite.log` after a single access to your WebDAV area and don't forget to set the `RewriteLogLevel` back to `0` after your debug session.

### 404 File Not Found / 500 Internal Server Error / 'Premature end of script headers'

Please check the following:

1. Apache error log - Apache writes sometimes helpful things into logs
2. read and execute file permissions of `webdavwrapper` and `webdav.pl` and fix it if necessary (owner/group too):

       chmod a+rx webdav.pl
       chmod a+rx,ug+s webdavwrapper
       chown root:root webdavwrapper

3. shebang of `webdav.pl`: path to the Perl interpreter have to be correct
4. `/etc/webdav.conf` syntax (maybe a broken config):

       #> perl -c /etc/webdav.conf
       webdav.conf syntax OK

5. check your /etc/webdav.conf: wrong `$VIRTUAL_BASE` or `$DOCUMENT_ROOT` values are cause for a 404 File Not Found
6. `webdav.pl` syntax (maybe a broken config or a missing Perl module):

       #> perl -I/etc/webdavcgi/lib/perl -c webdav.pl
       webdav.pl syntax OK

       #> bash /etc/webdavcgi/checkenv
       +++ Checking perl:
         perl /usr/bin/perl
       ++++ Checking required modules:
         CGI installed
         DBI installed
         POSIX installed
         File::Temp installed
         Date::Parse installed
         UUID::Tiny installed
         XML::Simple installed
         Quota installed
         Archive::Zip installed
         IO::Compress::Gzip installed
         IO::Compress::Deflate installed
         Digest::MD5 installed
         Module::Load installed
       ++++ Checking optional modules:
         DBD::SQLite installed
         DBD::mysql installed
         DBD::Pg installed
       ++++ Checking required modules for FS backend:
         File::Spec::Link installed
       ++++ Checking required modules for AFS backend:
         File::Spec::Link already checked
       ++++ Checking required modules for GFS backend:
         File::Spec::Link already checked
       ++++ Checking required modules for SMB backend:
         Filesys::SmbClient installed
       ++++ Checking required modules for RCS backend:
         Rcs installed
       ++++ Checking optional binaries:
         smbclient /usr/bin/smbclient
       #### Summary:
       All modules found.
       All binaries found.

7. Check your database setup (`$DBI_SRC`, `$DBI_USER`, `$DBI_PASS`).
8. Call webdav.pl from a shell:

       #> env WEBDAVCONF=/etc/webdav.conf perl -I/etc/webdavcgi/lib/perl webdav.pl
       DAV: 1, 2, 3, <http://apache.org/dav/propset/fs/1>, extended-mkcol, access-control, calendar-access, calendarserver-private-comments, calendar-auto-schedule, addressbook, bind
       MS-Author-Via: DAV
       Status: 404 Not Found
       Date: Mon, 14 Mar 2011 12:51:35 GMT
       Etag: "d41d8cd98f00b204e9800998ecf8427e"
       Content-length: 0
       Content-Type: text/plain; charset=utf-8

9. Call webdavwrapper from a shell:

       #> ./webdavwrapper
       Status: 404 Not Found
       Content-Type: text/plain

       404 Not Found - your wrapper

10. Contact the author

### FreeBSD/OpenBSD: all LOCK requests result in a segmentation fault error (signal 11)

In some installations OSSP::uuid module lets Perl crashing with a segmentation fault. A solution is to replace OSSP::uuid with UUID::Tiny (thx Tony Wijnhard):

1. install UUID::Tiny: `perl -MCPAN -e 'install UUID::Tiny'`
2. replace `use OSSP:uuid;` with `use UUID::Tiny;`:

       sed -i -e 's@use OSSP::uuid;@use UUID::Tiny;@g' webdav.pl

3. replace `sub getuuid {` with `sub _unused_getuuid {`:

       sed -i -e 's@^sub getuuid@sub _unused_getuuid@g' webdav.pl

4. add a new getuuid routine to webdav.pl:

       cat - >>webdav.pl <<'EOF'
       sub getuuid {
               my ($fn) = @_;
               my $uuid_ns = create_UUID(UUID_V1, "opaquelocktoken:$fn");
               my $uuid = create_UUID(UUID_V3, $uuid_ns, "$fn".time());
               debug("_LOCK after uuid made in method:");
               return UUID_to_string($uuid);
       }
       EOF

### Web interface: Copy/Cut/Paste and bookmarks do not work as expected.

WebDAV CGI uses the 'secure' flag for cookies. If you access the Web interface without encryption (http instead of https) all cookie based actions do not work.

### Web interface: missing stylesheets, locales, and/or icons

1. Check your `$INSTALL_BASE` variable in your `/etc/webdav.conf` (maybe you forget the trailing slash?)
2. Check /etc/webdav.conf syntax: `perl -c /etc/webdav.conf`
3. Check your Apache rewrite rule: the path to your webdav.conf must be correct: `E=WEBDAVCONF:/etc/webdav.conf`

### Web interface: wrong date/time/number formatting for a language

WebDAV CGI uses language specific formattings for date/time/numbers. Check your locales

    #> locale -a
    de_DE.utf8
    en_US.utf8
    fr_FR.utf8
    hu_HU.utf8
    it_IT.utf8

and install missing locales for the language with a wrong date/time/number formatting, e.g. Ubuntu:

    # add new locale entry to the list:
    echo fr_FR.UTF-8 UTF-8 >> /var/lib/locales/supported.d/local
    # or add all supported locales (! slows down package installation/updates):
    ### cp /usr/share/i18n/SUPPORTED /var/lib/locales/supported.d/local

    # and don't forget to compile locale definition files:
    locale-gen

### Slow response working with WebDAV resources on Windows Vista or Windows 7

see http://support.microsoft.com/kb/2445570
OR: see http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol

### RedHat/Fedora/CentOS: Graphics::Magick does not compile

see https://bugzilla.redhat.com/show_bug.cgi?id=527143#c2

### Apache error log: Permission denied: exec of '.../webdavwrapper' failed

- Check all file and folder permissions (Apache runs with user permissions)
- SELinux users should define a policy to allow the execution of webdavwrapper.

### Speedy problems with different WebDAV CGI instances on a single server

If you run multiple WebDAV CGI instances on a single server with different setups and databases you have to separate the Speedy instances. This can be done with a additional rewrite option: `E=SPEEDY_TMPBASE:myprojecttmpbase` (replace `myprojecttmpbase` with a unique name for a WebDAV CGI instances, e.g. `E=SPEEDY_TMPBASE:/tmp/project2`)

## Common issues

### Wide character in print at ... warning

You can ignore this warning.

© ZE CMS, Humboldt-Universität zu Berlin | Written 2010-2015 by Daniel Rohde