lighttpd1.4/src/mod_webdav.c

1628 lines
42 KiB
C
Raw Normal View History

#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#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
#include "base.h"
#include "log.h"
#include "buffer.h"
#include "response.h"
#include "plugin.h"
#include "stream.h"
#include "stat_cache.h"
/**
* 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 {
unsigned short enabled;
unsigned short is_readonly;
buffer *sqlite_db_name;
#ifdef USE_PROPPATCH
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;
#endif
} plugin_config;
typedef struct {
PLUGIN_DATA;
buffer *tmp_buf;
request_uri uri;
physical physical;
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();
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();
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];
if (!s) continue;
#ifdef USE_PROPPATCH
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);
}
#endif
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[] = {
{ "webdav.activate", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
{ "webdav.is-readonly", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
{ "webdav.sqlite-db-name", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 2 */
{ 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));
s->sqlite_db_name = buffer_init();
cv[0].destination = &(s->enabled);
cv[1].destination = &(s->is_readonly);
cv[2].destination = s->sqlite_db_name;
p->config_storage[i] = s;
if (0 != config_insert_values_global(srv, ((data_config *)srv->config_context->data[i])->value, cv)) {
return HANDLER_ERROR;
}
if (!buffer_is_empty(s->sqlite_db_name)) {
#ifdef USE_PROPPATCH
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;
}
#else
log_error_write(srv, __FILE__, __LINE__, "s", "Sorry, no sqlite3 and libxml2 support include, compile with --with-webdav-props");
return HANDLER_ERROR;
#endif
}
}
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];
PATCH(enabled);
PATCH(is_readonly);
#ifdef USE_PROPPATCH
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);
#endif
/* 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];
if (buffer_is_equal_string(du->key, CONST_STR_LEN("webdav.activate"))) {
PATCH(enabled);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("webdav.is-readonly"))) {
PATCH(is_readonly);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("webdav.sqlite-db-name"))) {
#ifdef USE_PROPPATCH
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);
#endif
}
}
}
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);
if (!p->conf.enabled) return HANDLER_GO_ON;
switch (con->request.http_method) {
case HTTP_METHOD_OPTIONS:
/* we fake a little bit but it makes MS W2k happy and it let's us mount the volume */
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"));
if (p->conf.is_readonly) {
response_header_insert(srv, con, CONST_STR_LEN("Allow"), CONST_STR_LEN("PROPFIND"));
} else {
response_header_insert(srv, con, CONST_STR_LEN("Allow"), CONST_STR_LEN("PROPFIND, DELETE, MKCOL, PUT, MOVE, COPY, PROPPATCH"));
}
break;
default:
break;
}
/* not found */
return HANDLER_GO_ON;
}
static int webdav_gen_prop_tag(server *srv, connection *con,
char *prop_name,
char *prop_ns,
char *value,
buffer *b) {
UNUSED(srv);
UNUSED(con);
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, "\"/>");
}
return 0;
}
static int webdav_gen_response_status_tag(server *srv, connection *con, physical *dst, int status, buffer *b) {
UNUSED(srv);
buffer_append_string(b,"<D:response xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n");
buffer_append_string(b,"<D:href>\n");
buffer_append_string_buffer(b, dst->rel_path);
buffer_append_string(b,"</D:href>\n");
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));
buffer_append_string(b,"</D:status>\n");
buffer_append_string(b,"</D:response>\n");
return 0;
}
static int webdav_delete_file(server *srv, connection *con, plugin_data *p, physical *dst, buffer *b) {
int status = 0;
/* 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 {
#ifdef USE_PROPPATCH
sqlite3_stmt *stmt = p->conf.stmt_delete_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);
if (SQLITE_DONE != sqlite3_step(stmt)) {
/* */
WP();
}
#endif
}
return (status != 0);
}
static int webdav_delete_dir(server *srv, connection *con, plugin_data *p, physical *dst, buffer *b) {
DIR *dir;
int have_multi_status = 0;
physical d;
d.path = buffer_init();
d.rel_path = buffer_init();
if (NULL != (dir = opendir(dst->path->ptr))) {
struct dirent *de;
while(NULL != (de = readdir(dir))) {
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;
/* ignore the parent dir */
}
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);
/* try to unlink it */
if (-1 == rmdir(d.path->ptr)) {
switch(errno) {
case EACCES:
case EPERM:
/* 403 */
status = 403;
break;
default:
status = 501;
break;
}
have_multi_status = 1;
webdav_gen_response_status_tag(srv, con, &d, status, b);
} else {
#ifdef USE_PROPPATCH
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();
}
#endif
}
} else {
have_multi_status = webdav_delete_file(srv, con, p, &d, b);
}
}
closedir(dir);
buffer_free(d.path);
buffer_free(d.rel_path);
}
return have_multi_status;
}
static int webdav_copy_file(server *srv, connection *con, plugin_data *p, physical *src, physical *dst, int overwrite) {
stream s;
int status = 0, ofd;
UNUSED(con);
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;
}
}
stream_close(&s);
close(ofd);
#ifdef USE_PROPPATCH
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();
}
}
#endif
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 {
#ifdef USE_PROPPATCH
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();
}
#endif
}
} else if (S_ISREG(st.st_mode)) {
/* a plain file */
if (0 != (status = webdav_copy_file(srv, con, p, &s, &d, overwrite))) {
break;
}
}
}
buffer_free(s.path);
buffer_free(s.rel_path);
buffer_free(d.path);
buffer_free(d.rel_path);
closedir(srcdir);
}
return status;
}
static int webdav_get_live_property(server *srv, connection *con, plugin_data *p, physical *dst, char *prop_name, buffer *b) {
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;
if (0 == strcmp(prop_name, "resourcetype")) {
if (S_ISDIR(sce->st.st_mode)) {
buffer_append_string(b, "<D:resourcetype><D:collection/></D:resourcetype>");
found = 1;
}
} else if (0 == strcmp(prop_name, "getcontenttype")) {
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;
}
}
}
} else if (0 == strcmp(prop_name, "creationdate")) {
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;
} else if (0 == strcmp(prop_name, "getlastmodified")) {
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;
} else if (0 == strcmp(prop_name, "getcontentlength")) {
buffer_append_string(b,"<D:getcontentlength>");
buffer_append_off_t(b, sce->st.st_size);
buffer_append_string(b, "</D:getcontentlength>");
found = 1;
} else if (0 == strcmp(prop_name, "getcontentlanguage")) {
buffer_append_string(b,"<D:getcontentlanguage>");
buffer_append_string(b, "en");
buffer_append_string(b, "</D:getcontentlanguage>");
found = 1;
}
}
return found ? 0 : -1;
}
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:")) {
/* a local 'live' property */
return webdav_get_live_property(srv, con, p, dst, prop_name, b);
} else {
int found = 0;
#ifdef USE_PROPPATCH
/* 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' */
webdav_gen_prop_tag(srv, con, prop_name, prop_ns, (char *)sqlite3_column_text(p->conf.stmt_select_prop, 0), b);
found = 1;
}
#endif
return found ? 0 : -1;
}
/* not found */
return -1;
}
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,
dst, prop->prop, prop->ns, b_200)) {
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;
}
URIHANDLER_FUNC(mod_webdav_subrequest_handler) {
plugin_data *p = p_d;
buffer *b;
DIR *dir;
data_string *ds;
int depth = -1;
struct stat st;
buffer *prop_200;
buffer *prop_404;
webdav_properties *req_props;
UNUSED(srv);
if (!p->conf.enabled) return HANDLER_GO_ON;