-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
do not write htaccess file if disk space is too low #41544
Conversation
/backport to stable27 |
Why? |
Because the file got truncated on @tobiasKaminsky's instance due to low disk space... |
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"); |
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.
You can also check if all bytes have been written. Should be something like this:
return (bool)@file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent . $content . "\n"); | |
$fullContent = $htaccessContent . $content . "\n"; | |
return @file_put_contents($setupHelper->pathToHtaccess(), $$fullContent) === strlen($fullContent); |
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 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...
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.
We had the same prpblem with config.php before and fixed in in the same way.
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.
It's another security in case something happen during the copy.
The file will already be erased, but at least you'll have the info
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.
Ah I see.
Signed-off-by: Simon L <szaimen@e.mail.de>
Signed-off-by: Simon L <szaimen@e.mail.de>
99a3dc6
to
3f6caa4
Compare
I copied the logic from
server/lib/private/Config.php
Lines 288 to 295 in 1b18b97