net icon indicating copy to clipboard operation
net copied to clipboard

webdav: return forbidden on failed proppatch

Open klarose opened this issue 3 years ago • 2 comments

Some file systems do not allow opening directories with a write flag. The PROPPATCH implementation always opens all files it tries to patch with O_RDWR. When running on Linux with the Dir implementation of FileSystem, this leads to all PROPPATCH calls to a directory failing with an Internal Server Error.

Some clients, such as git via the Microsoft Mini Redirector try to patch directories' properties. A server using a Dir FileSystem fails in this situation, which makes it unusable for that entire class of clients.

Rather than failing with a Internal Server Error we can instead return Forbidden, which indicates to the client that it's not allowed to patch properties on that file. This patch does so if we fail to open the file, and the error is because of a lack of permission, or because the file is a directory. We don't unconditionally return Forbidden in this case because other errors are more likey to be ephemeral: a client retrying could possibly succeed in a subsequent patch.

Fixes golang/go#43929

klarose avatar Jan 26 '21 21:01 klarose

This PR (HEAD: ee2d1ddf10a919a6efc45a073007f52f28527bf8) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/net/+/286992 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off) See the Wiki page for more info

gopherbot avatar Jan 26 '21 21:01 gopherbot

I had something similar here, I'll test your patch too, thank you

drakkan avatar Mar 09 '21 10:03 drakkan