feat: improve permissions support#1059
Merged
G-Rath merged 16 commits intostreamich:masterfrom Sep 19, 2024
Merged
Conversation
While files are not a permitted place to create subdirectories in, the proper error should be ENOTDIR, not EACCES
G-Rath
requested changes
Sep 16, 2024
Collaborator
G-Rath
left a comment
There was a problem hiding this comment.
this is looking good to me - would you mind just running prettier over the files? (don't worry about commitlint, as everything will get squashed when we merge 🙂)
Contributor
Author
|
I found a bug in |
G-Rath
approved these changes
Sep 19, 2024
github-actions bot
pushed a commit
that referenced
this pull request
Sep 19, 2024
# [4.12.0](v4.11.2...v4.12.0) (2024-09-19) ### Features * improve permissions support ([#1059](#1059)) ([575a76b](575a76b))
Contributor
|
🎉 This PR is included in version 4.12.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
BadIdeaException
pushed a commit
to BadIdeaException/memfs
that referenced
this pull request
Oct 2, 2024
# [4.12.0](streamich/memfs@v4.11.2...v4.12.0) (2024-09-19) ### Features * improve permissions support ([streamich#1059](streamich#1059)) ([575a76b](streamich@575a76b))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pursuant to our discussion in #1009, this PR adds basic permission support to memfs. It supports the POSIX-compliant r, w and x permissions for user, group and world. It does not support the more eclectic permissions such as SUID, GUID, or the sticky bit.
Some remarks on design considerations/implementation details:
All permissions checking is done within
Volume.NodeandLinkremain permission agnostic, to stay in keeping with how existence checking was done. To make this possible, tree walking had to be moved fromLinkto a private method on the volume, though. The overhead, as per your requirement, is pretty small.Extensive tests are under
src/__tests__/volume/*. I could not quite figure out by what logic tests go intosrc/__tests__/volume.test.tsas opposed to a dedicated file undersrc/__tests__/volume/. In the end, I decided the latter was probably sort of avolume.test.ddirectory.I did not implement permissions checking for
chmodandchown, because their security model largely depends on whether the user is root or not. (More specifically, on whether the executing process has certain capability flags set, which I'm not sure there is a way to check from within Node.js anyways.) (NB: Forchmod, it also depends on whether the current user is the owner of the file to be changed.) For the most part, I left this out to prevent creating situations where the user locks themselves out from accessing a file, which is then irrevocable due to the lack of a concept of elevating privileges.I think in the
open*code path, there is duplicate symlink resolution: first by openFile, then again by openLink. I commented the second one out for a try, and all tests still passed. But since was already the case before I changed things around, I do not feel quite confident enough to delete it. In this PR, it is active code, but maybe you can take a look at it yourself.Resolves #1009