Skip to content
Snippets Groups Projects
Unverified Commit 5a61a794 authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Do not write and read rootcerts.crt at the same time


(Possibly) fixes #3470

When updating the main file /files_external/rootcerts.crt we should not
read from /files_external/rootcerts.crt at the same time.

For 2 reasons: writing to a file and reading from it at the same time
can have non deterministic results

And we don't want all the certificates to appear 2 times in there.

This isn't caught by our standard file locking (that does not allow this
actually) because it is in a non locked path....

Signed-off-by: default avatarRoeland Jago Douma <roeland@famdouma.nl>
parent 46f7e820
No related branches found
No related tags found
Loading
...@@ -119,7 +119,8 @@ class CertificateManager implements ICertificateManager { ...@@ -119,7 +119,8 @@ class CertificateManager implements ICertificateManager {
return; return;
} }
$fhCerts = $this->view->fopen($path . '/rootcerts.crt', 'w'); $certPath = $path . 'rootcerts.crt';
$fhCerts = $this->view->fopen($certPath, 'w');
// Write user certificates // Write user certificates
foreach ($certs as $cert) { foreach ($certs as $cert) {
...@@ -136,7 +137,7 @@ class CertificateManager implements ICertificateManager { ...@@ -136,7 +137,7 @@ class CertificateManager implements ICertificateManager {
// Append the system certificate bundle // Append the system certificate bundle
$systemBundle = $this->getCertificateBundle(null); $systemBundle = $this->getCertificateBundle(null);
if ($this->view->file_exists($systemBundle)) { if ($systemBundle !== $certPath && $this->view->file_exists($systemBundle)) {
$systemCertificates = $this->view->file_get_contents($systemBundle); $systemCertificates = $this->view->file_get_contents($systemBundle);
fwrite($fhCerts, $systemCertificates); fwrite($fhCerts, $systemCertificates);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment