fix: allow writes when user scope resolves to filesystem root

WithinScope compared targets against root+separator, which produced
"//" when the scope resolved to "/". No path matched, so every write
was rejected with os.ErrPermission (HTTP 403), breaking saves and
uploads for root-scoped installs. Skip the appended separator when root
already ends in one.
This commit is contained in:
Henrique Dias committed 2026-06-03 15:40:26 +02:00
1 parent 503fd6b01f
commit 6b04cbf5e9
2 files changed
+94 -1

No files matched your search

+11 -1
View File
@@ -217,7 +217,17 @@ func WithinScope(fsys afero.Fs, p string) (bool, error) {
return false, err
}
return resolved == root || strings.HasPrefix(resolved, root+string(filepath.Separator)), nil
// Compare against root with a trailing separator so a sibling like
// "/srvother" is not treated as being inside "/srv". When root is itself
// the filesystem boundary (e.g. "/"), it already ends in a separator, so
// avoid producing "//" — which no path would match — and accept any path
// under it.
prefix := root
if !strings.HasSuffix(prefix, string(filepath.Separator)) {
prefix += string(filepath.Separator)
}
return resolved == root || strings.HasPrefix(resolved, prefix), nil
}
// Checksum checksums a given File for a given User, using a specific