Skip to content

Conversation

@st3iny
Copy link
Member

@st3iny st3iny commented Mar 4, 2024

  • Resolves: none

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

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>
@st3iny st3iny added bug 2. developing Work in progress labels Mar 4, 2024
@st3iny st3iny self-assigned this Mar 4, 2024
Comment on lines +236 to +238
$writtenBytes = @file_put_contents($testFile, "TEST");
if ($writtenBytes !== false) {
$permissions += Constants::PERMISSION_DELETE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does creating a random file successfully imply that the other file is deletable? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense!

@icewind1991
Copy link
Member

icewind1991 commented Mar 5, 2024

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

@st3iny
Copy link
Member Author

st3iny commented Mar 18, 2024

This is not longer required.

@st3iny st3iny closed this Mar 18, 2024
@st3iny st3iny deleted the fix/is_writable-nfs branch March 18, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants