Skip to content

Commit e09921f

Browse files
committed
explicitly set permissions for newly created files
Signed-off-by: Robin Appelman <[email protected]>
1 parent a219fa5 commit e09921f

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

lib/private/Files/Storage/Local.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ public function touch($path, $mtime = null) {
263263
} else {
264264
$result = @touch($this->getSourcePath($path));
265265
}
266+
chmod($this->getSourcePath($path), 0644);
266267
if ($result) {
267268
clearstatcache(true, $this->getSourcePath($path));
268269
}
@@ -275,7 +276,9 @@ public function file_get_contents($path) {
275276
}
276277

277278
public function file_put_contents($path, $data) {
278-
return file_put_contents($this->getSourcePath($path), $data);
279+
$result = file_put_contents($this->getSourcePath($path), $data);
280+
chmod($this->getSourcePath($path), 0644);
281+
return $result;
279282
}
280283

281284
public function unlink($path) {
@@ -349,12 +352,21 @@ public function copy($path1, $path2) {
349352
if ($this->is_dir($path1)) {
350353
return parent::copy($path1, $path2);
351354
} else {
352-
return copy($this->getSourcePath($path1), $this->getSourcePath($path2));
355+
$result = copy($this->getSourcePath($path1), $this->getSourcePath($path2));
356+
if ($result) {
357+
chmod($this->getSourcePath($path2), 0644);
358+
}
359+
return $result;
353360
}
354361
}
355362

356363
public function fopen($path, $mode) {
357-
return fopen($this->getSourcePath($path), $mode);
364+
umask(022);
365+
$result = fopen($this->getSourcePath($path), $mode);
366+
if ($mode !== 'r') {
367+
chmod($this->getSourcePath($path), 0644);
368+
}
369+
return $result;
358370
}
359371

360372
public function hash($type, $path, $raw = false) {

0 commit comments

Comments
 (0)