Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-01-22 17:44:24 +0300
committerRobin Appelman <robin@icewind.nl>2021-03-23 16:52:31 +0300
commite5dc1a8085226492b6d323142381fd163451c06d (patch)
tree7f281700c60af538de5df4890af6c4162b64c232 /lib/private/Files/Storage
parenta219fa587af77bcb5f9d0a9a9cd3b0e0134153ff (diff)
Set umask before operations that create local files
this solves issues where "other php stuff" is messing with the umask Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Storage')
-rw-r--r--lib/private/Files/Storage/Local.php20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 944b0b69959..47d3bb8f189 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -87,8 +87,9 @@ class Local extends \OC\Files\Storage\Common {
public function mkdir($path) {
$sourcePath = $this->getSourcePath($path);
+ $oldMask = umask(022);
$result = @mkdir($sourcePath, 0777, true);
- chmod($sourcePath, 0755);
+ umask($oldMask);
return $result;
}
@@ -258,11 +259,13 @@ class Local extends \OC\Files\Storage\Common {
if ($this->file_exists($path) and !$this->isUpdatable($path)) {
return false;
}
+ $oldMask = umask(022);
if (!is_null($mtime)) {
$result = @touch($this->getSourcePath($path), $mtime);
} else {
$result = @touch($this->getSourcePath($path));
}
+ umask($oldMask);
if ($result) {
clearstatcache(true, $this->getSourcePath($path));
}
@@ -275,7 +278,10 @@ class Local extends \OC\Files\Storage\Common {
}
public function file_put_contents($path, $data) {
- return file_put_contents($this->getSourcePath($path), $data);
+ $oldMask = umask(022);
+ $result = file_put_contents($this->getSourcePath($path), $data);
+ umask($oldMask);
+ return $result;
}
public function unlink($path) {
@@ -349,12 +355,18 @@ class Local extends \OC\Files\Storage\Common {
if ($this->is_dir($path1)) {
return parent::copy($path1, $path2);
} else {
- return copy($this->getSourcePath($path1), $this->getSourcePath($path2));
+ $oldMask = umask(022);
+ $result = copy($this->getSourcePath($path1), $this->getSourcePath($path2));
+ umask($oldMask);
+ return $result;
}
}
public function fopen($path, $mode) {
- return fopen($this->getSourcePath($path), $mode);
+ $oldMask = umask(022);
+ $result = fopen($this->getSourcePath($path), $mode);
+ umask($oldMask);
+ return $result;
}
public function hash($type, $path, $raw = false) {