Merge pull request #26966 from nextcloud/backport/26292/stable19

[stable19] ignore readonly flag for directories
This commit is contained in:
kesselb 2021-05-14 22:31:09 +02:00 committed by GitHub
commit 76dd79056c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 8 deletions

View File

@ -97,9 +97,6 @@ class SMB extends Common implements INotifyStorage {
/** @var bool */ /** @var bool */
protected $checkAcl; protected $checkAcl;
/** @var bool */
protected $rootWritable;
public function __construct($params) { public function __construct($params) {
if (!isset($params['host'])) { if (!isset($params['host'])) {
throw new \Exception('Invalid configuration, no host provided'); throw new \Exception('Invalid configuration, no host provided');
@ -137,7 +134,6 @@ class SMB extends Common implements INotifyStorage {
$this->showHidden = isset($params['show_hidden']) && $params['show_hidden']; $this->showHidden = isset($params['show_hidden']) && $params['show_hidden'];
$this->checkAcl = isset($params['check_acl']) && $params['check_acl']; $this->checkAcl = isset($params['check_acl']) && $params['check_acl'];
$this->rootWritable = isset($params['root_force_writable']) && $params['root_force_writable'];
$this->statCache = new CappedMemoryCache(); $this->statCache = new CappedMemoryCache();
parent::__construct($params); parent::__construct($params);
@ -578,9 +574,7 @@ class SMB extends Common implements INotifyStorage {
$permissions = Constants::PERMISSION_READ + Constants::PERMISSION_SHARE; $permissions = Constants::PERMISSION_READ + Constants::PERMISSION_SHARE;
if ( if (
!$fileInfo->isReadOnly() || ( !$fileInfo->isReadOnly() || $fileInfo->isDirectory()
$this->rootWritable && $fileInfo->getPath() == $this->buildPath('')
)
) { ) {
$permissions += Constants::PERMISSION_DELETE; $permissions += Constants::PERMISSION_DELETE;
$permissions += Constants::PERMISSION_UPDATE; $permissions += Constants::PERMISSION_UPDATE;
@ -683,7 +677,7 @@ class SMB extends Common implements INotifyStorage {
$info = $this->getFileInfo($path); $info = $this->getFileInfo($path);
// following windows behaviour for read-only folders: they can be written into // following windows behaviour for read-only folders: they can be written into
// (https://support.microsoft.com/en-us/kb/326549 - "cause" section) // (https://support.microsoft.com/en-us/kb/326549 - "cause" section)
return ($this->showHidden || !$info->isHidden()) && (!$info->isReadOnly() || $this->is_dir($path)); return ($this->showHidden || !$info->isHidden()) && (!$info->isReadOnly() || $info->isDirectory());
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
return false; return false;
} catch (ForbiddenException $e) { } catch (ForbiddenException $e) {