-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Filesystem] Consider the umask setting when dumping a file #19872
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
@nicolas-grekas I original also added the part that would listen to the umask, but that would have been a BC break, so I left it out. I do support the idea of adding it. 👍 |
@@ -554,8 +554,7 @@ public function dumpFile($filename, $content) | |||
throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename); | |||
} | |||
|
|||
// Ignore for filesystems that do not support umask | |||
@chmod($tmpFile, 0666); | |||
@chmod($tmpFile, 0666 & ~umask()); |
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.
Can you also adjust the test case to test this behavior? (be aware of windows not having umask)
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.
There is nothing I could adjust, because the Symfony unit test suite explicitly sets the umask to 0
, so the expected file permissions in the tests will always be 666
on both Unix and Windows.
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.
@hboomsma Ah, I see. Thank you. 😄
@leofeyer can you please rebase so that the merge commit goes away? |
Done. |
I'd be 👍 here, looks consistent to me. |
👍 |
1 similar comment
👍 |
Thank you @leofeyer. |
…e (leofeyer) This PR was merged into the 3.1 branch. Discussion ---------- [Filesystem] Consider the umask setting when dumping a file | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14246 , #17063 | License | MIT | Doc PR | - `Filesystem::dumpFile()` does not consider the umask setting and thus creates files with write permissions for everyone (`0666`). Other `chmod()` calls in Symfony do consider the umask setting (see e.g. [here](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/File/File.php#L101) or [here](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/File/UploadedFile.php#L230)), therefore I have adjusted the `dumpFile()` method accordingly. Commits ------- fdd266f Consider the umask setting when dumping a file.
Filesystem::dumpFile()
does not consider the umask setting and thus creates files with write permissions for everyone (0666
). Otherchmod()
calls in Symfony do consider the umask setting (see e.g. here or here), therefore I have adjusted thedumpFile()
method accordingly.