-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
do not write htaccess file if disk space is too low #41544
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -560,6 +560,14 @@ public static function updateHtaccess() { | |||||||
| } | ||||||||
|
|
||||||||
| if ($content !== '') { | ||||||||
| // Never write file back if disk space should be too low | ||||||||
| if (function_exists('disk_free_space')) { | ||||||||
| $df = disk_free_space(\OC::$SERVERROOT); | ||||||||
| $size = strlen($content) + 10240; | ||||||||
| if ($df !== false && $df < (float)$size) { | ||||||||
| throw new \Exception(\OC::$SERVERROOT . " does not have enough space for writing the htaccess file! Not writing it back!"); | ||||||||
| } | ||||||||
| } | ||||||||
| //suppress errors in case we don't have permissions for it | ||||||||
| return (bool)@file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent . $content . "\n"); | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also check if all bytes have been written. Should be something like this:
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not going to help here. The prpblem is that file_pu_content truncates the file if there is not enough space which should never happen as the file is very important to work...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We had the same prpblem with config.php before and fixed in in the same way.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's another security in case something happen during the copy.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see. |
||||||||
| } | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.