Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webdav backend incompatible with golang stdlib webdav implementation #825

Open
SISheogorath opened this issue Dec 22, 2024 · 1 comment
Open
Labels
🗄️ backend Related to a backup storage backend good first issue help wanted

Comments

@SISheogorath
Copy link

I think I found conflict between how the seedvault implementation expects directories to work and how golang handles it:

In this function, you test that directories exist using the HEAD function:

internal fun DavCollection.ensureFoldersExist(log: KLogger, folders: MutableSet<HttpUrl>) {
if (location.pathSize <= 2) return
val parent = location.newBuilder()
.removePathSegment(location.pathSize - 1)
.build()
if (parent in folders) return
val parentCollection = DavCollection(httpClient, parent)
try {
parentCollection.head { response ->
log.debugLog { "head($parent) = $response" }
folders.add(parent)
}
} catch (e: NotFoundException) {
log.debugLog { "$parent not found, creating..." }
parentCollection.mkColCreateMissing { response ->
log.debugLog { "mkColCreateMissing($parent) = $response" }
folders.add(parent)
}
}
}

golang doesn't support HEAD requests on directory listings:
https://github.com/golang/net/blob/dfc720dfe0cfc125116068c20efcdcb5e4eab464/webdav/webdav.go#L212

I checked the RFCs RFC4918 and RFC2068 but couldn't find any defintive answer how this should be handled. But there isn't really an answer to this, beyond "Treat GET and HEAD identical". The overall internet also seems undecided how to handle directory requests in webdav. (Here one of the samples I found).

I think the correct way to check for directories would be the usage of PROPFIND with a depth of 0. That would certainly be in line with the RFC4918 section 9.1.

This is an upstream issue for downstream issue GrapheneOS/os-issue-tracker#4558

@grote grote added 🗄️ backend Related to a backup storage backend help wanted good first issue labels Dec 23, 2024
@grote
Copy link
Collaborator

grote commented Dec 23, 2024

shouldn't be too difficult to change the head request to propfind(depth=0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄️ backend Related to a backup storage backend good first issue help wanted
Projects
None yet
Development

No branches or pull requests

2 participants