
		mod_dav_fs_diskquota for Apache 2.0

	by Akira YOSHIYAMA <yosshy@debian.or.jp>, March 15, 2006

ABOUT
-----
mod_dav_fs_diskquota is a derived work of mod_dav_fs in Apache 2.0.55.
When it creates files/directories, it changes their owner for OS user
account that has same name of the web-authorized user, so OS disk
quota works fine for WebDAV contents.


BASIC IDEA
----------
mod_dav_fs_diskquota makes new files/directories:

   owner: OS user account (= same name of Web authorized account)
   group: Apache group account
   mode: user=readable/writable, group=readable/writable

The owner of them is an user account, so amount of them is limited by
OS disk quota. Apache can treat them with group permission. To change
files/directories owner, we need to:

1.Give CAP_NET_BIND_SERVICE and CAP_CHOWN capability to Apache.

2.Run Apache as non-root account from beginning. (otherwise, Apache
  process changes its UID as apache user and it drops above
  capabilities.)


LICENSE
-------
mod_dav_fs_diskquota has Apache license. See each file for details.


INSTALL and RUN
---------------
1.Give CAP_NET_BIND_SERVICE and CAP_CHOWN capability to the Apache. I
  tested with capability override LSM
  (http://www.randombit.net/projects/cap_over/).  See example/CapOver
  directory and you find sample configuration files.

2.Modify these parameters in Makefile for your software environment.
  (Now, these are for Debian GNU/Linux.)
	top_srcdir=/usr/share/apache2
	top_builddir=/usr/share/apache2
	include /usr/share/apache2/build/special.mk
	APXS=apxs2
	APACHECTL=apache2ctl

3.Type below:
	make
	su
	make install

4.Stop httpd.
	Debian: /etc/init.d/apache2 stop
	RedHat: /etc/init.d/httpd stop

5.Change owner of some directories/files as the Apache account.
  (Debian)
	chown -R www-data.www-data /var/lib/apache2/
	chown -R www-data.www-data /var/log/apache2/
	chown -R www-data.www-data /var/run/apache2/
	mkdir /var/www/dav
	chown www-data.www-data /var/www/dav
	chmod 770 /var/www/dav
  (RedHat? I don't know about them well, perhaps below:)
	chown -R apache.apache /var/log/httpd/
	chown -R apache.apache /var/run/httpd/
	mkdir /var/www/dav
	chown apache.apache /var/www/dav
	chmod 770 /var/www/dav

6.Modify apache configuration file.
	before: PidFile /var/run/apache2.pid
 	after:  PidFile /var/run/apache2/apache2.pid

	(Debian: /etc/apache2/mods-enabled/dav_fs.load)
	before: LoadModule dav_fs_module /usr/lib/apache2/modules/mod_dav_fs.so
	after:  LoadModule dav_fs_module /usr/lib/apache2/modules/mod_dav_fs_diskquota.so

	(RedHat)
	before: LoadModule dav_fs_module modules/mod_dav_fs.so
	after:  LoadModule dav_fs_module modules/mod_dav_fs_diskquota.so

	and add dav configuration like below:
---
    Alias /dav/ "/var/www/dav/"
    <Directory "/var/www/dav/">
        DAV on
	AuthType Basic
	AuthUserFile /etc/apache2/htpasswd
	AuthName "WebDAV folder"
	satisfy any
	require valid-user
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
    </Directory>
---

7.If you want to create /etc/apache2/htpasswd file, type below:
	Debian: htpasswd2 -c /etc/passwd2/htpasswd <account>
	RedHat: htpasswd -c /etc/passwd2/htpasswd <account>
  <accout> must be same name of OS account.

8.Modify rc file for Apache.
	(Debian: /etc/init.d/apache2)
	before: $APACHE2CTL startssl
	after:  su www-data -c "$APACHE2CTL startssl"

	(RedHat: /etc/init.d/httpd)
	before: daemon $httpd $OPTIONS
	after:  daemon --user=apache $httpd $OPTIONS

9.Just run Apache.
	Debian: /etc/init.d/apache2 start
	RedHat: /etc/init.d/httpd start

10.Test it.

11.Enjoy it :-).


CHANGLOG
--------
Mar 15, 2006 initial release.
