-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[6.x] Allows multiple OS users to share values cached in file store #32841
Conversation
To address the bug described above, I'm proposing adding an The new flag is used by FileStore#put to indicate that we only wish to apply $filePermission to files that we own. This is an improvement over existing behaviour, because the chmod will either continue to apply cleanly, or we will ignore any exception that was previously thrown and continue on. It is safe to ignore this exception, because if we encounter a file that we don't own in the cache directory, it was very likely written by a different PHP process running the Laravel FileStore code, which will itself have already applied the $filePermissions to this file. |
@@ -192,9 +192,13 @@ public function append($path, $data) | |||
* @param int|null $mode | |||
* @return mixed | |||
*/ | |||
public function chmod($path, $mode = null) | |||
public function chmod($path, $mode = null, $ensureOwnership = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change unfortunately.
In my opinion it's not the chowns job to ensure this, also since this is changing a public api it should target master. Better solutions IMO:
|
Breaking change as noted above. |
Thank you all for looking. I think there is a bug here to be resolved, so I wonder if you might consider an alternative solution. (I'm happy to raise the PR). How about the second solution proposed by @netpok? This would amount to this change in FileStore: if ($result !== false && $result > 0) {
- if (! is_null($this->filePermission))
+ if (! is_null($this->filePermission) && $this->files->chmod($path) !== $this->filePermission) {
$this->files->chmod($path, $this->filePermission);
} |
@louismrose Sent a PR for it. Also the code you sent is not correct since the chmod will return an octal string but it will be evaluated as a decimal string, |
This modifies some of the behaviour in 61b5aa1
From pull request #31579
That change was intended to make it easier for multiple OS users to read/write the same cached values when using the FileStore driver. However, the change introduced a subtle bug. Suppose we have the following situation:
www-data
) puts a value in the cache.2 Some time later but before the value from (1) has expired, another user (say
ubuntu
) attempts to update the value written in (1).This will fail irrespective of what $filePermission value is configured for FileStore because:
www-data
ubuntu
from changing the file permissions of a file owned bywww-data
In short, the $filePermission option is not working as intended when two users try to write to the same cache key.