Compare commits

...

4 Commits

Author SHA1 Message Date
Robin Appelman 4b4a108cb3
fix part file rename check
Signed-off-by: Robin Appelman <robin@icewind.nl>
2020-06-23 15:37:25 +02:00
Robin Appelman 32f5cfd490
extend warning messages on rename failure
Signed-off-by: Robin Appelman <robin@icewind.nl>
2020-06-23 14:41:57 +02:00
Robin Appelman 9865023340
fix check for part file rename permissions
Signed-off-by: Robin Appelman <robin@icewind.nl>
2020-06-23 14:40:02 +02:00
Robin Appelman 30460d9545
add extra debug logging for rename failure
Signed-off-by: Robin Appelman <robin@icewind.nl>
2020-06-23 14:39:58 +02:00
3 changed files with 23 additions and 7 deletions

View File

@ -312,10 +312,12 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
if ($targetExists || ($sameFodler && !$isPartFile)) {
if (!$this->isUpdatable('')) {
$this->logger->warning("Blocking rename, target not updatable");
return false;
}
} else {
if (!$this->isCreatable('')) {
$this->logger->warning("Blocking rename, target not creatable");
return false;
}
}

View File

@ -337,7 +337,16 @@ class Local extends \OC\Files\Storage\Common {
}
}
return rename($this->getSourcePath($path1), $this->getSourcePath($path2));
$targetExists = file_exists($this->getSourcePath($path2));
$result = rename($this->getSourcePath($path1), $this->getSourcePath($path2));
if (!$result) {
$message = "Failed to rename file from " . $this->getSourcePath($path1) . " to " . $this->getSourcePath($path2) . ($targetExists ? " (target exists)" : "");
\OC::$server->getLogger()->logException(new \Exception($message));
}
return $result;
}
public function copy($path1, $path2) {

View File

@ -80,14 +80,19 @@ class PermissionsMask extends Wrapper {
}
public function rename($path1, $path2) {
$p = strpos($path1, $path2);
if ($p === 0) {
$part = substr($path1, strlen($path2));
//This is a rename of the transfer file to the original file
if (strpos($part, '.ocTransferId') === 0) {
return $this->checkMask(Constants::PERMISSION_CREATE) and parent::rename($path1, $path2);
//This is a rename of the transfer file to the original file
if (strpos($path1, '.ocTransferId') > 0) {
if (!$this->checkMask(Constants::PERMISSION_CREATE)) {
\OC::$server->getLogger()->warning("Blocking rename from $path1 to $path2, not enough permissions to create new file from part. mask: " . $this->mask);
}
return $this->checkMask(Constants::PERMISSION_CREATE) and parent::rename($path1, $path2);
}
if (!$this->checkMask(Constants::PERMISSION_UPDATE)) {
\OC::$server->getLogger()->warning("Blocking rename from $path1 to $path2, not enough permissions to update file. mask: " . $this->mask);
}
return $this->checkMask(Constants::PERMISSION_UPDATE) and parent::rename($path1, $path2);
}