-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Lock] fix lock file permissions #27903
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
Conversation
@@ -81,7 +81,7 @@ private function lock(Key $key, $blocking) | |||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; }); | |||
if (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) { | |||
if ($handle = fopen($fileName, 'x')) { | |||
chmod($fileName, 0444); | |||
chmod($fileName, 0666); |
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.
0644?
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.
True, that should suffice of course.
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.
I don't think so as that would prohibit locks across different users, wouldn't it?
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.
@xabbuh good point
@nicolas-grekas what do you think? Should we change it back to 0666
?
d4b4776
to
23481a1
Compare
Thank you @fritzmg. |
This PR was squashed before being merged into the 3.4 branch (closes #27903). Discussion ---------- [Lock] fix lock file permissions | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | see discussion below | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - See [this comment](#27668 (comment)). Since we are using `r+` now to fix an issue on Solaris, we also need to change the file permissions when the lock file is created for the first time. Otherwise ```php fopen($fileName, 'r+') ``` will fail due to the file permissions and while ```php fopen($fileName, 'r') ``` will work, the subsequent locking will again fail on Solaris. Changing the file permissions to `0666` fixes this issue. __However__ any lock file that was generated _prior_ to this change will still cause issues and would need to be manually deleted. Usually the default `sys_get_temp_dir()` location is used for the lock files and _usually_ these files are purged periodically, so it probably won't matter that much. But it still might cause some confusion since it will not be transparent, why the file lock failed on Solaris systems. Commits ------- 23481a1 [Lock] fix lock file permissions
This PR was squashed before being merged into the 2.8 branch (closes #27904). Discussion ---------- [Filesystem] fix lock file permissions | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | see linked discussion | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - See #27903 Commits ------- 7a68fea [Filesystem] fix lock file permissions
Just so that the discussion does not get lost: @nicolas-grekas I think we should use |
I fixed it to 0666 directly in the branch. |
See this comment. Since we are using
r+
now to fix an issue on Solaris, we also need to change the file permissions when the lock file is created for the first time. Otherwisewill fail due to the file permissions and while
will work, the subsequent locking will again fail on Solaris.
Changing the file permissions to
0666
fixes this issue. However any lock file that was generated prior to this change will still cause issues and would need to be manually deleted. Usually the defaultsys_get_temp_dir()
location is used for the lock files and usually these files are purged periodically, so it probably won't matter that much. But it still might cause some confusion since it will not be transparent, why the file lock failed on Solaris systems.