summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-02-27 14:06:14 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-05-01 15:18:56 +0200
commitdb96b0bb0b67ceb99c49e131aef9f3d3f436a23c (patch)
tree68d1da15463c8afbc995a2281adbe8cdff5ada16 /lib
parentf212c692ac5204fbea4639727db8e464152dba5d (diff)
downloadnextcloud-server-db96b0bb0b67ceb99c49e131aef9f3d3f436a23c.tar.gz
nextcloud-server-db96b0bb0b67ceb99c49e131aef9f3d3f436a23c.zip
Make it possible to make external storages read only
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/legacy/util.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index d3599d14e7a..356d336f687 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -259,6 +259,23 @@ class OC_Util {
return $storage;
});
+ \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, \OCP\Files\Storage\IStorage $storage, \OCP\Files\Mount\IMountPoint $mount) {
+ /*
+ * Do not allow any operations that modify the storage
+ */
+ if ($mount->getOption('readonly', false)) {
+ return new \OC\Files\Storage\Wrapper\PermissionsMask([
+ 'storage' => $storage,
+ 'mask' => \OCP\Constants::PERMISSION_ALL & ~(
+ \OCP\Constants::PERMISSION_UPDATE |
+ \OCP\Constants::PERMISSION_CREATE |
+ \OCP\Constants::PERMISSION_DELETE
+ ),
+ ]);
+ }
+ return $storage;
+ });
+
OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user));
\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(true);