… is a Perl CGI script that enables the WebDAV protocol (class 1,2,3) for web server. If you need correct permissions for files and folders you can install this WebDAV CGI script and a UID/GID wrapper. The Apache module mod_dav does not support UID/GID wrapping, so this implementation fills up this gap as a (most complete) replacement.

Content of this topic:

Features

WebDAV CGI …

  • supports WebDAV compliance classes 1, 2 and 3
  • implements CGI interface
  • offers a simple web interface for file/folder management
  • is wrappable to change UID/GID for file permissions other than web server permissions

My test environment:

  • Ubuntu 8.04 LTS
  • Apache 2.2.x
  • Perl 5.8.8

WebDAV CGI is tested with following WebDAV clients (licensing):

  • Firefox web browser – for folder listing, POST uploads and download tests (free)
  • M$ Internet Explorer 7 – for web interface tests (commercial)
  • cadaver – a Linux command line WebDAV client (free)
  • nautilus – the Gnome file manager (free)
  • konqueror – the KDE browser (free)
  • OpenOffice (free)
  • Web Folders – Windows XP & Windows Vista (build-in)
  • Novell netdrive (commercial)
  • BitKinex WebDAV Client (free)

Known Problems:

  • Windows Web Folder tries to read folders without ‘/’ at the end 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
  • DAVExplorer has some trouble with XML parsing (PROPFIND) … sometimes.
  • Adobe Dreamweaver has some trouble to read folders
  • nautilus cannot copy folders via clipboard

Download

TuXxX Blog download :

the WebDAV CGI WebDavCGI.zip Version: 0.3.3
13.6 KiB 1227 Downloads Details...

Latest version: 0.3.3 (Changes: see webdav.pl)

  • webdav.pl – the WebDAV CGI
    Downloads: 35
  • webdavwrapper.c – a sample UID/GID wrapper: takes UID from the file/folder or if file/folder does not exists takes the UID of the authenticated user (REMOTE_USER)
    Downloads: 18

The latest BETA release is also available: webdav-beta.pl (Downloads: 8)

Installation

  1. install required CPAN modules (Debian/Ubuntu package name):
    • CGI (libcgi-perl)
    • DBI (libdbi-perl) and a database driver, e.g. DBD::SQLite (libdbd-sqlite3-perl)
    • Date::Parse (libtimedate-perl)
    • File::Copy::Recursive (libfile-copy-recursive-perl)
    • OSSP::uuid (libossp-uuid-perl)
    • XML::Simple (libxml-simple-perl)

    You can do that with ‘perl -MCPAN -e "install <ModuleName>"‘ or with ‘apt-get install <PackageName>‘.

  2. compile your wrapper, change the permissions and put it into your cgi-bin, e.g:
    gcc -o webdavwrapper webdavwrapper.c
    strip webdavwrapper
    
    chown root:root webdavwrapper
    chmod ug+s webdavwrapper
    
    cp -p webdavwrapper /srv/www/cgi-bin/
    
  3. put the WebDAV CGI webdav.pl into your cgi-bin; edit webdav.pl to setup and change permissions, e.g:
    cp webdav.pl /srv/www/cgi-bin
    vim webdav.pl
    chmod a+rx webdav.pl
    
  4. configure your web server:
    • you can do that with rewrite rules
    • or with a handler action

    Here is an example Apache 2.x configuration:

    Action webdav-cgi /cgi-bin/webdavwrapper
    <Location /mywebdavspace>
    	SetHandler webdav-cgi
    	#necessary for PUT, MKCOL and LOCK:
    	ErrorDocument  404  /cgi-bin/webdavwrapper
    	#fix Windows requests to folders without slash (handle redirects):
    	ErrorDocument  301  /cgi-bin/webdavwrapper
    	AuthType Basic
    	AuthName "WebDAV space"
    	AuthUserFile /path-to-my-auth-file
    	Require valid-user
    </Location>
    # if you want to map this to a real path, do that:
    # (end setup VIRTUAL_BASE)
    RewriteRule  ^/mywebdavspace(.*) /cgi-bin/webdavwrapper \
    	[L,E=PATH_TRANSLATED:/srv/www/htdocs$1]
        

Licensing

GPLv3

Links

the WebDAV CGI WebDavCGI.zip Version: 0.3.3
13.6 KiB 1227 Downloads Details...