Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix moving files out of a shared folder #4329

Merged
merged 2 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getData($path) {
if ($data === null) {
return null;
}
$internalPath = $this->storage->getSourcePath($path);
$internalPath = $this->storage->getUnjailedPath($path);
$data['permissions'] = $this->storage->getSourceStorage()->getPermissions($internalPath);
return $data;
}
Expand Down
10 changes: 5 additions & 5 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function isSharable($path) {
}

public function fopen($path, $mode) {
if ($source = $this->getSourcePath($path)) {
if ($source = $this->getUnjailedPath($path)) {
switch ($mode) {
case 'r+':
case 'rb+':
Expand Down Expand Up @@ -274,7 +274,7 @@ public function fopen($path, $mode) {
'mode' => $mode,
);
\OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info);
return $this->nonMaskedStorage->fopen($this->getSourcePath($path), $mode);
return $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode);
}
return false;
}
Expand Down Expand Up @@ -302,7 +302,7 @@ public function rename($path1, $path2) {
}
}

return $this->nonMaskedStorage->rename($this->getSourcePath($path1), $this->getSourcePath($path2));
return $this->nonMaskedStorage->rename($this->getUnjailedPath($path1), $this->getUnjailedPath($path2));
}

/**
Expand Down Expand Up @@ -479,7 +479,7 @@ public function getWrapperStorage() {
public function file_get_contents($path) {
$info = [
'target' => $this->getMountPoint() . '/' . $path,
'source' => $this->getSourcePath($path),
'source' => $this->getUnjailedPath($path),
];
\OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_get_contents', $info);
return parent::file_get_contents($path);
Expand All @@ -488,7 +488,7 @@ public function file_get_contents($path) {
public function file_put_contents($path, $data) {
$info = [
'target' => $this->getMountPoint() . '/' . $path,
'source' => $this->getSourcePath($path),
'source' => $this->getUnjailedPath($path),
];
\OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info);
return parent::file_put_contents($path, $data);
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Node/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ private function getAbsolutePath(IMountPoint $mount, $path) {
$storage = $mount->getStorage();
if ($storage->instanceOfStorage('\OC\Files\Storage\Wrapper\Jail')) {
/** @var \OC\Files\Storage\Wrapper\Jail $storage */
$jailRoot = $storage->getSourcePath('');
$jailRoot = $storage->getUnjailedPath('');
$rootLength = strlen($jailRoot) + 1;
if ($path === $jailRoot) {
return $mount->getMountPoint();
Expand Down
11 changes: 9 additions & 2 deletions lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

namespace OC\Files\Storage;

use OC\Files\Storage\Wrapper\Jail;
use OCP\Files\ForbiddenException;

/**
Expand Down Expand Up @@ -371,7 +372,7 @@ public function getSourcePath($path) {
return $fullPath;
}

\OCP\Util::writeLog('core', "Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", \OCP\Util::ERROR);
\OCP\Util::writeLog('core', "Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", \OCP\Util::ERROR);
throw new ForbiddenException('Following symlinks is not allowed', false);
}

Expand Down Expand Up @@ -427,7 +428,13 @@ public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceIntern
* @return bool
*/
public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Local')) {
if ($sourceStorage->instanceOfStorage(Local::class)) {
if ($sourceStorage->instanceOfStorage(Jail::class)) {
/**
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage
*/
$sourceInternalPath = $sourceStorage->getUnjailedPath($sourceInternalPath);
}
/**
* @var \OC\Files\Storage\Local $sourceStorage
*/
Expand Down
Loading