2005-08-19 00:05:52 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <dirent.h>
|
2005-08-19 13:42:01 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
2005-08-19 14:40:19 +00:00
|
|
|
#include <fcntl.h>
|
2005-08-20 19:10:44 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2005-08-21 10:06:23 +00:00
|
|
|
#include "config.h"
|
|
|
|
#if defined(HAVE_LIBXML_H) && defined(HAVE_SQLITE3_H)
|
|
|
|
#define USE_PROPPATCH
|
|
|
|
#include <libxml/tree.h>
|
|
|
|
#include <libxml/parser.h>
|
|
|
|
|
|
|
|
#include <sqlite3.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-08-19 00:05:52 +00:00
|
|
|
#include "base.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "response.h"
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
#include "stream.h"
|
|
|
|
#include "stat_cache.h"
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-21 07:21:22 +00:00
|
|
|
|
2005-08-19 00:05:52 +00:00
|
|
|
/**
|
|
|
|
* this is a webdav for a lighttpd plugin
|
|
|
|
*
|
|
|
|
* at least a very basic one.
|
|
|
|
* - for now it is read-only and we only support PROPFIND
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* plugin config for all request/connections */
|
|
|
|
|
|
|
|
typedef struct {
|
2005-08-19 13:42:01 +00:00
|
|
|
unsigned short enabled;
|
|
|
|
unsigned short is_readonly;
|
2005-08-20 19:10:44 +00:00
|
|
|
|
|
|
|
buffer *sqlite_db_name;
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
sqlite3 *sql;
|
|
|
|
sqlite3_stmt *stmt_update_prop;
|
|
|
|
sqlite3_stmt *stmt_delete_prop;
|
|
|
|
sqlite3_stmt *stmt_select_prop;
|
|
|
|
sqlite3_stmt *stmt_select_propnames;
|
|
|
|
|
|
|
|
sqlite3_stmt *stmt_delete_uri;
|
|
|
|
sqlite3_stmt *stmt_move_uri;
|
|
|
|
sqlite3_stmt *stmt_copy_uri;
|
2005-08-21 07:21:22 +00:00
|
|
|
#endif
|
2005-08-19 00:05:52 +00:00
|
|
|
} plugin_config;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PLUGIN_DATA;
|
|
|
|
|
|
|
|
buffer *tmp_buf;
|
2005-08-20 19:10:44 +00:00
|
|
|
request_uri uri;
|
|
|
|
physical physical;
|
|
|
|
|
2005-08-19 00:05:52 +00:00
|
|
|
plugin_config **config_storage;
|
|
|
|
|
|
|
|
plugin_config conf;
|
|
|
|
} plugin_data;
|
|
|
|
|
|
|
|
/* init the plugin data */
|
|
|
|
INIT_FUNC(mod_webdav_init) {
|
|
|
|
plugin_data *p;
|
|
|
|
|
|
|
|
p = calloc(1, sizeof(*p));
|
|
|
|
|
|
|
|
p->tmp_buf = buffer_init();
|
2005-08-20 19:10:44 +00:00
|
|
|
|
|
|
|
p->uri.scheme = buffer_init();
|
|
|
|
p->uri.path_raw = buffer_init();
|
|
|
|
p->uri.path = buffer_init();
|
|
|
|
p->uri.authority = buffer_init();
|
|
|
|
|
|
|
|
p->physical.path = buffer_init();
|
|
|
|
p->physical.rel_path = buffer_init();
|
|
|
|
p->physical.doc_root = buffer_init();
|
|
|
|
p->physical.basedir = buffer_init();
|
2005-08-19 00:05:52 +00:00
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* detroy the plugin data */
|
|
|
|
FREE_FUNC(mod_webdav_free) {
|
|
|
|
plugin_data *p = p_d;
|
|
|
|
|
|
|
|
UNUSED(srv);
|
|
|
|
|
|
|
|
if (!p) return HANDLER_GO_ON;
|
|
|
|
|
|
|
|
if (p->config_storage) {
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < srv->config_context->used; i++) {
|
|
|
|
plugin_config *s = p->config_storage[i];
|
2005-08-19 08:37:21 +00:00
|
|
|
|
|
|
|
if (!s) continue;
|
2005-08-20 19:10:44 +00:00
|
|
|
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
if (s->sql) {
|
|
|
|
sqlite3_finalize(s->stmt_delete_prop);
|
|
|
|
sqlite3_finalize(s->stmt_delete_uri);
|
|
|
|
sqlite3_finalize(s->stmt_update_prop);
|
|
|
|
sqlite3_finalize(s->stmt_select_prop);
|
|
|
|
sqlite3_finalize(s->stmt_select_propnames);
|
|
|
|
sqlite3_close(s->sql);
|
|
|
|
}
|
2005-08-21 07:21:22 +00:00
|
|
|
#endif
|
2005-08-19 00:05:52 +00:00
|
|
|
free(s);
|
|
|
|
}
|
|
|
|
free(p->config_storage);
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer_free(p->tmp_buf);
|
|
|
|
|
|
|
|
free(p);
|
|
|
|
|
|
|
|
return HANDLER_GO_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle plugin config and check values */
|
|
|
|
|
|
|
|
SETDEFAULTS_FUNC(mod_webdav_set_defaults) {
|
|
|
|
plugin_data *p = p_d;
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
config_values_t cv[] = {
|
2005-08-19 08:37:21 +00:00
|
|
|
{ "webdav.activate", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
|
2005-08-19 13:42:01 +00:00
|
|
|
{ "webdav.is-readonly", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
|
2005-08-20 19:10:44 +00:00
|
|
|
{ "webdav.sqlite-db-name", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 2 */
|
2005-08-19 00:05:52 +00:00
|
|
|
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!p) return HANDLER_ERROR;
|
|
|
|
|
|
|
|
p->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
|
|
|
|
|
|
|
|
for (i = 0; i < srv->config_context->used; i++) {
|
|
|
|
plugin_config *s;
|
|
|
|
|
|
|
|
s = calloc(1, sizeof(plugin_config));
|
2005-08-20 19:10:44 +00:00
|
|
|
s->sqlite_db_name = buffer_init();
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-19 08:37:21 +00:00
|
|
|
cv[0].destination = &(s->enabled);
|
2005-08-19 13:42:01 +00:00
|
|
|
cv[1].destination = &(s->is_readonly);
|
2005-08-20 19:10:44 +00:00
|
|
|
cv[2].destination = s->sqlite_db_name;
|
2005-08-19 00:05:52 +00:00
|
|
|
|
|
|
|
p->config_storage[i] = s;
|
|
|
|
|
|
|
|
if (0 != config_insert_values_global(srv, ((data_config *)srv->config_context->data[i])->value, cv)) {
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
2005-08-20 19:10:44 +00:00
|
|
|
|
|
|
|
if (!buffer_is_empty(s->sqlite_db_name)) {
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
const char *next_stmt;
|
|
|
|
char *err;
|
|
|
|
|
|
|
|
if (SQLITE_OK != sqlite3_open(s->sqlite_db_name->ptr, &(s->sql))) {
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "s", "sqlite3_open failed");
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SQLITE_OK != sqlite3_prepare(s->sql,
|
|
|
|
CONST_STR_LEN("SELECT value FROM properties WHERE resource = ? AND prop = ? AND ns = ?"),
|
|
|
|
&(s->stmt_select_prop), &next_stmt)) {
|
|
|
|
/* prepare failed */
|
|
|
|
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "ss", "sqlite3_prepare failed:", sqlite3_errmsg(s->sql));
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SQLITE_OK != sqlite3_prepare(s->sql,
|
|
|
|
CONST_STR_LEN("SELECT ns, prop FROM properties WHERE resource = ?"),
|
|
|
|
&(s->stmt_select_propnames), &next_stmt)) {
|
|
|
|
/* prepare failed */
|
|
|
|
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "ss", "sqlite3_prepare failed:", sqlite3_errmsg(s->sql));
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SQLITE_OK != sqlite3_exec(s->sql,
|
|
|
|
"CREATE TABLE properties ("
|
|
|
|
" resource TEXT NOT NULL,"
|
|
|
|
" prop TEXT NOT NULL,"
|
|
|
|
" ns TEXT NOT NULL,"
|
|
|
|
" value TEXT NOT NULL,"
|
|
|
|
" PRIMARY KEY(resource, prop, ns))",
|
|
|
|
NULL, NULL, &err)) {
|
|
|
|
|
|
|
|
if (0 != strcmp(err, "table properties already exists")) {
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "ss", "can't open transaction:", err);
|
|
|
|
sqlite3_free(err);
|
|
|
|
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SQLITE_OK != sqlite3_prepare(s->sql,
|
|
|
|
CONST_STR_LEN("REPLACE INTO properties (resource, prop, ns, value) VALUES (?, ?, ?, ?)"),
|
|
|
|
&(s->stmt_update_prop), &next_stmt)) {
|
|
|
|
/* prepare failed */
|
|
|
|
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "ss", "sqlite3_prepare failed:", sqlite3_errmsg(s->sql));
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SQLITE_OK != sqlite3_prepare(s->sql,
|
|
|
|
CONST_STR_LEN("DELETE FROM properties WHERE resource = ? AND prop = ? AND ns = ?"),
|
|
|
|
&(s->stmt_delete_prop), &next_stmt)) {
|
|
|
|
/* prepare failed */
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "ss", "sqlite3_prepare failed", sqlite3_errmsg(s->sql));
|
|
|
|
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SQLITE_OK != sqlite3_prepare(s->sql,
|
|
|
|
CONST_STR_LEN("DELETE FROM properties WHERE resource = ?"),
|
|
|
|
&(s->stmt_delete_uri), &next_stmt)) {
|
|
|
|
/* prepare failed */
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "ss", "sqlite3_prepare failed", sqlite3_errmsg(s->sql));
|
|
|
|
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SQLITE_OK != sqlite3_prepare(s->sql,
|
|
|
|
CONST_STR_LEN("INSERT INTO properties SELECT ?, prop, ns, value FROM properties WHERE resource = ?"),
|
|
|
|
&(s->stmt_copy_uri), &next_stmt)) {
|
|
|
|
/* prepare failed */
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "ss", "sqlite3_prepare failed", sqlite3_errmsg(s->sql));
|
|
|
|
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SQLITE_OK != sqlite3_prepare(s->sql,
|
|
|
|
CONST_STR_LEN("UPDATE properties SET resource = ? WHERE resource = ?"),
|
|
|
|
&(s->stmt_move_uri), &next_stmt)) {
|
|
|
|
/* prepare failed */
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "ss", "sqlite3_prepare failed", sqlite3_errmsg(s->sql));
|
|
|
|
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
}
|
2005-08-21 07:21:22 +00:00
|
|
|
#else
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "s", "Sorry, no sqlite3 and libxml2 support include, compile with --with-webdav-props");
|
|
|
|
return HANDLER_ERROR;
|
|
|
|
#endif
|
2005-08-20 19:10:44 +00:00
|
|
|
}
|
2005-08-19 00:05:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return HANDLER_GO_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PATCH(x) \
|
|
|
|
p->conf.x = s->x;
|
|
|
|
static int mod_webdav_patch_connection(server *srv, connection *con, plugin_data *p) {
|
|
|
|
size_t i, j;
|
|
|
|
plugin_config *s = p->config_storage[0];
|
|
|
|
|
2005-08-19 08:37:21 +00:00
|
|
|
PATCH(enabled);
|
2005-08-19 13:42:01 +00:00
|
|
|
PATCH(is_readonly);
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
PATCH(sql);
|
|
|
|
PATCH(stmt_update_prop);
|
|
|
|
PATCH(stmt_delete_prop);
|
|
|
|
PATCH(stmt_select_prop);
|
|
|
|
PATCH(stmt_select_propnames);
|
|
|
|
|
|
|
|
PATCH(stmt_delete_uri);
|
|
|
|
PATCH(stmt_move_uri);
|
|
|
|
PATCH(stmt_copy_uri);
|
2005-08-21 07:21:22 +00:00
|
|
|
#endif
|
2005-08-19 00:05:52 +00:00
|
|
|
/* skip the first, the global context */
|
|
|
|
for (i = 1; i < srv->config_context->used; i++) {
|
|
|
|
data_config *dc = (data_config *)srv->config_context->data[i];
|
|
|
|
s = p->config_storage[i];
|
|
|
|
|
|
|
|
/* condition didn't match */
|
|
|
|
if (!config_check_cond(srv, con, dc)) continue;
|
|
|
|
|
|
|
|
/* merge config */
|
|
|
|
for (j = 0; j < dc->value->used; j++) {
|
|
|
|
data_unset *du = dc->value->data[j];
|
|
|
|
|
2005-08-19 08:37:21 +00:00
|
|
|
if (buffer_is_equal_string(du->key, CONST_STR_LEN("webdav.activate"))) {
|
|
|
|
PATCH(enabled);
|
2005-08-19 13:42:01 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("webdav.is-readonly"))) {
|
|
|
|
PATCH(is_readonly);
|
2005-08-20 19:10:44 +00:00
|
|
|
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("webdav.sqlite-db-name"))) {
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
PATCH(sql);
|
|
|
|
PATCH(stmt_update_prop);
|
|
|
|
PATCH(stmt_delete_prop);
|
|
|
|
PATCH(stmt_select_prop);
|
|
|
|
PATCH(stmt_select_propnames);
|
|
|
|
|
|
|
|
PATCH(stmt_delete_uri);
|
|
|
|
PATCH(stmt_move_uri);
|
|
|
|
PATCH(stmt_copy_uri);
|
2005-08-21 07:21:22 +00:00
|
|
|
#endif
|
2005-08-19 00:05:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#undef PATCH
|
|
|
|
|
|
|
|
URIHANDLER_FUNC(mod_webdav_uri_handler) {
|
|
|
|
plugin_data *p = p_d;
|
|
|
|
|
|
|
|
UNUSED(srv);
|
|
|
|
|
|
|
|
if (con->uri.path->used == 0) return HANDLER_GO_ON;
|
|
|
|
|
|
|
|
mod_webdav_patch_connection(srv, con, p);
|
|
|
|
|
2005-08-19 08:37:21 +00:00
|
|
|
if (!p->conf.enabled) return HANDLER_GO_ON;
|
|
|
|
|
2005-08-19 00:05:52 +00:00
|
|
|
switch (con->request.http_method) {
|
|
|
|
case HTTP_METHOD_OPTIONS:
|
2005-08-19 08:37:21 +00:00
|
|
|
/* we fake a little bit but it makes MS W2k happy and it let's us mount the volume */
|
2005-08-19 00:05:52 +00:00
|
|
|
response_header_overwrite(srv, con, CONST_STR_LEN("DAV"), CONST_STR_LEN("1,2"));
|
|
|
|
response_header_overwrite(srv, con, CONST_STR_LEN("MS-Author-Via"), CONST_STR_LEN("DAV"));
|
2005-08-19 13:42:01 +00:00
|
|
|
|
|
|
|
if (p->conf.is_readonly) {
|
|
|
|
response_header_insert(srv, con, CONST_STR_LEN("Allow"), CONST_STR_LEN("PROPFIND"));
|
|
|
|
} else {
|
2005-08-21 10:06:23 +00:00
|
|
|
response_header_insert(srv, con, CONST_STR_LEN("Allow"), CONST_STR_LEN("PROPFIND, DELETE, MKCOL, PUT, MOVE, COPY, PROPPATCH"));
|
2005-08-19 13:42:01 +00:00
|
|
|
}
|
2005-08-19 00:05:52 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not found */
|
|
|
|
return HANDLER_GO_ON;
|
|
|
|
}
|
2005-08-20 19:10:44 +00:00
|
|
|
static int webdav_gen_prop_tag(server *srv, connection *con,
|
2005-08-21 07:21:22 +00:00
|
|
|
char *prop_name,
|
|
|
|
char *prop_ns,
|
2005-08-21 10:06:23 +00:00
|
|
|
char *value,
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer *b) {
|
|
|
|
|
2005-08-21 07:21:22 +00:00
|
|
|
UNUSED(srv);
|
|
|
|
UNUSED(con);
|
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
if (value) {
|
|
|
|
buffer_append_string(b,"<");
|
|
|
|
buffer_append_string(b, prop_name);
|
|
|
|
buffer_append_string(b, " xmlns=\"");
|
|
|
|
buffer_append_string(b, prop_ns);
|
|
|
|
buffer_append_string(b, "\">");
|
|
|
|
|
|
|
|
buffer_append_string(b, value);
|
|
|
|
|
|
|
|
buffer_append_string(b,"</");
|
|
|
|
buffer_append_string(b, prop_name);
|
|
|
|
buffer_append_string(b, ">");
|
|
|
|
} else {
|
|
|
|
buffer_append_string(b,"<");
|
|
|
|
buffer_append_string(b, prop_name);
|
|
|
|
buffer_append_string(b, " xmlns=\"");
|
|
|
|
buffer_append_string(b, prop_ns);
|
|
|
|
buffer_append_string(b, "\"/>");
|
|
|
|
}
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
static int webdav_gen_response_status_tag(server *srv, connection *con, physical *dst, int status, buffer *b) {
|
2005-08-21 07:21:22 +00:00
|
|
|
UNUSED(srv);
|
|
|
|
|
2005-08-19 00:05:52 +00:00
|
|
|
buffer_append_string(b,"<D:response xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n");
|
|
|
|
|
|
|
|
buffer_append_string(b,"<D:href>\n");
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_append_string_buffer(b, dst->rel_path);
|
2005-08-19 00:05:52 +00:00
|
|
|
buffer_append_string(b,"</D:href>\n");
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_append_string(b,"<D:status>\n");
|
|
|
|
|
|
|
|
if (con->request.http_version == HTTP_VERSION_1_1) {
|
|
|
|
BUFFER_COPY_STRING_CONST(b, "HTTP/1.1 ");
|
|
|
|
} else {
|
|
|
|
BUFFER_COPY_STRING_CONST(b, "HTTP/1.0 ");
|
|
|
|
}
|
|
|
|
buffer_append_long(b, status);
|
|
|
|
BUFFER_APPEND_STRING_CONST(b, " ");
|
|
|
|
buffer_append_string(b, get_http_status_name(status));
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_append_string(b,"</D:status>\n");
|
|
|
|
buffer_append_string(b,"</D:response>\n");
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
static int webdav_delete_file(server *srv, connection *con, plugin_data *p, physical *dst, buffer *b) {
|
|
|
|
int status = 0;
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
/* try to unlink it */
|
|
|
|
if (-1 == unlink(dst->path->ptr)) {
|
|
|
|
switch(errno) {
|
|
|
|
case EACCES:
|
|
|
|
case EPERM:
|
|
|
|
/* 403 */
|
|
|
|
status = 403;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = 501;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
webdav_gen_response_status_tag(srv, con, dst, status, b);
|
|
|
|
} else {
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
sqlite3_stmt *stmt = p->conf.stmt_delete_uri;
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
sqlite3_reset(stmt);
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
/* bind the values to the insert */
|
2005-08-19 00:05:52 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
sqlite3_bind_text(stmt, 1,
|
|
|
|
dst->rel_path->ptr,
|
|
|
|
dst->rel_path->used - 1,
|
|
|
|
SQLITE_TRANSIENT);
|
|
|
|
|
|
|
|
if (SQLITE_DONE != sqlite3_step(stmt)) {
|
|
|
|
/* */
|
|
|
|
WP();
|
2005-08-19 00:05:52 +00:00
|
|
|
}
|
2005-08-21 07:21:22 +00:00
|
|
|
#endif
|
2005-08-19 00:05:52 +00:00
|
|
|
}
|
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
return (status != 0);
|
2005-08-19 00:05:52 +00:00
|
|
|
}
|
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
static int webdav_delete_dir(server *srv, connection *con, plugin_data *p, physical *dst, buffer *b) {
|
2005-08-19 13:42:01 +00:00
|
|
|
DIR *dir;
|
|
|
|
int have_multi_status = 0;
|
2005-08-20 19:10:44 +00:00
|
|
|
physical d;
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
d.path = buffer_init();
|
|
|
|
d.rel_path = buffer_init();
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
if (NULL != (dir = opendir(dst->path->ptr))) {
|
2005-08-19 13:42:01 +00:00
|
|
|
struct dirent *de;
|
|
|
|
|
|
|
|
while(NULL != (de = readdir(dir))) {
|
2005-08-20 19:10:44 +00:00
|
|
|
struct stat st;
|
|
|
|
int status = 0;
|
|
|
|
|
|
|
|
if ((de->d_name[0] == '.' && de->d_name[1] == '\0') ||
|
|
|
|
(de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0')) {
|
|
|
|
continue;
|
2005-08-19 13:42:01 +00:00
|
|
|
/* ignore the parent dir */
|
2005-08-20 19:10:44 +00:00
|
|
|
}
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_copy_string_buffer(d.path, dst->path);
|
|
|
|
BUFFER_APPEND_SLASH(d.path);
|
|
|
|
buffer_append_string(d.path, de->d_name);
|
|
|
|
|
|
|
|
buffer_copy_string_buffer(d.rel_path, dst->rel_path);
|
|
|
|
BUFFER_APPEND_SLASH(d.rel_path);
|
|
|
|
buffer_append_string(d.rel_path, de->d_name);
|
|
|
|
|
|
|
|
/* stat and unlink afterwards */
|
|
|
|
if (-1 == stat(d.path->ptr, &st)) {
|
|
|
|
/* don't about it yet, rmdir will fail too */
|
|
|
|
} else if (S_ISDIR(st.st_mode)) {
|
|
|
|
have_multi_status = webdav_delete_dir(srv, con, p, &d, b);
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
/* try to unlink it */
|
|
|
|
if (-1 == rmdir(d.path->ptr)) {
|
|
|
|
switch(errno) {
|
|
|
|
case EACCES:
|
|
|
|
case EPERM:
|
|
|
|
/* 403 */
|
|
|
|
status = 403;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = 501;
|
|
|
|
break;
|
2005-08-19 13:42:01 +00:00
|
|
|
}
|
2005-08-20 19:10:44 +00:00
|
|
|
have_multi_status = 1;
|
|
|
|
|
|
|
|
webdav_gen_response_status_tag(srv, con, &d, status, b);
|
2005-08-19 13:42:01 +00:00
|
|
|
} else {
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
sqlite3_stmt *stmt = p->conf.stmt_delete_uri;
|
|
|
|
|
|
|
|
status = 0;
|
|
|
|
|
|
|
|
sqlite3_reset(stmt);
|
|
|
|
|
|
|
|
/* bind the values to the insert */
|
|
|
|
|
|
|
|
sqlite3_bind_text(stmt, 1,
|
|
|
|
d.rel_path->ptr,
|
|
|
|
d.rel_path->used - 1,
|
|
|
|
SQLITE_TRANSIENT);
|
|
|
|
|
|
|
|
if (SQLITE_DONE != sqlite3_step(stmt)) {
|
|
|
|
/* */
|
|
|
|
WP();
|
2005-08-19 13:42:01 +00:00
|
|
|
}
|
2005-08-21 07:21:22 +00:00
|
|
|
#endif
|
2005-08-19 13:42:01 +00:00
|
|
|
}
|
2005-08-20 19:10:44 +00:00
|
|
|
} else {
|
|
|
|
have_multi_status = webdav_delete_file(srv, con, p, &d, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dir);
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_free(d.path);
|
|
|
|
buffer_free(d.rel_path);
|
|
|
|
}
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
return have_multi_status;
|
|
|
|
}
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
static int webdav_copy_file(server *srv, connection *con, plugin_data *p, physical *src, physical *dst, int overwrite) {
|
|
|
|
stream s;
|
|
|
|
int status = 0, ofd;
|
|
|
|
|
2005-08-21 10:06:23 +00:00
|
|
|
UNUSED(con);
|
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
if (stream_open(&s, src->path)) {
|
|
|
|
return 403;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (-1 == (ofd = open(dst->path->ptr, O_WRONLY|O_TRUNC|O_CREAT|(overwrite ? 0 : O_EXCL), 0600))) {
|
|
|
|
/* opening the destination failed for some reason */
|
|
|
|
switch(errno) {
|
|
|
|
case EEXIST:
|
|
|
|
status = 412;
|
|
|
|
break;
|
|
|
|
case EISDIR:
|
|
|
|
status = 409;
|
|
|
|
break;
|
|
|
|
case ENOENT:
|
|
|
|
/* at least one part in the middle wasn't existing */
|
|
|
|
status = 409;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = 403;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
stream_close(&s);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (-1 == write(ofd, s.start, s.size)) {
|
|
|
|
switch(errno) {
|
|
|
|
case ENOSPC:
|
|
|
|
status = 507;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = 403;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
stream_close(&s);
|
|
|
|
close(ofd);
|
|
|
|
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
if (0 == status) {
|
|
|
|
/* copy worked fine, copy connected properties */
|
|
|
|
sqlite3_stmt *stmt = p->conf.stmt_copy_uri;
|
|
|
|
|
|
|
|
sqlite3_reset(stmt);
|
|
|
|
|
|
|
|
/* bind the values to the insert */
|
|
|
|
sqlite3_bind_text(stmt, 1,
|
|
|
|
dst->rel_path->ptr,
|
|
|
|
dst->rel_path->used - 1,
|
|
|
|
SQLITE_TRANSIENT);
|
|
|
|
|
|
|
|
sqlite3_bind_text(stmt, 2,
|
|
|
|
src->rel_path->ptr,
|
|
|
|
src->rel_path->used - 1,
|
|
|
|
SQLITE_TRANSIENT);
|
|
|
|
|
|
|
|
if (SQLITE_DONE != sqlite3_step(stmt)) {
|
|
|
|
/* */
|
|
|
|
WP();
|
|
|
|
}
|
|
|
|
}
|
2005-08-21 07:21:22 +00:00
|
|
|
#endif
|
2005-08-20 19:10:44 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int webdav_copy_dir(server *srv, connection *con, plugin_data *p, physical *src, physical *dst, int overwrite) {
|
|
|
|
DIR *srcdir;
|
|
|
|
int status = 0;
|
|
|
|
|
|
|
|
if (NULL != (srcdir = opendir(src->path->ptr))) {
|
|
|
|
struct dirent *de;
|
|
|
|
physical s, d;
|
|
|
|
|
|
|
|
s.path = buffer_init();
|
|
|
|
s.rel_path = buffer_init();
|
|
|
|
|
|
|
|
d.path = buffer_init();
|
|
|
|
d.rel_path = buffer_init();
|
|
|
|
|
|
|
|
while (NULL != (de = readdir(srcdir))) {
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if ((de->d_name[0] == '.' && de->d_name[1] == '\0') ||
|
|
|
|
(de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0')) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer_copy_string_buffer(s.path, src->path);
|
|
|
|
BUFFER_APPEND_SLASH(s.path);
|
|
|
|
buffer_append_string(s.path, de->d_name);
|
|
|
|
|
|
|
|
buffer_copy_string_buffer(d.path, dst->path);
|
|
|
|
BUFFER_APPEND_SLASH(d.path);
|
|
|
|
buffer_append_string(d.path, de->d_name);
|
|
|
|
|
|
|
|
buffer_copy_string_buffer(s.rel_path, src->rel_path);
|
|
|
|
BUFFER_APPEND_SLASH(s.rel_path);
|
|
|
|
buffer_append_string(s.rel_path, de->d_name);
|
|
|
|
|
|
|
|
buffer_copy_string_buffer(d.rel_path, dst->rel_path);
|
|
|
|
BUFFER_APPEND_SLASH(d.rel_path);
|
|
|
|
buffer_append_string(d.rel_path, de->d_name);
|
|
|
|
|
|
|
|
if (-1 == stat(s.path->ptr, &st)) {
|
|
|
|
/* why ? */
|
|
|
|
} else if (S_ISDIR(st.st_mode)) {
|
|
|
|
/* a directory */
|
|
|
|
if (-1 == mkdir(d.path->ptr, 0700) &&
|
|
|
|
errno != EEXIST) {
|
|
|
|
/* WTH ? */
|
|
|
|
} else {
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
sqlite3_stmt *stmt = p->conf.stmt_copy_uri;
|
|
|
|
|
|
|
|
if (0 != (status = webdav_copy_dir(srv, con, p, &s, &d, overwrite))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* directory is copied, copy the properties too */
|
|
|
|
|
|
|
|
sqlite3_reset(stmt);
|
|
|
|
|
|
|
|
/* bind the values to the insert */
|
|
|
|
sqlite3_bind_text(stmt, 1,
|
|
|
|
dst->rel_path->ptr,
|
|
|
|
dst->rel_path->used - 1,
|
|
|
|
SQLITE_TRANSIENT);
|
|
|
|
|
|
|
|
sqlite3_bind_text(stmt, 2,
|
|
|
|
src->rel_path->ptr,
|
|
|
|
src->rel_path->used - 1,
|
|
|
|
SQLITE_TRANSIENT);
|
|
|
|
|
|
|
|
if (SQLITE_DONE != sqlite3_step(stmt)) {
|
|
|
|
/* */
|
|
|
|
WP();
|
2005-08-19 13:42:01 +00:00
|
|
|
}
|
2005-08-21 07:21:22 +00:00
|
|
|
#endif
|
2005-08-20 19:10:44 +00:00
|
|
|
}
|
|
|
|
} else if (S_ISREG(st.st_mode)) {
|
|
|
|
/* a plain file */
|
|
|
|
if (0 != (status = webdav_copy_file(srv, con, p, &s, &d, overwrite))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_free(s.path);
|
|
|
|
buffer_free(s.rel_path);
|
|
|
|
buffer_free(d.path);
|
|
|
|
buffer_free(d.rel_path);
|
|
|
|
|
|
|
|
closedir(srcdir);
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2005-08-21 07:21:22 +00:00
|
|
|
static int webdav_get_live_property(server *srv, connection *con, plugin_data *p, physical *dst, char *prop_name, buffer *b) {
|
2005-08-20 19:10:44 +00:00
|
|
|
stat_cache_entry *sce = NULL;
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
if (HANDLER_ERROR != (stat_cache_get_entry(srv, con, dst->path, &sce))) {
|
|
|
|
char ctime_buf[] = "2005-08-18T07:27:16Z";
|
|
|
|
char mtime_buf[] = "Thu, 18 Aug 2005 07:27:16 GMT";
|
|
|
|
size_t k;
|
|
|
|
|
2005-08-21 07:21:22 +00:00
|
|
|
if (0 == strcmp(prop_name, "resourcetype")) {
|
2005-08-20 19:10:44 +00:00
|
|
|
if (S_ISDIR(sce->st.st_mode)) {
|
|
|
|
buffer_append_string(b, "<D:resourcetype><D:collection/></D:resourcetype>");
|
|
|
|
found = 1;
|
|
|
|
}
|
2005-08-21 07:21:22 +00:00
|
|
|
} else if (0 == strcmp(prop_name, "getcontenttype")) {
|
2005-08-20 19:10:44 +00:00
|
|
|
if (S_ISDIR(sce->st.st_mode)) {
|
|
|
|
buffer_append_string(b, "<D:getcontenttype>httpd/unix-directory</D:getcontenttype>");
|
|
|
|
found = 1;
|
|
|
|
} else if(S_ISREG(sce->st.st_mode)) {
|
|
|
|
for (k = 0; k < con->conf.mimetypes->used; k++) {
|
|
|
|
data_string *ds = (data_string *)con->conf.mimetypes->data[k];
|
|
|
|
|
|
|
|
if (ds->key->used == 0) continue;
|
|
|
|
|
|
|
|
if (buffer_is_equal_right_len(p->tmp_buf, ds->key, ds->key->used - 1)) {
|
|
|
|
buffer_append_string(b,"<D:getcontenttype>");
|
|
|
|
buffer_append_string_buffer(b, ds->value);
|
|
|
|
buffer_append_string(b, "</D:getcontenttype>");
|
|
|
|
found = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2005-08-19 13:42:01 +00:00
|
|
|
}
|
|
|
|
}
|
2005-08-21 07:21:22 +00:00
|
|
|
} else if (0 == strcmp(prop_name, "creationdate")) {
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_append_string(b, "<D:creationdate ns0:dt=\"dateTime.tz\">");
|
|
|
|
strftime(ctime_buf, sizeof(ctime_buf), "%Y-%m-%dT%H:%M:%SZ", gmtime(&(sce->st.st_ctime)));
|
|
|
|
buffer_append_string(b, ctime_buf);
|
|
|
|
buffer_append_string(b, "</D:creationdate>");
|
|
|
|
found = 1;
|
2005-08-21 07:21:22 +00:00
|
|
|
} else if (0 == strcmp(prop_name, "getlastmodified")) {
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_append_string(b,"<D:getlastmodified ns0:dt=\"dateTime.rfc1123\">");
|
|
|
|
strftime(mtime_buf, sizeof(mtime_buf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(sce->st.st_mtime)));
|
|
|
|
buffer_append_string(b, mtime_buf);
|
|
|
|
buffer_append_string(b, "</D:getlastmodified>");
|
|
|
|
found = 1;
|
2005-08-21 07:21:22 +00:00
|
|
|
} else if (0 == strcmp(prop_name, "getcontentlength")) {
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_append_string(b,"<D:getcontentlength>");
|
|
|
|
buffer_append_off_t(b, sce->st.st_size);
|
|
|
|
buffer_append_string(b, "</D:getcontentlength>");
|
|
|
|
found = 1;
|
2005-08-21 07:21:22 +00:00
|
|
|
} else if (0 == strcmp(prop_name, "getcontentlanguage")) {
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer_append_string(b,"<D:getcontentlanguage>");
|
|
|
|
buffer_append_string(b, "en");
|
|
|
|
buffer_append_string(b, "</D:getcontentlanguage>");
|
|
|
|
found = 1;
|
2005-08-19 13:42:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
return found ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2005-08-21 07:21:22 +00:00
|
|
|
static int webdav_get_property(server *srv, connection *con, plugin_data *p, physical *dst, char *prop_name, char *prop_ns, buffer *b) {
|
|
|
|
if (0 == strcmp(prop_ns, "DAV:")) {
|
2005-08-20 19:10:44 +00:00
|
|
|
/* a local 'live' property */
|
|
|
|
return webdav_get_live_property(srv, con, p, dst, prop_name, b);
|
|
|
|
} else {
|
|
|
|
int found = 0;
|
2005-08-21 07:21:22 +00:00
|
|
|
#ifdef USE_PROPPATCH
|
2005-08-20 19:10:44 +00:00
|
|
|
/* perhaps it is in sqlite3 */
|
|
|
|
sqlite3_reset(p->conf.stmt_select_prop);
|
|
|
|
|
|
|
|
/* bind the values to the insert */
|
|
|
|
|
|
|
|
sqlite3_bind_text(p->conf.stmt_select_prop, 1,
|
|
|
|
dst->rel_path->ptr,
|
|
|
|
dst->rel_path->used - 1,
|
|
|
|
SQLITE_TRANSIENT);
|
|
|
|
sqlite3_bind_text(p->conf.stmt_select_prop, 2,
|
|
|
|
prop_name,
|
|
|
|
strlen(prop_name),
|
|
|
|
SQLITE_TRANSIENT);
|
|
|
|
sqlite3_bind_text(p->conf.stmt_select_prop, 3,
|
|
|
|
prop_ns,
|
|
|
|
strlen(prop_ns),
|
|
|
|
SQLITE_TRANSIENT);
|
|
|
|
|
|
|
|
/* it is the PK */
|
|
|
|
while (SQLITE_ROW == sqlite3_step(p->conf.stmt_select_prop)) {
|
|
|
|
/* there is a row for us, we only expect a single col 'value' */
|
2005-08-21 10:06:23 +00:00
|
|
|
webdav_gen_prop_tag(srv, con, prop_name, prop_ns, (char *)sqlite3_column_text(p->conf.stmt_select_prop, 0), b);
|
2005-08-20 19:10:44 +00:00
|
|
|
found = 1;
|
|
|
|
}
|
2005-08-21 07:21:22 +00:00
|
|
|
#endif
|
2005-08-20 19:10:44 +00:00
|
|
|
return found ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not found */
|
|
|
|
return -1;
|
|
|
|
}
|
2005-08-19 13:42:01 +00:00
|
|
|
|
2005-08-20 19:10:44 +00:00
|
|
|
typedef struct {
|
|
|
|
char *ns;
|
|
|
|
char *prop;
|
|
|
|
} webdav_property;
|
|
|
|
|
|
|
|
webdav_property live_properties[] = {
|
|
|
|
{ "DAV:", "creationdate" },
|
|
|
|
{ "DAV:", "displayname" },
|
|
|
|
{ "DAV:", "getcontentlanguage" },
|
|
|
|
{ "DAV:", "getcontentlength" },
|
|
|
|
{ "DAV:", "getcontenttype" },
|
|
|
|
{ "DAV:", "getetag" },
|
|
|
|
{ "DAV:", "getlastmodified" },
|
|
|
|
{ "DAV:", "resourcetype" },
|
|
|
|
{ "DAV:", "lockdiscovery" },
|
|
|
|
{ "DAV:", "source" },
|
|
|
|
{ "DAV:", "supportedlock" },
|
|
|
|
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
webdav_property **ptr;
|
|
|
|
|
|
|
|
size_t used;
|
|
|
|
size_t size;
|
|
|
|
} webdav_properties;
|
|
|
|
|
|
|
|
static int webdav_get_props(server *srv, connection *con, plugin_data *p, physical *dst, webdav_properties *props, buffer *b_200, buffer *b_404) {
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (props) {
|
|
|
|
for (i = 0; i < props->used; i++) {
|
|
|
|
webdav_property *prop;
|
|
|
|
|
|
|
|
prop = props->ptr[i];
|
|
|
|
|
|
|
|
if (0 != webdav_get_property(srv, con, p,
|
2005-08-21 10:06:23 +00:00
|
|
|
dst, prop->prop, prop->ns, b_200)) {
|
2005-08-20 19:10:44 +00:00
|
|
|
webdav_gen_prop_tag(srv, con, prop->prop, prop->ns, NULL, b_404);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; live_properties[i].prop; i++) {
|
|
|
|
/* a local 'live' property */
|
|
|
|
webdav_get_live_property(srv, con, p, dst, live_properties[i].prop, b_200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2005-08-19 13:42:01 +00:00
|
|
|
}
|
2005-08-20 19:10:44 +00:00
|
|
|
|
2005-08-19 00:05:52 +00:00
|
|
|
URIHANDLER_FUNC(mod_webdav_subrequest_handler) {
|
|
|
|
plugin_data *p = p_d;
|
|
|
|
buffer *b;
|
|
|
|
DIR *dir;
|
|
|
|
data_string *ds;
|
|
|
|
int depth = -1;
|
2005-08-19 13:42:01 +00:00
|
|
|
struct stat st;
|
2005-08-20 19:10:44 +00:00
|
|
|
buffer *prop_200;
|
|
|
|
buffer *prop_404;
|
|
|
|
webdav_properties *req_props;
|
2005-08-19 00:05:52 +00:00
|
|
|
|
|
|
|
UNUSED(srv);
|
|
|
|
|
2005-08-19 08:37:21 +00:00
|
|
|
if (!p->conf.enabled) return HANDLER_GO_ON;
|
|