Branch: Tag:

2018-02-01

2018-02-01 15:50:13 by Henrik Grubbström (Grubba) <grubba@grubba.org>

WebDAV: DELETE should also delete corresponding locks.

Comply with RFC 4918 9.6.

Fixes some of [WS-160].

1:   // Protocol support for RFC 2518   // - // $Id: webdav.pike,v 1.38 2008/08/15 12:33:55 mast Exp $ + // $Id$   //   // 2003-09-17 Henrik Grubbström   
9:   #include <module.h>   #include <request_trace.h>    - constant cvs_version = "$Id: webdav.pike,v 1.38 2008/08/15 12:33:55 mast Exp $"; + constant cvs_version = "$Id$";   constant thread_safe = 1;   constant module_name = "WebDAV: Protocol support";   constant module_type = MODULE_FIRST;
501:    if (res && res->error < 300) {    // Succeed in deleting some file(s).    empty_result = res; +  +  // RFC 4918 9.6: +  // A server processing a successful DELETE request: +  // +  // MUST destroy locks rooted on the deleted resource +  multiset(DAVLock) sub_locks = +  module->find_locks(path, -1, 0, id); +  foreach(sub_locks||(<>);DAVLock lock;) { +  SIMPLE_TRACE_ENTER(module, +  "DELETE: Unlocking %O...", lock); +  mapping fail = +  id->conf->unlock_file(lock->path, lock, id); +  if (fail) { +  TRACE_LEAVE("DELETE: Unlock failed."); +  } else { +  TRACE_LEAVE("DELETE: Unlock ok."); +  } +  }    return 0;    }    return res;