diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-11-07 14:25:05 +0300 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-11-14 11:12:39 +0300 |
commit | fa7f9a191e5921da76f822a6a92ef723cc0cf7f5 (patch) | |
tree | 1f46aedd6ca86acacab65f611656856db0eec3a5 /lib | |
parent | aefbe29971fc68ba1251466c97f5ea2306fcde44 (diff) |
Add repair step to fix file share permissions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Repair/RepairInvalidShares.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/private/Repair/RepairInvalidShares.php b/lib/private/Repair/RepairInvalidShares.php index 728632486d0..4f7ca2699e2 100644 --- a/lib/private/Repair/RepairInvalidShares.php +++ b/lib/private/Repair/RepairInvalidShares.php @@ -26,6 +26,7 @@ namespace OC\Repair; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use Doctrine\DBAL\Platforms\OraclePlatform; /** * Repairs shares with invalid data @@ -91,6 +92,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) { @@ -136,6 +166,9 @@ class RepairInvalidShares implements IRepairStep { // this situation was only possible before 9.1 $this->addShareLinkDeletePermission($out); } + if (version_compare($ocVersionFromBeforeUpdate, '9.1.2.6', '<')) { + $this->adjustFileSharePermissions($out); + } $this->removeSharesNonExistingParent($out); } |