mod_dav_fs.c revision 975e51c02f55eaa15e6c5c65ffd89f6c0431e4f5
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek/* Licensed to the Apache Software Foundation (ASF) under one or more
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * contributor license agreements. See the NOTICE file distributed with
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * this work for additional information regarding copyright ownership.
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * The ASF licenses this file to You under the Apache License, Version 2.0
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * (the "License"); you may not use this file except in compliance with
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * the License. You may obtain a copy of the License at
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek *
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * http://www.apache.org/licenses/LICENSE-2.0
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek *
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * Unless required by applicable law or agreed to in writing, software
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * distributed under the License is distributed on an "AS IS" BASIS,
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * See the License for the specific language governing permissions and
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek * limitations under the License.
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek */
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek#include "httpd.h"
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek#include "http_config.h"
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek#include "apr_strings.h"
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek#include "ap_config_auto.h"
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek#include "mod_dav.h"
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek#include "repos.h"
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek/* per-server configuration */
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmektypedef struct {
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek const char *lockdb_path;
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen} dav_fs_server_conf;
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersenextern module AP_MODULE_DECLARE_DATA dav_fs_module;
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmekconst char *dav_get_lockdb_path(const request_rec *r)
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek{
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen dav_fs_server_conf *conf;
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin conf = ap_get_module_config(r->server->module_config, &dav_fs_module);
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin return conf->lockdb_path;
8c7db2fb2186277f9572d58b664cc59792ee4f50Evgeny Vereshchagin}
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmekstatic void *dav_fs_create_server_config(apr_pool_t *p, server_rec *s)
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek{
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin dav_fs_server_conf *conf = apr_pcalloc(p, sizeof(dav_fs_server_conf));
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin#ifdef DEFAULT_EXP_DAVLOCKDB
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin conf->lockdb_path = DEFAULT_EXP_DAVLOCKDB;
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin if (*conf->lockdb_path == '\0') {
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek conf->lockdb_path = NULL;
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek }
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek#endif
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek return conf;
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek}
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmekstatic void *dav_fs_merge_server_config(apr_pool_t *p,
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek void *base, void *overrides)
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin{
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek dav_fs_server_conf *parent = base;
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek dav_fs_server_conf *child = overrides;
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek dav_fs_server_conf *newconf;
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek newconf = apr_pcalloc(p, sizeof(*newconf));
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek newconf->lockdb_path =
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek child->lockdb_path ? child->lockdb_path : parent->lockdb_path;
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek return newconf;
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen}
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen/*
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen * Command handler for the DAVLockDB directive, which is TAKE1
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen */
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersenstatic const char *dav_fs_cmd_davlockdb(cmd_parms *cmd, void *config,
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen const char *arg1)
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen{
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen dav_fs_server_conf *conf;
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen conf = ap_get_module_config(cmd->server->module_config,
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen &dav_fs_module);
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen conf->lockdb_path = ap_server_root_relative(cmd->pool, arg1);
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen if (!conf->lockdb_path) {
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen return apr_pstrcat(cmd->pool, "Invalid DAVLockDB path ",
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen arg1, NULL);
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen }
f961371fb7a6d1cb5897255cd66608bdc43579ccEvgeny Vereshchagin
f961371fb7a6d1cb5897255cd66608bdc43579ccEvgeny Vereshchagin return NULL;
75d73dc9d08c39ca5e413e4045daf1de61ea7ee6Evgeny Vereshchagin}
64a713d94dea614ac6bd35d8c4b1d5b96add3347Evgeny Vereshchagin
4e79ac4425ae36a02ba511ebc1c63a9f1a7d2d37Evgeny Vereshchaginstatic const command_rec dav_fs_cmds[] =
4e79ac4425ae36a02ba511ebc1c63a9f1a7d2d37Evgeny Vereshchagin{
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen /* per server */
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen AP_INIT_TAKE1("DAVLockDB", dav_fs_cmd_davlockdb, NULL, RSRC_CONF,
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen "specify a lock database"),
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen { NULL }
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen};
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersenstatic void register_hooks(apr_pool_t *p)
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen{
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen dav_hook_gather_propsets(dav_fs_gather_propsets, NULL, NULL,
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen APR_HOOK_MIDDLE);
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen dav_hook_find_liveprop(dav_fs_find_liveprop, NULL, NULL, APR_HOOK_MIDDLE);
761a7c71b649b5e926c28c703a11fbdc22dd6df1Thomas Hindoe Paaboel Andersen dav_hook_insert_all_liveprops(dav_fs_insert_all_liveprops, NULL, NULL,
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin APR_HOOK_MIDDLE);
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin dav_fs_register(p);
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin}
20bde8192332cff5a2fcf7059a4b48b9fca75e63Evgeny Vereshchagin
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-SzmekAP_DECLARE_MODULE(dav_fs) =
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek{
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek STANDARD20_MODULE_STUFF,
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek NULL, /* dir config creater */
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek NULL, /* dir merger --- default is to override */
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek dav_fs_create_server_config, /* server config */
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek dav_fs_merge_server_config, /* merge server config */
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek dav_fs_cmds, /* command table */
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek register_hooks, /* register hooks */
64eed40c07efb4e2b316ebb4e7481b7a891b7934Zbigniew Jędrzejewski-Szmek};