Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function register(IRegistrationContext $context): void {
};
$config = $c->get(IConfig::class);
$allowRootShare = $config->getAppValue('groupfolders', 'allow_root_share', 'true') === 'true';
$enableEncryption = $config->getAppValue('groupfolders', 'enable_encryption', 'false') === 'true';

return new MountProvider(
$c->getServer()->getGroupManager(),
Expand All @@ -87,7 +88,8 @@ public function register(IRegistrationContext $context): void {
$c->get(ISession::class),
$c->get(IMountProviderCollection::class),
$c->get(IDBConnection::class),
$allowRootShare
$allowRootShare,
$enableEncryption
);
});

Expand Down
29 changes: 29 additions & 0 deletions lib/Mount/GroupFolderNoEncryptionStorage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\GroupFolders\Mount;

use OCP\Files\Storage\IDisableEncryptionStorage;

class GroupFolderNoEncryptionStorage extends GroupFolderStorage implements IDisableEncryptionStorage {
}
2 changes: 1 addition & 1 deletion lib/Mount/GroupFolderStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use OCP\IUser;
use OCP\IUserSession;

class GroupFolderStorage extends Quota implements IDisableEncryptionStorage {
class GroupFolderStorage extends Quota {
/** @var int */
private $folderId;

Expand Down
11 changes: 0 additions & 11 deletions lib/Mount/GroupMountPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@ public function getMountType() {
return 'group';
}

public function getOption($name, $default) {
$options = $this->getOptions();
return isset($options[$name]) ? $options[$name] : $default;
}

public function getOptions() {
$options = parent::getOptions();
$options['encrypt'] = false;
return $options;
}

public function getFolderId(): int {
return $this->folderId;
}
Expand Down
32 changes: 23 additions & 9 deletions lib/Mount/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class MountProvider implements IMountProvider {
private $mountProviderCollection;
private $connection;
private $allowRootShare;
private bool $enableEncryption;

public function __construct(
IGroupManager $groupProvider,
Expand All @@ -79,7 +80,8 @@ public function __construct(
ISession $session,
IMountProviderCollection $mountProviderCollection,
IDBConnection $connection,
bool $allowRootShare
bool $allowRootShare,
bool $enableEncryption
) {
$this->groupProvider = $groupProvider;
$this->folderManager = $folderManager;
Expand All @@ -91,6 +93,7 @@ public function __construct(
$this->mountProviderCollection = $mountProviderCollection;
$this->connection = $connection;
$this->allowRootShare = $allowRootShare;
$this->enableEncryption = $enableEncryption;
}

/**
Expand Down Expand Up @@ -189,14 +192,25 @@ public function getMount(int $id, string $mountPoint, int $permissions, int $quo
'storage' => $storage,
'root' => $rootPath
]);
$quotaStorage = new GroupFolderStorage([
'storage' => $baseStorage,
'quota' => $quota,
'folder_id' => $id,
'rootCacheEntry' => $cacheEntry,
'userSession' => $this->userSession,
'mountOwner' => $user,
]);
if ($this->enableEncryption) {
$quotaStorage = new GroupFolderStorage([
'storage' => $baseStorage,
'quota' => $quota,
'folder_id' => $id,
'rootCacheEntry' => $cacheEntry,
'userSession' => $this->userSession,
'mountOwner' => $user,
]);
} else {
$quotaStorage = new GroupFolderNoEncryptionStorage([
'storage' => $baseStorage,
'quota' => $quota,
'folder_id' => $id,
'rootCacheEntry' => $cacheEntry,
'userSession' => $this->userSession,
'mountOwner' => $user,
]);
}
$maskedStore = new PermissionsMask([
'storage' => $quotaStorage,
'mask' => $permissions
Expand Down