summaryrefslogtreecommitdiffstats
path: root/lib/private/files/utils/scanner.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-06-25 15:22:49 +0200
committerRobin Appelman <icewind@owncloud.com>2014-06-25 15:22:49 +0200
commit9a2ed86672d5d7a162263448070ed1c562ef2515 (patch)
tree8853f416df6b80d7984263a641c7e649cc0edc9e /lib/private/files/utils/scanner.php
parentb1116880f861cf5b72d45a9edfabfdd7d48a9887 (diff)
downloadnextcloud-server-9a2ed86672d5d7a162263448070ed1c562ef2515.tar.gz
nextcloud-server-9a2ed86672d5d7a162263448070ed1c562ef2515.zip
Prevent running the files:scan command as the wrong user
Diffstat (limited to 'lib/private/files/utils/scanner.php')
-rw-r--r--lib/private/files/utils/scanner.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php
index 1bb3e694c96..c2fabf51946 100644
--- a/lib/private/files/utils/scanner.php
+++ b/lib/private/files/utils/scanner.php
@@ -11,6 +11,7 @@ namespace OC\Files\Utils;
use OC\Files\View;
use OC\Files\Cache\ChangePropagator;
use OC\Files\Filesystem;
+use OC\ForbiddenException;
use OC\Hooks\PublicEmitter;
/**
@@ -104,6 +105,7 @@ class Scanner extends PublicEmitter {
/**
* @param string $dir
+ * @throws \OC\ForbiddenException
*/
public function scan($dir) {
$mounts = $this->getMounts($dir);
@@ -111,7 +113,14 @@ class Scanner extends PublicEmitter {
if (is_null($mount->getStorage())) {
continue;
}
- $scanner = $mount->getStorage()->getScanner();
+ $storage = $mount->getStorage();
+ // if the home storage isn't writable then the scanner is run as the wrong user
+ if ($storage->instanceOfStorage('\OC\Files\Storage\Home') and
+ (!$storage->isCreatable('') or !$storage->isCreatable('files'))
+ ) {
+ throw new ForbiddenException();
+ }
+ $scanner = $storage->getScanner();
$this->attachListener($mount);
$scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
}