-
Notifications
You must be signed in to change notification settings - Fork 18k
testing/fstest: set perm 0555 for synthetized directories in MapFS #63468
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
Comments
Fix: diff --git a/src/testing/fstest/mapfs.go b/src/testing/fstest/mapfs.go
index a0b1f65668..b3fc0c8ad7 100644
--- a/src/testing/fstest/mapfs.go
+++ b/src/testing/fstest/mapfs.go
@@ -98,14 +98,14 @@ func (fsys MapFS) Open(name string) (fs.File, error) {
delete(need, fi.name)
}
for name := range need {
- list = append(list, mapFileInfo{name, &MapFile{Mode: fs.ModeDir}})
+ list = append(list, mapFileInfo{name, &MapFile{Mode: fs.ModeDir | 0555}})
}
sort.Slice(list, func(i, j int) bool {
return list[i].name < list[j].name
})
if file == nil {
- file = &MapFile{Mode: fs.ModeDir}
+ file = &MapFile{Mode: fs.ModeDir | 0555}
}
return &mapDir{name, mapFileInfo{elem, file}, list, 0}, nil
} |
CC @bcmills, @ianlancetaylor. |
Want to send a patch? https://go.dev/doc/contribute. |
Change https://go.dev/cl/534075 mentions this issue: |
🎉 |
As MapFS ignores filemodes and always grant read and traverse access on directories, let's make synthetized directory entries to expose filemode 0555 instead of 0000. Fixes golang#63468. Change-Id: I5d64a6bf2f2ac6082ca5dde55b3062669fb50b8d Reviewed-on: https://go-review.googlesource.com/c/go/+/534075 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
While I do agree that it makes sense for directories to have However, the documentation does still suggest that a directory can be created by setting the file mode to
|
testing/fstest.MapFS
should set a FileMode compatible with its behaviour: as reading and traversing directories just ignores filemodes (it doesn't check filemode before giving access to file content or directory content), it would be more consistent to synthetise directories with modefs.ModeDir | 0555
instead offs.ModeDir | 0000
.What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What did you do?
https://go.dev/play/p/3_nH4WnurYA
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: