mirror of
https://github.com/nextcloud/server.git
synced 2024-08-29 17:54:44 +02:00
Make it possible to make external storages read only
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
f212c692ac
commit
db96b0bb0b
@ -48,6 +48,12 @@ var MOUNT_OPTIONS_DROPDOWN_TEMPLATE =
|
|||||||
' <label for="mountOptionsEncoding">{{mountOptionsEncodingLabel}}</label>'+
|
' <label for="mountOptionsEncoding">{{mountOptionsEncodingLabel}}</label>'+
|
||||||
' </span>'+
|
' </span>'+
|
||||||
' </li>'+
|
' </li>'+
|
||||||
|
' <li class="optionRow">' +
|
||||||
|
' <span class="menuitem">' +
|
||||||
|
' <input id="mountOptionsReadOnly" class="checkbox" name="readonly" type="checkbox" value="true"/>' +
|
||||||
|
' <label for="mountOptionsReadOnly">{{t "files_external" "Read only"}}</label>' +
|
||||||
|
' </span>' +
|
||||||
|
' </li>' +
|
||||||
' </ul>'+
|
' </ul>'+
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
@ -916,7 +922,8 @@ MountConfigListView.prototype = _.extend({
|
|||||||
'previews': true,
|
'previews': true,
|
||||||
'enable_sharing': false,
|
'enable_sharing': false,
|
||||||
'filesystem_check_changes': 1,
|
'filesystem_check_changes': 1,
|
||||||
'encoding_compatibility': false
|
'encoding_compatibility': false,
|
||||||
|
'readonly': false,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1303,7 +1310,8 @@ MountConfigListView.prototype = _.extend({
|
|||||||
'previews',
|
'previews',
|
||||||
'filesystem_check_changes',
|
'filesystem_check_changes',
|
||||||
'enable_sharing',
|
'enable_sharing',
|
||||||
'encoding_compatibility'
|
'encoding_compatibility',
|
||||||
|
'readonly'
|
||||||
];
|
];
|
||||||
if (this._encryptionEnabled) {
|
if (this._encryptionEnabled) {
|
||||||
visibleOptions.push('encrypt');
|
visibleOptions.push('encrypt');
|
||||||
|
@ -192,7 +192,8 @@ class ListCommand extends Base {
|
|||||||
'previews' => true,
|
'previews' => true,
|
||||||
'filesystem_check_changes' => 1,
|
'filesystem_check_changes' => 1,
|
||||||
'enable_sharing' => false,
|
'enable_sharing' => false,
|
||||||
'encoding_compatibility' => false
|
'encoding_compatibility' => false,
|
||||||
|
'readonly' => false,
|
||||||
];
|
];
|
||||||
$rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions, $full) {
|
$rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions, $full) {
|
||||||
$storageConfig = $config->getBackendOptions();
|
$storageConfig = $config->getBackendOptions();
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
$l->t("Check for changes");
|
$l->t("Check for changes");
|
||||||
$l->t("Never");
|
$l->t("Never");
|
||||||
$l->t("Once every direct access");
|
$l->t("Once every direct access");
|
||||||
|
$l->t('Read only');
|
||||||
|
|
||||||
script('files_external', 'settings');
|
script('files_external', 'settings');
|
||||||
style('files_external', 'settings');
|
style('files_external', 'settings');
|
||||||
|
@ -259,6 +259,23 @@ class OC_Util {
|
|||||||
return $storage;
|
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_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user));
|
||||||
\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(true);
|
\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user