From c376eb9f90dbf51c35d9997f36c275a9ba780e82 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Pablo=20Villafa=C3=B1ez?= <jvillafanez@solidgear.es>
Date: Wed, 20 Jul 2016 14:22:04 +0200
Subject: [PATCH] Fix file permissions for SMB (read-only folders will be
 writeable) (#25301)

* Fix file permissions for SMB (read-only folders will be writeable)

* Read-only folders won't be deletable

* Added comment for the read-only behaviour for folders
---
 apps/files_external/lib/Lib/Storage/SMB.php | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index e677f8c9eba..b9613adff21 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -381,6 +381,19 @@ class SMB extends \OC\Files\Storage\Common {
 	}
 
 	public function isUpdatable($path) {
+		try {
+			$info = $this->getFileInfo($path);
+			// following windows behaviour for read-only folders: they can be written into
+			// (https://support.microsoft.com/en-us/kb/326549 - "cause" section)
+			return !$info->isHidden() && (!$info->isReadOnly() || $this->is_dir($path));
+		} catch (NotFoundException $e) {
+			return false;
+		} catch (ForbiddenException $e) {
+			return false;
+		}
+	}
+
+	public function isDeletable($path) {
 		try {
 			$info = $this->getFileInfo($path);
 			return !$info->isHidden() && !$info->isReadOnly();
-- 
GitLab