summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-01-08 05:32:36 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2014-01-08 05:32:36 -0800
commit0bc0a60a93d05f02ebac76850bf020fd5ef1bdd9 (patch)
tree3606c38d2a8404307a03cb494e89e55c8206c293 /lib
parentbb443ae937bdbc9f50c352d34abeaa0eaa3fa890 (diff)
parentf642ad39614970de67358d80517bc1d76a006e0e (diff)
downloadnextcloud-server-0bc0a60a93d05f02ebac76850bf020fd5ef1bdd9.tar.gz
nextcloud-server-0bc0a60a93d05f02ebac76850bf020fd5ef1bdd9.zip
Merge pull request #6680 from owncloud/core-preventunlinkstorageroot
Prevent deleting storage root
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/view.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index ac45a881331..8893911ed5d 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -336,6 +336,19 @@ class View {
}
public function unlink($path) {
+ if ($path === '' || $path === '/') {
+ // do not allow deleting the root
+ return false;
+ }
+ $postFix = (substr($path, -1, 1) === '/') ? '/' : '';
+ $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
+ list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
+ if (!$internalPath || $internalPath === '' || $internalPath === '/') {
+ // do not allow deleting the storage's root / the mount point
+ // because for some storages it might delete the whole contents
+ // but isn't supposed to work that way
+ return false;
+ }
return $this->basicOperation('unlink', $path, array('delete'));
}