fix: fall back to creating a temp file on NFS mounts#43976
Closed
fix: fall back to creating a temp file on NFS mounts#43976
Conversation
The built-in method `is_writable()` is not reliable on NFS mounts so we should fall back to creating a random file to check for delete permissions. Ref https://stackoverflow.com/a/50801358 Ref #13237 Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Comment on lines
+236
to
+238
| $writtenBytes = @file_put_contents($testFile, "TEST"); | ||
| if ($writtenBytes !== false) { | ||
| $permissions += Constants::PERMISSION_DELETE; |
Member
There was a problem hiding this comment.
why does creating a random file successfully imply that the other file is deletable? 🤔
Member
Author
There was a problem hiding this comment.
Because we create the file on the parent directory. If we can create a new file in the parent directory we can also delete a file from it as the write permission bit is responsible for both.
Member
|
For primary/home storage we should just hardcode will permissions as we don't support anything but full permissions on the data directory. For local external storage this might still make sense though. But having to create a tmp file every time we query the permissions would be much to expensive |
Member
Author
|
This is not longer required. |
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.
Summary
The built-in method
is_writable()is not reliable on NFS mounts so we should fall back to creating a random file to check for delete permissions.This might have an impact on performance as we create, write to a file and unlink it again.
Ref https://stackoverflow.com/a/50801358
Ref #13237
TODO
Checklist