repos.c revision 6f15570e3adc0faf87bf55f70857028276fc9e32
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* ====================================================================
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * The Apache Software License, Version 1.1
e21e5f0fa66bf80e14cfd3f571e09b3952e46ad9Alexis Tsogias * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
fc09e0a6af734edbd944dd8082bb51985c233b43Alexis Tsogias * Redistribution and use in source and binary forms, with or without
fc09e0a6af734edbd944dd8082bb51985c233b43Alexis Tsogias * modification, are permitted provided that the following conditions
e21e5f0fa66bf80e14cfd3f571e09b3952e46ad9Alexis Tsogias * 1. Redistributions of source code must retain the above copyright
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * notice, this list of conditions and the following disclaimer.
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * 2. Redistributions in binary form must reproduce the above copyright
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * notice, this list of conditions and the following disclaimer in
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * the documentation and/or other materials provided with the
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * distribution.
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * 3. The end-user documentation included with the redistribution,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * if any, must include the following acknowledgment:
1e622ddf5a057555db1924ddc88475c695c6f7f2Alexis Tsogias * "This product includes software developed by the
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * Apache Software Foundation (http://www.apache.org/)."
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * Alternately, this acknowledgment may appear in the software itself,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * if and wherever such third-party acknowledgments normally appear.
1e622ddf5a057555db1924ddc88475c695c6f7f2Alexis Tsogias * 4. The names "Apache" and "Apache Software Foundation" must
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * not be used to endorse or promote products derived from this
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * software without prior written permission. For written
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * permission, please contact apache@apache.org.
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * 5. Products derived from this software may not be called "Apache",
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * nor may "Apache" appear in their name, without prior written
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * permission of the Apache Software Foundation.
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
748e10233de9e76b68be4f0050c7b4a7f3c415eaAlexis Tsogias * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
748e10233de9e76b68be4f0050c7b4a7f3c415eaAlexis Tsogias * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
748e10233de9e76b68be4f0050c7b4a7f3c415eaAlexis Tsogias * SUCH DAMAGE.
748e10233de9e76b68be4f0050c7b4a7f3c415eaAlexis Tsogias * ====================================================================
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * This software consists of voluntary contributions made by many
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * individuals on behalf of the Apache Software Foundation. For more
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * information on the Apache Software Foundation, please see
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias** DAV filesystem-based repository provider
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias#include "http_protocol.h" /* for ap_set_* (in dav_fs_set_headers) */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias#include "http_request.h" /* for ap_update_mtime() */
4cea468e955597a7069faba3f43f27e913f2b651Alexis Tsogias/* to assist in debugging mod_dav's GET handling */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias#define DAV_FS_COPY_BLOCKSIZE 16384 /* copy 16k at a time */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* context needed to identify a resource */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias apr_pool_t *pool; /* memory storage pool associated with request */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias const char *pathname; /* full pathname to resource */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* private context for doing a filesystem walk */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogiastypedef struct {
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias /* the input walk parameters */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* reused as we walk */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* MOVE/COPY need a secondary path */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogiastypedef struct {
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias dav_buffer work_buf; /* handy buffer for copymove_file() */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias /* CALLBACK: this is a secondary resource managed specially for us */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias /* copied from dav_walk_params (they are invariant across the walk) */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* an internal WALKTYPE to walk hidden files (the .DAV directory) */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias/* an internal WALKTYPE to call collections (again) after their contents */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias#define DAV_CALLTYPE_POSTFIX 1000 /* a private call type */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias/* pull this in from the other source file */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogiasextern const dav_hooks_locks dav_hooks_locks_fs;
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias/* forward-declare the hook structures */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogiasstatic const dav_hooks_repository dav_hooks_repository_fs;
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogiasstatic const dav_hooks_liveprop dav_hooks_liveprop_fs;
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias** The namespace URIs that we use. This list and the enumeration must
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias** stay in sync.
1e622ddf5a057555db1924ddc88475c695c6f7f2Alexis Tsogiasstatic const char * const dav_fs_namespace_uris[] =
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias DAV_FS_URI_MYPROPS /* the namespace URI for our custom props */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias** Does this platform support an executable flag?
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias** ### need a way to portably abstract this query
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias** The single property that we define (in the DAV_FS_URI_MYPROPS namespace)
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogiasstatic const dav_liveprop_spec dav_fs_props[] =
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias /* standard DAV properties */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias "creationdate",
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias "getcontentlength",
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias "getlastmodified",
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* our custom properties */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias "executable",
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias 0 /* handled special in dav_fs_is_writable */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias { 0 } /* sentinel */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogiasstatic const dav_liveprop_group dav_fs_liveprop_group =
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* define the dav_stream structure for our use */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias const char *pathname; /* we may need to remove it at close time */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* forward declaration for internal treewalkers */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogiasstatic dav_error * dav_fs_walk(const dav_walk_params *params, int depth,
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogiasstatic dav_error * dav_fs_internal_walk(const dav_walk_params *params,
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias/* --------------------------------------------------------------------
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias** PRIVATE REPOSITORY FUNCTIONS
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogiasapr_pool_t *dav_fs_pool(const dav_resource *resource)
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogiasconst char *dav_fs_pathname(const dav_resource *resource)
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias char *dirpath = ap_make_dirstr_parent(ctx->pool, ctx->pathname);
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias rv = apr_filepath_root(&rootpath, &testpath, 0, ctx->pool);
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* remove trailing slash from dirpath, unless it's a root path
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias if ((rv == APR_SUCCESS && testpath && *testpath)
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ###: Looks like a response could be appropriate
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * APR_SUCCESS here tells us the dir is a root
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * APR_ERELATIVE told us we had no root (ok)
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * APR_EINCOMPLETE an incomplete testpath told us
4cea468e955597a7069faba3f43f27e913f2b651Alexis Tsogias * there was no -file- name here!
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * APR_EBADPATH or other errors tell us this file
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias * path is undecipherable
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if (rv == APR_SUCCESS || rv == APR_ERELATIVE) {
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias return dav_new_error(ctx->pool, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "An incomplete/bad path was found in "
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "dav_fs_dir_file_name.");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* Note: picked up from ap_gm_timestr_822() */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* NOTE: buf must be at least DAV_TIMEBUF_SIZE chars in size */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogiasstatic void dav_format_time(int style, apr_time_t sec, char *buf)
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### what to do if fails? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### should we use "-00:00" instead of "Z" ?? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* 20 chars plus null term */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ",
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* RFC 822 date format; as strftime '%a, %d %b %Y %T GMT' */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* 29 chars plus null term */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "%s, %.2d %s %d %.2d:%.2d:%.2d GMT",
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias dav_set_bufsize(p, pbuf, DAV_FS_COPY_BLOCKSIZE);
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if ((apr_file_open(&inf, src, APR_READ | APR_BINARY, APR_OS_DEFAULT, p))
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Could not open file for reading");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### do we need to deal with the umask? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if ((apr_file_open(&outf, dst, APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BINARY,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Could not open file for writing");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias status = apr_file_read(inf, pbuf->buf, &len);
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if (status != APR_SUCCESS && status != APR_EOF) {
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if (apr_file_remove(dst, p) != APR_SUCCESS) {
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### ACK! Inconsistent state... */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Could not delete output after read "
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "failure. Server is now in an "
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "inconsistent state.");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
4cea468e955597a7069faba3f43f27e913f2b651Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Could not read input file");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* write any bytes that were read (applies to APR_EOF, too) */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if (apr_file_write_full(outf, pbuf->buf, len, NULL) != APR_SUCCESS) {
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if (apr_file_remove(dst, p) != APR_SUCCESS) {
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### ACK! Inconsistent state... */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Could not delete output after write "
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "failure. Server is now in an "
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "inconsistent state.");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INSUFFICIENT_STORAGE, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "There is not enough storage to write to "
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "this resource.");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Could not write output file");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if (is_move && apr_file_remove(src, p) != APR_SUCCESS) {
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias int save_errno = errno; /* save the errno that got us here */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if (apr_file_remove(dst, p) != APR_SUCCESS) {
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### ACK. this creates an inconsistency. do more!? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* Note that we use the latest errno */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Could not remove source or destination "
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "file. Server is now in an inconsistent "
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Could not remove source file after move. "
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Destination was removed to ensure consistency.");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* copy/move a file from within a state dir to another state dir */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias/* ### need more buffers to replace the pool argument */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias apr_finfo_t src_finfo; /* finfo for source file */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias apr_finfo_t dst_state_finfo; /* finfo for STATE directory */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* build the propset pathname for the source file */
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias src = apr_pstrcat(p, src_dir, "/" DAV_FS_STATE_DIR "/", src_file, NULL);
4e95ffc23b9c5f0b5980ab6f1cacbe7bd9789851Alexis Tsogias /* the source file doesn't exist */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias rv = apr_stat(&src_finfo, src, APR_FINFO_NORM, p);
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if (rv != APR_SUCCESS && rv != APR_INCOMPLETE) {
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* build the pathname for the destination state dir */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias dst = apr_pstrcat(p, dst_dir, "/" DAV_FS_STATE_DIR, NULL);
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### do we need to deal with the umask? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ensure that it exists */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "Could not create internal state directory");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* get info about the state directory */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias rv = apr_stat(&dst_state_finfo, dst, APR_FINFO_NORM, p);
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias if (rv != APR_SUCCESS && rv != APR_INCOMPLETE) {
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* Ack! Where'd it go? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias "State directory disappeared");
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* The mkdir() may have failed because a *file* exists there already */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### try to recover by deleting this file? (and mkdir again) */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias /* ### use something besides 500? */
12f6880fc0909e8dc2bdebc5f299a6a8bfa8afa7Alexis Tsogias return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
1e622ddf5a057555db1924ddc88475c695c6f7f2Alexis Tsogias "State directory is actually a file");
1e622ddf5a057555db1924ddc88475c695c6f7f2Alexis Tsogias /* append the target file to the state directory pathname */
return NULL;
const char *src_dir;
const char *src_file;
const char *src_state1;
const char *src_state2;
const char *dst_dir;
const char *dst_file;
const char *dst_state1;
const char *dst_state2;
#if DAV_DEBUG
pbuf);
pbuf);
return err;
const char *dirpath;
const char *fname;
const char *state1;
const char *state2;
const char *pathname;
NULL);
NULL);
return NULL;
request_rec *r,
const char *root_dir,
const char *label,
int use_checked_in,
char *filename;
return NULL;
char *dirpath;
const char *testroot;
const char *testpath;
return NULL;
return NULL;
return NULL;
static int dav_fs_is_same_resource(
static int dav_fs_is_parent_resource(
switch (mode) {
case DAV_MODE_WRITE_TRUNC:
case DAV_MODE_WRITE_SEEKABLE:
ds->p = p;
return NULL;
if (!commit) {
return NULL;
return NULL;
return NULL;
return NULL;
ap_set_etag(r);
return NULL;
return NULL;
return NULL;
int calltype)
return NULL;
return err;
int is_move,
int depth,
if (is_move)
return err;
return NULL;
return err;
int depth,
#if DAV_DEBUG
return err;
int can_rename = 0;
#if DAV_DEBUG
const char *dirpath;
if (!can_rename) {
return err;
return NULL;
err);
err);
return NULL;
return err;
return NULL;
return err;
return NULL;
return err;
return err;
return err;
return err;
return NULL;
#if DAV_DEBUG
return err;
NULL,
NULL,
const char *value;
int global_ns;
return DAV_PROP_INSERT_NOTDEF;
switch (propid) {
case DAV_PROPID_creationdate:
buf);
return DAV_PROP_INSERT_NOTDEF;
case DAV_PROPID_getetag:
buf);
case DAV_PROPID_FS_executable:
return DAV_PROP_INSERT_NOTDEF;
return DAV_PROP_INSERT_NOTDEF;
return DAV_PROP_INSERT_NOTDEF;
s = apr_psprintf(p,
return what;
#ifdef DAV_FS_HAS_EXECUTABLE
int operation,
void **context,
int *defer_to_dead)
char value;
return NULL;
? NULL
/* DBG3("name=%s cdata=%s f_cdata=%s",elem->name,cdata ? cdata->text : "[null]",f_cdata ? f_cdata->text : "[null]"); */
goto too_long;
goto too_long;
return NULL;
int operation,
void *context,
return NULL;
if (value)
return NULL;
int operation,
void *context,
int operation,
void *context,
if (value)
return NULL;
#ifdef DAV_FS_HAS_EXECUTABLE
#ifdef DAV_FS_HAS_EXECUTABLE