From 8a48e9ce78169daac2d45ebddbfb5bb496465ed3 Mon Sep 17 00:00:00 2001 From: rugk Date: Tue, 21 Jun 2016 17:18:11 +0200 Subject: [PATCH] Set permissions when saving files Fixes https://github.com/elrido/ZeroBin/issues/80 --- lib/persistence.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/persistence.php b/lib/persistence.php index 3b1f9af8..ed82720f 100644 --- a/lib/persistence.php +++ b/lib/persistence.php @@ -116,6 +116,7 @@ abstract class persistence self::_initialize(); $file = self::$_path . DIRECTORY_SEPARATOR . $filename; $writtenBytes = @file_put_contents($file, $data, LOCK_EX); + chmod($file, 0640); // protect file access if ($writtenBytes === false || $writtenBytes < strlen($data)) { throw new Exception('unable to write to file ' . $file, 13); }