From d25a9a118f7824a72f193d57373355e51323f118 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 25 Aug 2014 14:06:48 +0200 Subject: Check if a folder is deletable before we try to recursively delete it --- apps/files_external/lib/google.php | 3 +++ apps/files_external/lib/streamwrapper.php | 2 +- apps/files_external/lib/swift.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 88d82d51e2e..5d238a363de 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -204,6 +204,9 @@ class Google extends \OC\Files\Storage\Common { } public function rmdir($path) { + if (!$this->isDeletable($path)) { + return false; + } if (trim($path, '/') === '') { $dir = $this->opendir($path); if(is_resource($dir)) { diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index 44bd9a0161a..adccb2919e3 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -21,7 +21,7 @@ abstract class StreamWrapper extends Common { } public function rmdir($path) { - if ($this->file_exists($path)) { + if ($this->file_exists($path) and $this->isDeletable($path)) { $dh = $this->opendir($path); while (($file = readdir($dh)) !== false) { if ($this->is_dir($path . '/' . $file)) { diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index 1c56d180e2f..11186a9f394 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -187,7 +187,7 @@ class Swift extends \OC\Files\Storage\Common { public function rmdir($path) { $path = $this->normalizePath($path); - if (!$this->is_dir($path)) { + if (!$this->is_dir($path) or !$this->isDeletable($path)) { return false; } -- cgit v1.2.3 From 2f22e67570bd7b3e99d0f01b59c0e1808a8b5189 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 25 Aug 2014 14:28:35 +0200 Subject: Also check if the file itself is updatable --- apps/files_external/lib/streamwrapper.php | 2 +- apps/files_external/lib/swift.php | 2 +- lib/private/files/storage/common.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'apps/files_external') diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index adccb2919e3..b55bcf94af8 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -21,7 +21,7 @@ abstract class StreamWrapper extends Common { } public function rmdir($path) { - if ($this->file_exists($path) and $this->isDeletable($path)) { + if ($this->file_exists($path) && $this->isDeletable($path)) { $dh = $this->opendir($path); while (($file = readdir($dh)) !== false) { if ($this->is_dir($path . '/' . $file)) { diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index 11186a9f394..6a1e12986fb 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -187,7 +187,7 @@ class Swift extends \OC\Files\Storage\Common { public function rmdir($path) { $path = $this->normalizePath($path); - if (!$this->is_dir($path) or !$this->isDeletable($path)) { + if (!$this->is_dir($path) || !$this->isDeletable($path)) { return false; } diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 4680971b278..483a9ac6668 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -95,11 +95,11 @@ abstract class Common implements \OC\Files\Storage\Storage { } public function isDeletable($path) { - if ($path === '' or $path === '/') { + if ($path === '' || $path === '/') { return false; } $parent = dirname($path); - return $this->isUpdatable($parent); + return $this->isUpdatable($parent) and $this->isUpdatable($path); } public function isSharable($path) { -- cgit v1.2.3