-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
testing/fstest: TestFS: relax check ReadDir based on perms #63707
Comments
Cc: @bcmills |
Add testdata/perms.sqlar to check the permissions system. This allowed to discover two issues in testing/fstest.TestFS: - golang/go#63675 errors must be unwrappable - golang/go#63707 relax check on ReadDir if mode & 0444 != 0444
Add testdata/perms.sqlar to check the permissions system. This allowed to discover two issues in testing/fstest.TestFS: - golang/go#63675 errors must be unwrappable - golang/go#63707 relax check on ReadDir if mode & 0444 != 0444
Permission bits aren't universally supported; if |
@josharian May I ask your opinion on this (as you were the author of #46776 as well as of various io/fs.FS implementations)? |
@neild The documentation for
|
TL;DR
Drop one false positive case in
testing/fstest.TestFS
: it is ok forReadDir
to returnErrPermission
if thefs.FileMode
of the file says some users are not allowed to read the directory.Context
With
io/fs.FS
, there is no way to select which permission bits (fs.FileMode
) apply when reading a file. So fstest.TestFS has no way to enforce that given a FileMode's file/directory based on user/group/others permission bits,Open
,ReadFile
orReadDir
should trigger or not anfs.ErrPermission
.Currently any error (including
ErrPermission
) onReadDir
is always considered an error. However returningfs.ErrPermission
is correct behaviour if the filesystem enforcesfs.FileMode
and the directory has read permissions bits off.Proposal
I propose that
TestFS
to ignoreErrPermission
onReadDir
if at least one read permission bit is not set: ignoreErrPermission
(and silently skip otherReadDir
checks) ifmode & 0444 != 0444
.Impact
This change will only drop some returned errors and will never raise more errors, so backward compatibility is preserved.
The text was updated successfully, but these errors were encountered: