fix etag generation incompatibility; from Jason Oster

This commit is contained in:
jakob 2008-11-09 18:26:03 +00:00
parent 393edbb883
commit 21e9baa036
3 changed files with 78 additions and 5 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.16 2008/02/23 00:20:53 bernd Exp $
# $OpenBSD: Makefile,v 1.17 2008/11/09 18:26:03 jakob Exp $
COMMENT= class 1 and 2 DAV server for the Apache webserver
DISTNAME= mod_dav-1.0.3-1.3.6
PKGNAME= mod_dav-1.0.3p5
PKGNAME= mod_dav-1.0.3p6
CATEGORIES= www
MASTER_SITES= http://www.webdav.org/mod_dav/

View File

@ -0,0 +1,61 @@
--- dav_fs_repos.c~ 2008-07-17 10:39:21.000000000 -0700
+++ dav_fs_repos.c 2008-07-18 08:37:40.000000000 -0700
@@ -47,6 +47,11 @@ struct dav_resource_private {
pool *pool; /* memory storage pool associated with request */
const char *pathname; /* full pathname to resource */
struct stat finfo; /* filesystem info */
+ /* additional values needed by dav_fs_getetag() */
+ time_t request_time;
+ time_t mtime;
+ void *per_dir_config;
+ table *notes;
};
/* private context for doing a filesystem walk */
@@ -567,6 +572,12 @@ static dav_resource * dav_fs_get_resourc
(void) ap_update_mtime(r, r->finfo.st_mtime);
+ /* additional values needed by dav_fs_getetag() */
+ ctx->request_time = r->request_time;
+ ctx->mtime = r->mtime;
+ ctx->per_dir_config = r->per_dir_config;
+ ctx->notes = r->notes;
+
/* Preserve case on OSes which fold canonical filenames */
#if MODULE_MAGIC_NUMBER_MAJOR > 19990320 || (MODULE_MAGIC_NUMBER_MAJOR == 19990320 && MODULE_MAGIC_NUMBER_MINOR >= 8)
filename = r->case_preserved_filename;
@@ -1664,7 +1675,7 @@ static dav_error * dav_fs_walk(dav_walke
* for file path.
* ### do we need to return weak tags sometimes?
*/
-static const char *dav_fs_getetag(const dav_resource *resource)
+static const char *dav_fs_getetag_orig(const dav_resource *resource)
{
dav_resource_private *ctx = resource->info;
@@ -1681,6 +1692,24 @@ static const char *dav_fs_getetag(const
return ap_psprintf(ctx->pool, "\"%lx\"", (unsigned long) ctx->finfo.st_mtime);
}
+static const char *dav_fs_getetag(const dav_resource *resource)
+{
+ dav_resource_private *ctx = resource->info;
+ request_rec r;
+
+ if (!resource->exists)
+ return ap_pstrdup(ctx->pool, "");
+
+ r.pool = ctx->pool;
+ r.request_time = ctx->request_time;
+ r.finfo = ctx->finfo;
+ r.mtime = ctx->mtime;
+ r.per_dir_config = ctx->per_dir_config;
+ r.notes = ctx->notes;
+
+ return ap_make_etag(&r, 0);
+}
+
static const dav_hooks_repository dav_hooks_repository_fs =
{
DEBUG_GET_HANDLER, /* normally: special GET handling not required */

View File

@ -1,6 +1,5 @@
$OpenBSD: patch-dav_util_c,v 1.1 2005/10/28 01:04:53 brad Exp $
--- dav_util.c.orig Thu Oct 27 20:53:15 2005
+++ dav_util.c Thu Oct 27 20:53:32 2005
--- dav_util.c~ 2008-07-18 07:35:25.000000000 -0700
+++ dav_util.c 2008-07-18 07:45:18.000000000 -0700
@@ -546,7 +546,7 @@ void dav_xml2text(pool * p,
array_header *namespaces,
int *ns_map,
@ -10,3 +9,16 @@ $OpenBSD: patch-dav_util_c,v 1.1 2005/10/28 01:04:53 brad Exp $
{
/* get the exact size, plus a null terminator */
size_t size = dav_elem_size(elem, style, namespaces, ns_map) + 1;
@@ -1254,7 +1254,11 @@ static dav_error * dav_validate_resource
switch(state_list->type) {
case dav_if_etag:
{
- int mismatch = strcmp(state_list->etag, etag);
+ const char *given_etag = state_list->etag;
+ const char *current_etag = etag;
+ if ((given_etag[0] == 'W') && (given_etag[1] == '/')) given_etag += 2;
+ if ((current_etag[0] == 'W') && (current_etag[1] == '/')) current_etag += 2;
+ int mismatch = strcmp(given_etag, current_etag);
if (state_list->condition == DAV_IF_COND_NORMAL && mismatch) {
/*