]> source.dussan.org Git - nextcloud-server.git/commitdiff
add (hidden) option to always show smb root as writable 26145/head
authorRobin Appelman <robin@icewind.nl>
Tue, 16 Mar 2021 14:34:41 +0000 (15:34 +0100)
committerRobin Appelman <robin@icewind.nl>
Tue, 16 Mar 2021 14:35:35 +0000 (15:35 +0100)
some smb servers are very insistent in reporting that the root of the share is readonly, even if it isn't.

This works around the problem by adding a hidden option to overwrite the permissions of the root of the share.

This can be enabled using

```bash
occ files_external:config <mount id> root_force_writable true
```

where you can find your mount id using

```bash
occ files_external:list
```

Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_external/lib/Lib/Storage/SMB.php

index bc065b24552a9b3499297297ceed81f6c658728c..45a01db76b344cfeb175d865c9ae0022aca34bd5 100644 (file)
@@ -97,6 +97,9 @@ class SMB extends Common implements INotifyStorage {
        /** @var bool */
        protected $checkAcl;
 
+       /** @var bool */
+       protected $rootWritable;
+
        public function __construct($params) {
                if (!isset($params['host'])) {
                        throw new \Exception('Invalid configuration, no host provided');
@@ -134,6 +137,7 @@ class SMB extends Common implements INotifyStorage {
 
                $this->showHidden = isset($params['show_hidden']) && $params['show_hidden'];
                $this->checkAcl = isset($params['check_acl']) && $params['check_acl'];
+               $this->rootWritable = isset($params['root_force_writable']) && $params['root_force_writable'];
 
                $this->statCache = new CappedMemoryCache();
                parent::__construct($params);
@@ -573,7 +577,11 @@ class SMB extends Common implements INotifyStorage {
        private function getMetaDataFromFileInfo(IFileInfo $fileInfo) {
                $permissions = Constants::PERMISSION_READ + Constants::PERMISSION_SHARE;
 
-               if (!$fileInfo->isReadOnly()) {
+               if (
+                       !$fileInfo->isReadOnly() || (
+                               $this->rootWritable && $fileInfo->getPath() == $this->buildPath('')
+                       )
+               ) {
                        $permissions += Constants::PERMISSION_DELETE;
                        $permissions += Constants::PERMISSION_UPDATE;
                        if ($fileInfo->isDirectory()) {