summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-11-07 12:25:05 +0100
committerJoas Schilling <coding@schilljs.com>2017-01-05 14:30:22 +0100
commit7baa4ea1a48df31139fe6d36169cbc690208db62 (patch)
tree3e7e21f38910df629fc13b86fcb0fd2f0e1aa6b7 /lib/private
parentd9035e2805f2900cd1c78cc8ab22fdd1dfeb4b3e (diff)
downloadnextcloud-server-7baa4ea1a48df31139fe6d36169cbc690208db62.tar.gz
nextcloud-server-7baa4ea1a48df31139fe6d36169cbc690208db62.zip
Add repair step to fix file share permissions
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Repair/RepairInvalidShares.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/private/Repair/RepairInvalidShares.php b/lib/private/Repair/RepairInvalidShares.php
index 6cb690057bb..05267be72cf 100644
--- a/lib/private/Repair/RepairInvalidShares.php
+++ b/lib/private/Repair/RepairInvalidShares.php
@@ -27,6 +27,7 @@ namespace OC\Repair;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
+use Doctrine\DBAL\Platforms\OraclePlatform;
/**
* Repairs shares with invalid data
@@ -92,6 +93,35 @@ class RepairInvalidShares implements IRepairStep {
}
/**
+ * Adjust file share permissions
+ */
+ private function adjustFileSharePermissions(IOutput $out) {
+ $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE;
+ $builder = $this->connection->getQueryBuilder();
+
+
+ if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
+ $permsFunc = $builder->createFunction(
+ 'bitand(' . $builder->getColumnName('permissions') . ', ' . $mask . ')'
+ );
+ } else {
+ $permsFunc = $builder->createFunction(
+ '(' . $builder->getColumnName('permissions') . ' & ' . $mask . ')'
+ );
+ }
+ $builder
+ ->update('share')
+ ->set('permissions', $permsFunc)
+ ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file')))
+ ->andWhere($builder->expr()->neq('permissions', $permsFunc));
+
+ $updatedEntries = $builder->execute();
+ if ($updatedEntries > 0) {
+ $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares');
+ }
+ }
+
+ /**
* Remove shares where the parent share does not exist anymore
*/
private function removeSharesNonExistingParent(IOutput $out) {
@@ -137,6 +167,9 @@ class RepairInvalidShares implements IRepairStep {
// this situation was only possible before 9.1
$this->addShareLinkDeletePermission($out);
}
+ if (version_compare($ocVersionFromBeforeUpdate, '9.2.0.2', '<')) {
+ $this->adjustFileSharePermissions($out);
+ }
$this->removeSharesNonExistingParent($out);
}