mod_dav_fs.c revision 6b745319b1099edacf401e8911efa480440f999a
6ae232055d4d8a97267517c5e50074c2c819941and/* ====================================================================
6ae232055d4d8a97267517c5e50074c2c819941and * The Apache Software License, Version 1.1
6ae232055d4d8a97267517c5e50074c2c819941and *
6ae232055d4d8a97267517c5e50074c2c819941and * Copyright (c) 2000 The Apache Software Foundation. All rights
6ae232055d4d8a97267517c5e50074c2c819941and * reserved.
6ae232055d4d8a97267517c5e50074c2c819941and *
6ae232055d4d8a97267517c5e50074c2c819941and * Redistribution and use in source and binary forms, with or without
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * modification, are permitted provided that the following conditions
6ae232055d4d8a97267517c5e50074c2c819941and * are met:
6ae232055d4d8a97267517c5e50074c2c819941and *
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 1. Redistributions of source code must retain the above copyright
2e545ce2450a9953665f701bb05350f0d3f26275nd * notice, this list of conditions and the following disclaimer.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen *
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 2. Redistributions in binary form must reproduce the above copyright
6ae232055d4d8a97267517c5e50074c2c819941and * notice, this list of conditions and the following disclaimer in
6ae232055d4d8a97267517c5e50074c2c819941and * the documentation and/or other materials provided with the
6ae232055d4d8a97267517c5e50074c2c819941and * distribution.
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen *
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * 3. The end-user documentation included with the redistribution,
6ae232055d4d8a97267517c5e50074c2c819941and * if any, must include the following acknowledgment:
6ae232055d4d8a97267517c5e50074c2c819941and * "This product includes software developed by the
6ae232055d4d8a97267517c5e50074c2c819941and * Apache Software Foundation (http://www.apache.org/)."
b43f840409794ed298e8634f6284741f193b6c4ftakashi * Alternately, this acknowledgment may appear in the software itself,
6ae232055d4d8a97267517c5e50074c2c819941and * if and wherever such third-party acknowledgments normally appear.
6ae232055d4d8a97267517c5e50074c2c819941and *
6ae232055d4d8a97267517c5e50074c2c819941and * 4. The names "Apache" and "Apache Software Foundation" must
b43f840409794ed298e8634f6284741f193b6c4ftakashi * not be used to endorse or promote products derived from this
11495c9f0bd33e51a25b4d532beadfbcf9b944a3nilgun * software without prior written permission. For written
6ae232055d4d8a97267517c5e50074c2c819941and * permission, please contact apache@apache.org.
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung *
6ae232055d4d8a97267517c5e50074c2c819941and * 5. Products derived from this software may not be called "Apache",
b43f840409794ed298e8634f6284741f193b6c4ftakashi * nor may "Apache" appear in their name, without prior written
b43f840409794ed298e8634f6284741f193b6c4ftakashi * permission of the Apache Software Foundation.
b43f840409794ed298e8634f6284741f193b6c4ftakashi *
b43f840409794ed298e8634f6284741f193b6c4ftakashi * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
6ae232055d4d8a97267517c5e50074c2c819941and * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
6ae232055d4d8a97267517c5e50074c2c819941and * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
6ae232055d4d8a97267517c5e50074c2c819941and * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
6ae232055d4d8a97267517c5e50074c2c819941and * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6ae232055d4d8a97267517c5e50074c2c819941and * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
6ae232055d4d8a97267517c5e50074c2c819941and * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
6ae232055d4d8a97267517c5e50074c2c819941and * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
6ae232055d4d8a97267517c5e50074c2c819941and * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
6ae232055d4d8a97267517c5e50074c2c819941and * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
6ae232055d4d8a97267517c5e50074c2c819941and * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6ae232055d4d8a97267517c5e50074c2c819941and * SUCH DAMAGE.
6ae232055d4d8a97267517c5e50074c2c819941and * ====================================================================
6ae232055d4d8a97267517c5e50074c2c819941and *
6ae232055d4d8a97267517c5e50074c2c819941and * This software consists of voluntary contributions made by many
6ae232055d4d8a97267517c5e50074c2c819941and * individuals on behalf of the Apache Software Foundation. For more
6ae232055d4d8a97267517c5e50074c2c819941and * information on the Apache Software Foundation, please see
6ae232055d4d8a97267517c5e50074c2c819941and * <http://www.apache.org/>.
6ae232055d4d8a97267517c5e50074c2c819941and */
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and#include "httpd.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "http_config.h"
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and#include "mod_dav.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "repos.h"
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and/* per-server configuration */
6ae232055d4d8a97267517c5e50074c2c819941andtypedef struct {
6ae232055d4d8a97267517c5e50074c2c819941and const char *lockdb_path;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and} dav_fs_server_conf;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941andextern module MODULE_VAR_EXPORT dav_fs_module;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941andconst char *dav_get_lockdb_path(const request_rec *r)
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and dav_fs_server_conf *conf;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and conf = ap_get_module_config(r->server->module_config, &dav_fs_module);
6ae232055d4d8a97267517c5e50074c2c819941and return conf->lockdb_path;
6ae232055d4d8a97267517c5e50074c2c819941and}
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941andstatic void *dav_fs_create_server_config(ap_pool_t *p, server_rec *s)
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and return ap_pcalloc(p, sizeof(dav_fs_server_conf));
6ae232055d4d8a97267517c5e50074c2c819941and}
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941andstatic void *dav_fs_merge_server_config(ap_pool_t *p,
6ae232055d4d8a97267517c5e50074c2c819941and void *base, void *overrides)
070897b4d34cbd17fd2846289189f2a9891f9c84takashi{
6ae232055d4d8a97267517c5e50074c2c819941and dav_fs_server_conf *parent = base;
6ae232055d4d8a97267517c5e50074c2c819941and dav_fs_server_conf *child = overrides;
6ae232055d4d8a97267517c5e50074c2c819941and dav_fs_server_conf *newconf;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and newconf = ap_pcalloc(p, sizeof(*newconf));
070897b4d34cbd17fd2846289189f2a9891f9c84takashi
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh newconf->lockdb_path =
6ae232055d4d8a97267517c5e50074c2c819941and child->lockdb_path ? child->lockdb_path : parent->lockdb_path;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and return newconf;
6ae232055d4d8a97267517c5e50074c2c819941and}
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and/*
6ae232055d4d8a97267517c5e50074c2c819941and * Command handler for the DAVLockDB directive, which is TAKE1
6ae232055d4d8a97267517c5e50074c2c819941and */
6ae232055d4d8a97267517c5e50074c2c819941andstatic const char *dav_fs_cmd_davlockdb(cmd_parms *cmd, void *config,
6ae232055d4d8a97267517c5e50074c2c819941and const char *arg1)
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and dav_fs_server_conf *conf;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and conf = ap_get_module_config(cmd->server->module_config,
6ae232055d4d8a97267517c5e50074c2c819941and &dav_fs_module);
6ae232055d4d8a97267517c5e50074c2c819941and arg1 = ap_os_canonical_filename(cmd->pool, arg1);
6ae232055d4d8a97267517c5e50074c2c819941and conf->lockdb_path = ap_server_root_relative(cmd->pool, arg1);
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and return NULL;
6ae232055d4d8a97267517c5e50074c2c819941and}
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941andstatic const command_rec dav_fs_cmds[] =
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and /* per server */
6ae232055d4d8a97267517c5e50074c2c819941and AP_INIT_TAKE1("DAVLockDB", dav_fs_cmd_davlockdb, NULL, RSRC_CONF,
6ae232055d4d8a97267517c5e50074c2c819941and "specify a lock database"),
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and { NULL }
6ae232055d4d8a97267517c5e50074c2c819941and};
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941andstatic void register_hooks(void)
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and ap_hook_get_resource(dav_fs_hook_get_resource, NULL, NULL, AP_HOOK_MIDDLE);
6ae232055d4d8a97267517c5e50074c2c819941and ap_hook_get_lock_hooks(dav_fs_get_lock_hooks, NULL, NULL, AP_HOOK_MIDDLE);
6ae232055d4d8a97267517c5e50074c2c819941and ap_hook_get_propdb_hooks(dav_fs_get_propdb_hooks, NULL, NULL,
6ae232055d4d8a97267517c5e50074c2c819941and AP_HOOK_MIDDLE);
6ae232055d4d8a97267517c5e50074c2c819941and ap_hook_gather_propsets(dav_fs_gather_propsets, NULL, NULL,
6ae232055d4d8a97267517c5e50074c2c819941and AP_HOOK_MIDDLE);
6ae232055d4d8a97267517c5e50074c2c819941and ap_hook_find_liveprop(dav_fs_find_liveprop, NULL, NULL, AP_HOOK_MIDDLE);
6ae232055d4d8a97267517c5e50074c2c819941and ap_hook_insert_all_liveprops(dav_fs_insert_all_liveprops, NULL, NULL,
6ae232055d4d8a97267517c5e50074c2c819941and AP_HOOK_MIDDLE);
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and dav_fs_register_uris(NULL /* ### pconf */);
6ae232055d4d8a97267517c5e50074c2c819941and}
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941andmodule MODULE_VAR_EXPORT dav_fs_module =
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and STANDARD20_MODULE_STUFF,
6ae232055d4d8a97267517c5e50074c2c819941and NULL, /* dir config creater */
6ae232055d4d8a97267517c5e50074c2c819941and NULL, /* dir merger --- default is to override */
6ae232055d4d8a97267517c5e50074c2c819941and dav_fs_create_server_config, /* server config */
6ae232055d4d8a97267517c5e50074c2c819941and dav_fs_merge_server_config, /* merge server config */
6ae232055d4d8a97267517c5e50074c2c819941and dav_fs_cmds, /* command table */
6ae232055d4d8a97267517c5e50074c2c819941and NULL, /* handlers */
6ae232055d4d8a97267517c5e50074c2c819941and register_hooks, /* register hooks */
6ae232055d4d8a97267517c5e50074c2c819941and};
6ae232055d4d8a97267517c5e50074c2c819941and