summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/cache/file.php9
-rw-r--r--lib/private/filechunking.php4
-rw-r--r--lib/private/fileproxy.php138
-rw-r--r--lib/private/files/view.php22
-rw-r--r--lib/private/server.php12
5 files changed, 6 insertions, 179 deletions
diff --git a/lib/private/cache/file.php b/lib/private/cache/file.php
index 8874acbb1e5..c70698eb7f8 100644
--- a/lib/private/cache/file.php
+++ b/lib/private/cache/file.php
@@ -67,13 +67,10 @@ class File {
*/
public function get($key) {
$result = null;
- $proxyStatus = \OC_FileProxy::$enabled;
- \OC_FileProxy::$enabled = false;
if ($this->hasKey($key)) {
$storage = $this->getStorage();
$result = $storage->file_get_contents($key);
}
- \OC_FileProxy::$enabled = $proxyStatus;
return $result;
}
@@ -85,13 +82,10 @@ class File {
*/
public function size($key) {
$result = 0;
- $proxyStatus = \OC_FileProxy::$enabled;
- \OC_FileProxy::$enabled = false;
if ($this->hasKey($key)) {
$storage = $this->getStorage();
$result = $storage->filesize($key);
}
- \OC_FileProxy::$enabled = $proxyStatus;
return $result;
}
@@ -101,7 +95,6 @@ class File {
public function set($key, $value, $ttl = 0) {
$storage = $this->getStorage();
$result = false;
- $proxyStatus = \OC_FileProxy::$enabled;
// unique id to avoid chunk collision, just in case
$uniqueId = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(
16,
@@ -111,7 +104,6 @@ class File {
// use part file to prevent hasKey() to find the key
// while it is being written
$keyPart = $key . '.' . $uniqueId . '.part';
- \OC_FileProxy::$enabled = false;
if ($storage and $storage->file_put_contents($keyPart, $value)) {
if ($ttl === 0) {
$ttl = 86400; // 60*60*24
@@ -119,7 +111,6 @@ class File {
$result = $storage->touch($keyPart, time() + $ttl);
$result &= $storage->rename($keyPart, $key);
}
- \OC_FileProxy::$enabled = $proxyStatus;
return $result;
}
diff --git a/lib/private/filechunking.php b/lib/private/filechunking.php
index e8a58b2538d..82bf61fa7b1 100644
--- a/lib/private/filechunking.php
+++ b/lib/private/filechunking.php
@@ -189,8 +189,7 @@ class OC_FileChunking {
$absolutePath = \OC\Files\Filesystem::normalizePath(\OC\Files\Filesystem::getView()->getAbsolutePath($path));
$data = '';
// use file_put_contents as method because that best matches what this function does
- if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data)
- && \OC\Files\Filesystem::isValidPath($path)) {
+ if (\OC\Files\Filesystem::isValidPath($path)) {
$path = \OC\Files\Filesystem::getView()->getRelativePath($absolutePath);
$exists = \OC\Files\Filesystem::file_exists($path);
$run = true;
@@ -231,7 +230,6 @@ class OC_FileChunking {
\OC\Files\Filesystem::signal_post_write,
array( \OC\Files\Filesystem::signal_param_path => $path)
);
- OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
return $count > 0;
}else{
return false;
diff --git a/lib/private/fileproxy.php b/lib/private/fileproxy.php
deleted file mode 100644
index 8b28e866ac2..00000000000
--- a/lib/private/fileproxy.php
+++ /dev/null
@@ -1,138 +0,0 @@
-<?php
-/**
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Felix Moeller <mail@felixmoeller.de>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
- * @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <pvince81@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-/**
- * Class for manipulating filesystem requests
- *
- * Manipulation happens by using 2 kind of proxy operations, pre and post proxies
- * that manipulate the filesystem call and the result of the call respectively
- *
- * A pre-proxy recieves the filepath as arugments (or 2 filespaths in case of
- * operations like copy or move) and return a boolean
- * If a pre-proxy returns false the file operation will be canceled
- * All filesystem operations have a pre-proxy
- *
- * A post-proxy recieves 2 arguments, the filepath and the result of the operation.
- * The return value of the post-proxy will be used as the new result of the operation
- * The operations that have a post-proxy are:
- * file_get_contents, is_file, is_dir, file_exists, stat, is_readable,
- * is_writable, filemtime, filectime, file_get_contents,
- * getMimeType, hash, fopen, free_space and search
- */
-
-class OC_FileProxy{
- private static $proxies=array();
- public static $enabled=true;
-
- /**
- * fallback function when a proxy operation is not implemented
- * @param string $function the name of the proxy operation
- * @param mixed $arguments
- *
- * this implements a dummy proxy for all operations
- */
- public function __call($function, $arguments) {
- if(substr($function, 0, 3)=='pre') {
- return true;
- }else{
- return $arguments[1];
- }
- }
-
- /**
- * register a proxy to be used
- * @param OC_FileProxy $proxy
- */
- public static function register($proxy) {
- self::$proxies[]=$proxy;
- }
-
- /**
- * @param string $operation
- */
- public static function getProxies($operation = null) {
- if ($operation === null) {
- // return all
- return self::$proxies;
- }
- $proxies=array();
- foreach(self::$proxies as $proxy) {
- if(method_exists($proxy, $operation)) {
- $proxies[]=$proxy;
- }
- }
- return $proxies;
- }
-
- /**
- * @param string $operation
- * @param string|boolean $filepath
- */
- public static function runPreProxies($operation,&$filepath,&$filepath2=null) {
- if(!self::$enabled) {
- return true;
- }
- $operation='pre'.$operation;
- $proxies=self::getProxies($operation);
- foreach($proxies as $proxy) {
- if(!is_null($filepath2)) {
- if($proxy->$operation($filepath, $filepath2)===false) {
- return false;
- }
- }else{
- if($proxy->$operation($filepath)===false) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * @param string $operation
- * @param string|boolean $path
- *
- * @return string
- */
- public static function runPostProxies($operation, $path, $result) {
- if(!self::$enabled) {
- return $result;
- }
- $operation='post'.$operation;
- $proxies=self::getProxies($operation);
- foreach($proxies as $proxy) {
- $result=$proxy->$operation($path, $result);
- }
- return $result;
- }
-
- public static function clearProxies() {
- self::$proxies=array();
- }
-}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index f8ec4a0eb43..0f371bbc5ea 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -515,8 +515,7 @@ class View {
public function file_put_contents($path, $data) {
if (is_resource($data)) { //not having to deal with streams in file_put_contents makes life easier
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
- if (\OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data)
- and Filesystem::isValidPath($path)
+ if (Filesystem::isValidPath($path)
and !Filesystem::isFileBlacklisted($path)
) {
$path = $this->getRelativePath($absolutePath);
@@ -537,7 +536,6 @@ class View {
if ($this->shouldEmitHooks($path) && $result !== false) {
$this->emit_file_hooks_post($exists, $path);
}
- \OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
return $result;
} else {
return false;
@@ -591,8 +589,7 @@ class View {
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1));
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2));
if (
- \OC_FileProxy::runPreProxies('rename', $absolutePath1, $absolutePath2)
- and Filesystem::isValidPath($path2)
+ Filesystem::isValidPath($path2)
and Filesystem::isValidPath($path1)
and !Filesystem::isFileBlacklisted($path2)
) {
@@ -635,14 +632,12 @@ class View {
$sourceMountPoint = $mount->getMountPoint();
$result = $mount->moveMount($absolutePath2);
$manager->moveMount($sourceMountPoint, $mount->getMountPoint());
- \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2);
} else {
$result = false;
}
} elseif ($mp1 == $mp2) {
if ($storage1) {
$result = $storage1->rename($internalPath1, $internalPath2);
- \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2);
} else {
$result = false;
}
@@ -718,8 +713,7 @@ class View {
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1));
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2));
if (
- \OC_FileProxy::runPreProxies('copy', $absolutePath1, $absolutePath2)
- and Filesystem::isValidPath($path2)
+ Filesystem::isValidPath($path2)
and Filesystem::isValidPath($path1)
and !Filesystem::isFileBlacklisted($path2)
) {
@@ -927,7 +921,7 @@ class View {
public function hash($type, $path, $raw = false) {
$postFix = (substr($path, -1, 1) === '/') ? '/' : '';
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
- if (\OC_FileProxy::runPreProxies('hash', $absolutePath) && Filesystem::isValidPath($path)) {
+ if (Filesystem::isValidPath($path)) {
$path = $this->getRelativePath($absolutePath);
if ($path == null) {
return false;
@@ -942,7 +936,6 @@ class View {
list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
if ($storage) {
$result = $storage->hash($type, $internalPath, $raw);
- $result = \OC_FileProxy::runPostProxies('hash', $absolutePath, $result);
return $result;
}
}
@@ -975,8 +968,7 @@ class View {
private function basicOperation($operation, $path, $hooks = array(), $extraParam = null) {
$postFix = (substr($path, -1, 1) === '/') ? '/' : '';
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
- if (\OC_FileProxy::runPreProxies($operation, $absolutePath, $extraParam)
- and Filesystem::isValidPath($path)
+ if (Filesystem::isValidPath($path)
and !Filesystem::isFileBlacklisted($path)
) {
$path = $this->getRelativePath($absolutePath);
@@ -993,8 +985,6 @@ class View {
$result = $storage->$operation($internalPath);
}
- $result = \OC_FileProxy::runPostProxies($operation, $this->getAbsolutePath($path), $result);
-
if (in_array('delete', $hooks) and $result) {
$this->updater->remove($path);
}
@@ -1168,8 +1158,6 @@ class View {
$data['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
}
- $data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data);
-
return new FileInfo($path, $storage, $internalPath, $data, $mount);
}
diff --git a/lib/private/server.php b/lib/private/server.php
index d9c580c0f0c..d135150c1f7 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -496,19 +496,7 @@ class Server extends SimpleContainer implements IServerContainer {
$dir = '/files';
if (!$folder->nodeExists($dir)) {
$folder = $folder->newFolder($dir);
-
- if (\OCP\App::isEnabled('files_encryption')) {
- // disable encryption proxy to prevent recursive calls
- $proxyStatus = \OC_FileProxy::$enabled;
- \OC_FileProxy::$enabled = false;
- }
-
\OC_Util::copySkeleton($user, $folder);
-
- if (\OCP\App::isEnabled('files_encryption')) {
- // re-enable proxy - our work is done
- \OC_FileProxy::$enabled = $proxyStatus;
- }
} else {
$folder = $folder->get($dir);
}