CONTENTS [0] Technical stuff / Installation [0.1] Perl Setup [0.2] Apache Setup [0.2] Davmap script installation [1] Configuration/Running [1.1] perms.cf [1.2] Logs [2] Appendices [2.1] davmap script & modules [2.2] Apache source diff [2.3] Example perms.cf file [0] - Technical stuff / Installation build instruction: [0.1] - Perl Setup Get Quota (current version used 1.5.1) module for perl, build and install: perl Makefile.PL && PATH=PATH=/tool/lang11.1/SUNWspro/bin:$PATH make install [0.2] - Apache Setup Get Apache and compile it with unsafe options (-DBIG_SECURITY_HOLE, to allow it to run as root). modules/dav/main/mod_dav.c patched to chown files after creation (could be done in the perl): See [3.2] for the patch. (preference might be to proxy-pass from a front-end apache through to apaches running as the user accessing the share. Would need quite a few of these running of difference ports. Trickier to manage, harder to diagnose...) davmap lives in /opt/davmap. Relevant lines in apache are: > ------ CUT HERE ---------- LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so DAVLockDB /var/httpd/davlocks/DAVLockDB-localroot RewriteEngine On RewriteLock /opt/davmap/rewrite.lck ### Main R&D site RewriteEngine On RewriteMap davaccessmap prg:/opt/davmap/davmap.pl AuthType Basic AuthName "DAV File access" AuthUserFile /usr/local/etc/htpasswd Require valid-user Options -Indexes RewriteEngine On # Must be this order! RewriteRule (.*) ${davaccessmap:%{REQUEST_METHOD}-%{REMOTE_USER}-$1} [L] Dav On > ------ CUT HERE ---------- [0.2] - Davmap script installation Install in /opt/davmap/ (see appendices for source) [1] Configuration/Running [1.1] perms.cf These define above-and-beyond the unix permission access (or lack thereof) for users of the system. Everyone, by default, has access to their /home directory. The permissions maps are such that, for any given directory, you can take away access to users, or grant them access. Unix permissions are still queried and applied. If you grant a user access to a directory they wouldn't ordinarily have access to, then they still shouldn't be able to access it. The constants at the top of the perms.cf file are important and are mirrored in the davmap.pl script, so don't change the values here. Permissions are configured by creating a key in the hash, the name of which is the directory you wish to apply ACLs to. This is a reference to another hash, which defines which users are to be granted/denied access to this directory. 'ALL' is a wildcard matching everyone. Aside from this, use a user's id to set the access for that particular user. The user's own id should override the wildcard. There are four values you can assign for the access requirement. NOACCESS means the user doesn't have access at all. WRITE means they can WRITE and READ means they can READ. The fourth value; INHERIT; means that the access is granted for directories below here (assuming no more specific case matches, in which case, the rules defined there will take precedent). [1.1] Logging There's a whole load of stuff logged in /var/log/davmap.log. - probably too much. [2] Appendices [2.1] - davmap script & modules > ------ CUT HERE ---------- begin-base64 644 davmap.tar H4sIAE6g7UkAA+1aa1MbyZKdr+JXFEK2WjNCLWFj78JimzGyhxgMXMDjuwtY0ZJKUo9b 3aIfCC0wv/2ezKrqhxD4MTF3diMsgpC665FZWZknH1V7wXDo+sPGZPzDX/Zp4vPs6VP+ xkd/t8xz83nz6Q+tVmu9tbbefPb8Od63nrTW139o/nUsZZ8kip0QJMMgiB/qF8QjGT7Q zktaW08X+f/kM3F6n5yhFHtKDzaXlpJIivbVJAhjGeLx1e7x9tbF1DKvavSu/c/Dg6MT eh1MpN/xgqHoeUEk+Rf+PdeXInb7kwl1H89EBQ9iSzTxFCVdkY66XirRb2vv4G29+uJF VTRENHIHsXjVqYmbGxHKOAl9GleKpCd7MfXEnKXKzVYLk5m3xyc7B+9P0HCrCGTcgAI/ 6IG63fCI1hV6ENhdMDyWdTGW8Sjo14Xv0NPA9aRw/D44iRIvpu7WOIhiEQwwxo3E1PU8 0ZXC9XkOBwLFF6aM8Bwkw1FtqbRUmoSuHwuwIKqnvMie4zkhuuGbyFo1vCyL3Z0NJapz Ua5DBnVRPvPLKdcsUeKZ+vz0E7+HFP7M/m/3ejKK3seuF/1lGMA2vr5+j/23njVbLbL/ 50+erOHnE7b/58+/2/+/42PsP6cHGgPe9PzYE9WNcdCX1c05WKCnFDLo4R9JEDt6ZBSH bi/WD5dOGAkABeGI0MBR+zyujJ1JZyLDcdQJPonEd6/mnhzmV6gveuv6btzBKDEKxrLv huKCOEILTRwkobAquqVHFloXlcTtR/gahkEyifTLR0yFhqyIbeG52tCDyaonL6UnJk48 IsN2YvE7NAfPYI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IT5jEv1OseYJddTUqPa7hKU1xIQes+eXmF5sXiZXeHAcV/dv4Z64K qLEYlt0yN+2ZaPLHko0t4pC5hpFNpfiR8fvHFMBT9iywEyFAgilTGRXGyEPUOaqKzeB1 EZ2RQdTovByzKWfA90i7cAbO/84waOpAMOWKKTlqCmWSYqb5uTsW+eLqog4Lq+AZFt4p LOcrTEZkBSlXJrryyjUitBYdq4o9upKr0IPEU+cVDmUPlzKMkoh/O12HfXYQ9vgYWUSe A70JVPQhfYq3rhDUSrr5wgXZBhlFdoJnnHq/l53h3bkCYtSOGN3MjwZe0siFg5Ts7TIF XAjKaCyHYfnx23t74uDXZWXPhVre353Pff98/3z/fP986edfZLY0mAA4AAA= ==== > ------ CUT HERE ---------- [2.2] - Apache source diff (diff against 2.2.11) > ------ CUT HERE ---------- --- mod_dav.c.orig Wed Mar 11 12:57:25 2009 +++ mod_dav.c Thu Apr 16 15:56:01 2009 @@ -42,6 +42,9 @@ * so that we can keep the connection open. */ +/* andyw 20090311 */ +#include + #include "apr_strings.h" #include "apr_lib.h" /* for apr_is* */ @@ -72,6 +75,14 @@ DAV_ENABLED_ON }; +/* andyw 20090416 */ +struct dav_resource_private { + apr_pool_t *pool; /* memory storage pool associated with request */ + const char *pathname; /* full pathname to resource */ + apr_finfo_t finfo; /* filesystem info */ +}; + + /* per-dir configuration */ typedef struct { const char *provider_name; @@ -103,7 +114,6 @@ }; static int dav_methods[DAV_M_LAST]; - static int dav_init_handler(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { @@ -616,6 +626,9 @@ return DONE; } +/* andyw 20090311 */ +static int do_rd_own(request_rec*); + /* handy function for return values of methods that (may) create things */ static int dav_created(request_rec *r, const char *locn, const char *what, int replaced) @@ -622,6 +635,8 @@ { const char *body; + do_rd_own(r); + if (locn == NULL) { locn = r->uri; } @@ -4800,6 +4815,44 @@ dav_core_register_uris(p); } +/* andyw 20090311 - attempt own the resource as REMOTE_USER */ +static int do_rd_own(request_rec *r) +{ + dav_resource *resource; + dav_error *err; + struct passwd *ht_pwnam; + + err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */, + &resource); + + if (err != NULL) { + err = dav_push_error(r->pool, err->status, 0, + "do_rd_own: Unable to fetch dav resource.", + err); + return dav_handle_err(r, err, NULL); + } + + ht_pwnam = getpwnam( r->user ); + + if (ht_pwnam == NULL) { + err = dav_push_error(r->pool, err->status, 0, + "do_rd_own: Unable to fetch passwd struct.", + err); + return dav_handle_err(r, err, NULL); + } + + chown((const char *) resource->info->pathname, ht_pwnam->pw_uid, ht_pwnam->pw_gid); + if (err != NULL) { + err = dav_push_error(r->pool, err->status, 0, + "do_rd_own: Unable to chown resource.", + err); + return dav_handle_err(r, err, NULL); + } + + return 1; +} + + /*--------------------------------------------------------------------------- * * Configuration info for the module > ------ CUT HERE ---------- [2.3] - Example perms.cf file > ------ CUT HERE ---------- #!/usr/bin/perl # LDAP Directory/user permissions use constant NOACCESS => 0x0; use constant READ => 0x1; use constant WRITE => 0x2; # INHERIT - subdirectories inherit perms. use constant INHERIT => 0x4; # access for everyone is done via the keyword 'ALL' our %perms = ( '/project/yamis/www' => { ALL => READ | INHERIT, }, '/project/yamis/www/t' => { andyw => READ|WRITE|INHERIT, }, '/project/yamis/www/icons' => { ALL => NOACCESS, }, '/project/davtest' => { markv => READ|WRITE|INHERIT, andyw => READ|WRITE|INHERIT, justink => READ|WRITE|INHERIT, }, '/project' => { ALL => READ, andyw => READ|INHERIT, }, '/home' => { ALL => READ|WRITE|INHERIT, }, ); > ------ CUT HERE ---------- this is a standard perl hash. perl -c perms.cf should say 'Syntax OK'. You should just be able to type 'make' when you change the hash. Syntax is checked and if valid, pushed out to dav0 and apache restarted.