6

I'm using sabre/dav library for my project and I'm having some difficulties with preventing default Windows WebDAV client "deleting" a file that shouldn't be deleted. The implementation in the server part is ok and Forbidden statuses are thrown and acknowledged apparently by other clients (Finder, CyberDuck) that abort the deletion process with a forbidden error to user. The same statuses are thrown back at Windows client, but it seems that it simply "deletes" the files, that are still available on server-side. By refreshing the folder those files are again visible. It seems that Win client simply ignores the forbidden responses and virtually deletes folder, so that it isn't visible anymore.

The bigger problem is that if for a reason you decide to delete a folder, where there are protected and unprotected files/folders underneath, it deletes all of the unprotected ones, because it fails to acknowledge the first (or any) Forbidden response. Other WebDAV clients detect this and stop the deletion process therefore the designated folder and its child folders/files are untouched.

Example of a forbidden response, when trying to delete a folder or file:

HTTP/1.1 403 Forbidden
Server: nginx/1.8.0
Date: Wed, 29 Jul 2015 13:55:11 GMT
Content-Type: application/xml; charset=utf-8
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-Powered-By: PHP/5.4.41-1~dotdeb+7.1
X-Sabre-Version: 2.1.3
Vary: Accept-Encoding,User-Agent
Content-Length: 320

<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:sabredav-version>2.1.3</s:sabredav-version>
  <s:exception>Sabre\DAV\Exception\Forbidden</s:exception>
  <s:message>Permission denied to delete node</s:message>
</d:error>

Tested default Win client on Win8.1 x86.

Any idea how to force Win WebDav client to detect Forbidden responses and terminate deletion process?

Thanks.

sumone
  • 408
  • 4
  • 12
  • It might be possible to send some webdav properties to windows, indicating that the file should be treated as read-only. Not 100% sure how those properties look like though. – Evert Jul 29 '15 at 15:58
  • I've already tried several properties and ways from webdav specs, but none did the trick. Is there some kind of document over the internet (very well hidden) that describes what Windows webDAV client requires to have in responses? – sumone Jul 29 '15 at 16:38

1 Answers1

0

As mentioned by Evert, I think you could bypass the problem with properties: https://learn.microsoft.com/en-us/openspecs/sharepoint_protocols/ms-wdvme/f83d826b-7fad-4f80-838c-5c7cc98cb59f

This is described here: How to make file READ ONLY when exposed through WebDAV

Edit: It works in terms of you can set the read-only flag on the file, but this does windows explorer not prevent from sending the Delete request and ignoring the 403 status code. Windows explorer seems just to be a bad webdav client....

Pete
  • 81
  • 1
  • 8