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