aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/icewind/smb/src
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/3rdparty/icewind/smb/src')
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/ACL.php81
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/AbstractServer.php84
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/AbstractShare.php30
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/AnonymousAuth.php44
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/BasicAuth.php64
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Change.php40
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/AccessDeniedException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/AlreadyExistsException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/AuthenticationException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionAbortedException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionRefusedException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionResetException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/DependencyException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/Exception.php38
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/FileInUseException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/ForbiddenException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/HostDownException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidArgumentException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidHostException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidParameterException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidPathException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidRequestException.php34
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidResourceException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidTypeException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/NoLoginServerException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/NoRouteToHostException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/NotEmptyException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/NotFoundException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/OutOfSpaceException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/RevisionMismatchException.php16
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Exception/TimedOutException.php11
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/IAuth.php53
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/IFileInfo.php73
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/INotifyHandler.php45
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/IOptions.php29
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/IServer.php69
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/IShare.php160
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/ISystem.php78
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/ITimeZoneProvider.php32
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/KerberosAuth.php48
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php196
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeReadStream.php100
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeServer.php66
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php360
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php317
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php131
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeWriteStream.php104
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Options.php35
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/ServerFactory.php85
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/System.php69
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php54
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/Connection.php126
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/ErrorCodes.php31
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/FileInfo.php130
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/NotifyHandler.php109
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php191
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php189
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/Server.php91
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php562
61 files changed, 0 insertions, 4228 deletions
diff --git a/apps/files_external/3rdparty/icewind/smb/src/ACL.php b/apps/files_external/3rdparty/icewind/smb/src/ACL.php
deleted file mode 100644
index bdb77257f17..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/ACL.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php declare(strict_types=1);
-/**
- * @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-class ACL {
- const TYPE_ALLOW = 0;
- const TYPE_DENY = 1;
-
- const MASK_READ = 0x0001;
- const MASK_WRITE = 0x0002;
- const MASK_EXECUTE = 0x00020;
- const MASK_DELETE = 0x10000;
-
- const FLAG_OBJECT_INHERIT = 0x1;
- const FLAG_CONTAINER_INHERIT = 0x2;
-
- private $type;
- private $flags;
- private $mask;
-
- public function __construct(int $type, int $flags, int $mask) {
- $this->type = $type;
- $this->flags = $flags;
- $this->mask = $mask;
- }
-
- /**
- * Check if the acl allows a specific permissions
- *
- * Note that this does not take inherited acls into account
- *
- * @param int $mask one of the ACL::MASK_* constants
- * @return bool
- */
- public function allows(int $mask): bool {
- return $this->type === self::TYPE_ALLOW && ($this->mask & $mask) === $mask;
- }
-
- /**
- * Check if the acl allows a specific permissions
- *
- * Note that this does not take inherited acls into account
- *
- * @param int $mask one of the ACL::MASK_* constants
- * @return bool
- */
- public function denies(int $mask): bool {
- return $this->type === self::TYPE_DENY && ($this->mask & $mask) === $mask;
- }
-
- public function getType(): int {
- return $this->type;
- }
-
- public function getFlags(): int {
- return $this->flags;
- }
-
- public function getMask(): int {
- return $this->mask;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/AbstractServer.php b/apps/files_external/3rdparty/icewind/smb/src/AbstractServer.php
deleted file mode 100644
index aa2adfa67b3..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/AbstractServer.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-abstract class AbstractServer implements IServer {
- const LOCALE = 'en_US.UTF-8';
-
- /**
- * @var string $host
- */
- protected $host;
-
- /**
- * @var IAuth $user
- */
- protected $auth;
-
- /**
- * @var ISystem
- */
- protected $system;
-
- /**
- * @var TimeZoneProvider
- */
- protected $timezoneProvider;
-
- /** @var IOptions */
- protected $options;
-
- /**
- * @param string $host
- * @param IAuth $auth
- * @param ISystem $system
- * @param TimeZoneProvider $timeZoneProvider
- * @param IOptions $options
- */
- public function __construct($host, IAuth $auth, ISystem $system, TimeZoneProvider $timeZoneProvider, IOptions $options) {
- $this->host = $host;
- $this->auth = $auth;
- $this->system = $system;
- $this->timezoneProvider = $timeZoneProvider;
- $this->options = $options;
- }
-
- public function getAuth() {
- return $this->auth;
- }
-
- public function getHost() {
- return $this->host;
- }
-
- public function getTimeZone() {
- return $this->timezoneProvider->get($this->host);
- }
-
- public function getSystem() {
- return $this->system;
- }
-
- public function getOptions() {
- return $this->options;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/AbstractShare.php b/apps/files_external/3rdparty/icewind/smb/src/AbstractShare.php
deleted file mode 100644
index b53c253be08..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/AbstractShare.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB;
-
-use Icewind\SMB\Exception\InvalidPathException;
-
-abstract class AbstractShare implements IShare {
- private $forbiddenCharacters;
-
- public function __construct() {
- $this->forbiddenCharacters = ['?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r"];
- }
-
- protected function verifyPath($path) {
- foreach ($this->forbiddenCharacters as $char) {
- if (strpos($path, $char) !== false) {
- throw new InvalidPathException('Invalid path, "' . $char . '" is not allowed');
- }
- }
- }
-
- public function setForbiddenChars(array $charList) {
- $this->forbiddenCharacters = $charList;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/AnonymousAuth.php b/apps/files_external/3rdparty/icewind/smb/src/AnonymousAuth.php
deleted file mode 100644
index 737cc7c63f1..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/AnonymousAuth.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-class AnonymousAuth implements IAuth {
- public function getUsername() {
- return null;
- }
-
- public function getWorkgroup() {
- return 'dummy';
- }
-
- public function getPassword() {
- return null;
- }
-
- public function getExtraCommandLineArguments() {
- return '-N';
- }
-
- public function setExtraSmbClientOptions($smbClientState) {
- smbclient_option_set($smbClientState, SMBCLIENT_OPT_AUTO_ANONYMOUS_LOGIN, true);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/BasicAuth.php b/apps/files_external/3rdparty/icewind/smb/src/BasicAuth.php
deleted file mode 100644
index 9d7f9b5d306..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/BasicAuth.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-class BasicAuth implements IAuth {
- /** @var string */
- private $username;
- /** @var string */
- private $workgroup;
- /** @var string */
- private $password;
-
- /**
- * BasicAuth constructor.
- *
- * @param string $username
- * @param string $workgroup
- * @param string $password
- */
- public function __construct($username, $workgroup, $password) {
- $this->username = $username;
- $this->workgroup = $workgroup;
- $this->password = $password;
- }
-
- public function getUsername() {
- return $this->username;
- }
-
- public function getWorkgroup() {
- return $this->workgroup;
- }
-
- public function getPassword() {
- return $this->password;
- }
-
- public function getExtraCommandLineArguments() {
- return ($this->workgroup) ? '-W ' . escapeshellarg($this->workgroup) : '';
- }
-
- public function setExtraSmbClientOptions($smbClientState) {
- // noop
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Change.php b/apps/files_external/3rdparty/icewind/smb/src/Change.php
deleted file mode 100644
index 9dfd57b3973..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Change.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- *
- */
-
-namespace Icewind\SMB;
-
-class Change {
- private $code;
-
- private $path;
-
- /**
- * Change constructor.
- *
- * @param $code
- * @param $path
- */
- public function __construct($code, $path) {
- $this->code = $code;
- $this->path = $path;
- }
-
- /**
- * @return integer
- */
- public function getCode() {
- return $this->code;
- }
-
- /**
- * @return string
- */
- public function getPath() {
- return $this->path;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/AccessDeniedException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/AccessDeniedException.php
deleted file mode 100644
index adc42344b43..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/AccessDeniedException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class AccessDeniedException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/AlreadyExistsException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/AlreadyExistsException.php
deleted file mode 100644
index aaa5226f795..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/AlreadyExistsException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class AlreadyExistsException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/AuthenticationException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/AuthenticationException.php
deleted file mode 100644
index 9626d795e34..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/AuthenticationException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class AuthenticationException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectException.php
deleted file mode 100644
index 9aa174ba5bd..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class ConnectException extends Exception {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionAbortedException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionAbortedException.php
deleted file mode 100644
index 59363ca7ba9..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionAbortedException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2020 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class ConnectionAbortedException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionException.php
deleted file mode 100644
index d27752e702b..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class ConnectionException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionRefusedException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionRefusedException.php
deleted file mode 100644
index ffebb4c8a51..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionRefusedException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class ConnectionRefusedException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionResetException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionResetException.php
deleted file mode 100644
index d5ac10d32dc..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/ConnectionResetException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2020 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class ConnectionResetException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/DependencyException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/DependencyException.php
deleted file mode 100644
index 39735578798..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/DependencyException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2016 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class DependencyException extends Exception {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/Exception.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/Exception.php
deleted file mode 100644
index 4954518f980..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/Exception.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class Exception extends \Exception {
- public static function unknown($path, $error) {
- $message = 'Unknown error (' . $error . ')';
- if ($path) {
- $message .= ' for ' . $path;
- }
-
- return new Exception($message, is_string($error) ? 0 : $error);
- }
-
- /**
- * @param array $exceptionMap
- * @param mixed $error
- * @param string $path
- * @return Exception
- */
- public static function fromMap(array $exceptionMap, $error, $path) {
- if (isset($exceptionMap[$error])) {
- $exceptionClass = $exceptionMap[$error];
- if (is_numeric($error)) {
- return new $exceptionClass($path, $error);
- } else {
- return new $exceptionClass($path);
- }
- } else {
- return Exception::unknown($path, $error);
- }
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/FileInUseException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/FileInUseException.php
deleted file mode 100644
index 4408d39e06e..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/FileInUseException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class FileInUseException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/ForbiddenException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/ForbiddenException.php
deleted file mode 100644
index 31c051893e8..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/ForbiddenException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class ForbiddenException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/HostDownException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/HostDownException.php
deleted file mode 100644
index 9ae762b6108..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/HostDownException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class HostDownException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidArgumentException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidArgumentException.php
deleted file mode 100644
index a21d069d47f..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidArgumentException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class InvalidArgumentException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidHostException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidHostException.php
deleted file mode 100644
index 2358b7f338f..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidHostException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class InvalidHostException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidParameterException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidParameterException.php
deleted file mode 100644
index 5ffbf4f3819..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidParameterException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class InvalidParameterException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidPathException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidPathException.php
deleted file mode 100644
index 2b7859de155..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidPathException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class InvalidPathException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidRequestException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidRequestException.php
deleted file mode 100644
index 882bf1677bf..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidRequestException.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class InvalidRequestException extends Exception {
- /**
- * @var string
- */
- protected $path;
-
- /**
- * @param string $path
- * @param int $code
- */
- public function __construct($path, $code = 0) {
- $class = get_class($this);
- $parts = explode('\\', $class);
- $baseName = array_pop($parts);
- parent::__construct('Invalid request for ' . $path . ' (' . $baseName . ')', $code);
- $this->path = $path;
- }
-
- /**
- * @return string
- */
- public function getPath() {
- return $this->path;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidResourceException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidResourceException.php
deleted file mode 100644
index b5fdb851cab..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidResourceException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class InvalidResourceException extends Exception {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidTypeException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidTypeException.php
deleted file mode 100644
index 00da288b8a1..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidTypeException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class InvalidTypeException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/NoLoginServerException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/NoLoginServerException.php
deleted file mode 100644
index 8f0c5539282..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/NoLoginServerException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class NoLoginServerException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/NoRouteToHostException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/NoRouteToHostException.php
deleted file mode 100644
index 03daf36d610..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/NoRouteToHostException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class NoRouteToHostException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/NotEmptyException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/NotEmptyException.php
deleted file mode 100644
index 0e606d65ca3..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/NotEmptyException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class NotEmptyException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/NotFoundException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/NotFoundException.php
deleted file mode 100644
index 29ea2d87c99..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/NotFoundException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class NotFoundException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/OutOfSpaceException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/OutOfSpaceException.php
deleted file mode 100644
index 4c5517a1404..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/OutOfSpaceException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class OutOfSpaceException extends InvalidRequestException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/RevisionMismatchException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/RevisionMismatchException.php
deleted file mode 100644
index e898b5a2347..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/RevisionMismatchException.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-use Throwable;
-
-class RevisionMismatchException extends Exception {
- public function __construct($message = 'Protocol version mismatch', $code = 0, Throwable $previous = null) {
- parent::__construct($message, $code, $previous);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/TimedOutException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/TimedOutException.php
deleted file mode 100644
index dd57c9b8ccc..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Exception/TimedOutException.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Exception;
-
-class TimedOutException extends ConnectException {
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/IAuth.php b/apps/files_external/3rdparty/icewind/smb/src/IAuth.php
deleted file mode 100644
index 731b315ebaa..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/IAuth.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-interface IAuth {
- /**
- * @return string|null
- */
- public function getUsername();
-
- /**
- * @return string|null
- */
- public function getWorkgroup();
-
- /**
- * @return string|null
- */
- public function getPassword();
-
- /**
- * Any extra command line option for smbclient that are required
- *
- * @return string
- */
- public function getExtraCommandLineArguments();
-
- /**
- * Set any extra options for libsmbclient that are required
- *
- * @param resource $smbClientState
- */
- public function setExtraSmbClientOptions($smbClientState);
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/IFileInfo.php b/apps/files_external/3rdparty/icewind/smb/src/IFileInfo.php
deleted file mode 100644
index 3411d498d78..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/IFileInfo.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB;
-
-interface IFileInfo {
- /*
- * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
- * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
- * "system.*") is specified.
- */
- const MODE_READONLY = 0x01;
- const MODE_HIDDEN = 0x02;
- const MODE_SYSTEM = 0x04;
- const MODE_VOLUME_ID = 0x08;
- const MODE_DIRECTORY = 0x10;
- const MODE_ARCHIVE = 0x20;
- const MODE_NORMAL = 0x80;
-
- /**
- * @return string
- */
- public function getPath();
-
- /**
- * @return string
- */
- public function getName();
-
- /**
- * @return int
- */
- public function getSize();
-
- /**
- * @return int
- */
- public function getMTime();
-
- /**
- * @return bool
- */
- public function isDirectory();
-
- /**
- * @return bool
- */
- public function isReadOnly();
-
- /**
- * @return bool
- */
- public function isHidden();
-
- /**
- * @return bool
- */
- public function isSystem();
-
- /**
- * @return bool
- */
- public function isArchived();
-
- /**
- * @return ACL[]
- */
- public function getAcls(): array;
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/INotifyHandler.php b/apps/files_external/3rdparty/icewind/smb/src/INotifyHandler.php
deleted file mode 100644
index c3ee3ffe8cf..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/INotifyHandler.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- *
- */
-
-namespace Icewind\SMB;
-
-interface INotifyHandler {
- // https://msdn.microsoft.com/en-us/library/dn392331.aspx
- const NOTIFY_ADDED = 1;
- const NOTIFY_REMOVED = 2;
- const NOTIFY_MODIFIED = 3;
- const NOTIFY_RENAMED_OLD = 4;
- const NOTIFY_RENAMED_NEW = 5;
- const NOTIFY_ADDED_STREAM = 6;
- const NOTIFY_REMOVED_STREAM = 7;
- const NOTIFY_MODIFIED_STREAM = 8;
- const NOTIFY_REMOVED_BY_DELETE = 9;
-
- /**
- * Get all changes detected since the start of the notify process or the last call to getChanges
- *
- * @return Change[]
- */
- public function getChanges();
-
- /**
- * Listen actively to all incoming changes
- *
- * Note that this is a blocking process and will cause the process to block forever if not explicitly terminated
- *
- * @param callable $callback
- */
- public function listen($callback);
-
- /**
- * Stop listening for changes
- *
- * Note that any pending changes will be discarded
- */
- public function stop();
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/IOptions.php b/apps/files_external/3rdparty/icewind/smb/src/IOptions.php
deleted file mode 100644
index c46d2c8b3dc..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/IOptions.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-interface IOptions {
- /**
- * @return int
- */
- public function getTimeout();
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/IServer.php b/apps/files_external/3rdparty/icewind/smb/src/IServer.php
deleted file mode 100644
index 0b832025aab..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/IServer.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-interface IServer {
- /**
- * @return IAuth
- */
- public function getAuth();
-
- /**
- * @return string
- */
- public function getHost();
-
- /**
- * @return \Icewind\SMB\IShare[]
- *
- * @throws \Icewind\SMB\Exception\AuthenticationException
- * @throws \Icewind\SMB\Exception\InvalidHostException
- */
- public function listShares();
-
- /**
- * @param string $name
- * @return \Icewind\SMB\IShare
- */
- public function getShare($name);
-
- /**
- * @return string
- */
- public function getTimeZone();
-
- /**
- * @return ISystem
- */
- public function getSystem();
-
- /**
- * @return IOptions
- */
- public function getOptions();
-
- /**
- * @param ISystem $system
- * @return bool
- */
- public static function available(ISystem $system);
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/IShare.php b/apps/files_external/3rdparty/icewind/smb/src/IShare.php
deleted file mode 100644
index d33d10bb3fb..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/IShare.php
+++ /dev/null
@@ -1,160 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB;
-
-interface IShare {
- /**
- * Get the name of the share
- *
- * @return string
- */
- public function getName();
-
- /**
- * Download a remote file
- *
- * @param string $source remove file
- * @param string $target local file
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function get($source, $target);
-
- /**
- * Upload a local file
- *
- * @param string $source local file
- * @param string $target remove file
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function put($source, $target);
-
- /**
- * Open a readable stream top a remote file
- *
- * @param string $source
- * @return resource a read only stream with the contents of the remote file
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function read($source);
-
- /**
- * Open a writable stream to a remote file
- * Note: This method will truncate the file to 0bytes
- *
- * @param string $target
- * @return resource a write only stream to upload a remote file
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function write($target);
-
- /**
- * Open a writable stream to a remote file and set the cursor to the end of the file
- *
- * @param string $target
- * @return resource a write only stream to upload a remote file
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- * @throws \Icewind\SMB\Exception\InvalidRequestException
- */
- public function append($target);
-
- /**
- * Rename a remote file
- *
- * @param string $from
- * @param string $to
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\AlreadyExistsException
- */
- public function rename($from, $to);
-
- /**
- * Delete a file on the share
- *
- * @param string $path
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function del($path);
-
- /**
- * List the content of a remote folder
- *
- * @param $path
- * @return \Icewind\SMB\IFileInfo[]
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function dir($path);
-
- /**
- * @param string $path
- * @return \Icewind\SMB\IFileInfo
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- */
- public function stat($path);
-
- /**
- * Create a folder on the share
- *
- * @param string $path
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\AlreadyExistsException
- */
- public function mkdir($path);
-
- /**
- * Remove a folder on the share
- *
- * @param string $path
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function rmdir($path);
-
- /**
- * @param string $path
- * @param int $mode a combination of FileInfo::MODE_READONLY, FileInfo::MODE_ARCHIVE, FileInfo::MODE_SYSTEM and FileInfo::MODE_HIDDEN, FileInfo::NORMAL
- * @return mixed
- */
- public function setMode($path, $mode);
-
- /**
- * @param string $path
- * @return INotifyHandler
- */
- public function notify($path);
-
- /**
- * Get the IServer instance for this share
- *
- * @return IServer
- */
- public function getServer(): IServer;
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/ISystem.php b/apps/files_external/3rdparty/icewind/smb/src/ISystem.php
deleted file mode 100644
index 09994610716..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/ISystem.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-/**
- * The `ISystem` interface provides a way to access system dependent information
- * such as the availability and location of certain binaries.
- */
-interface ISystem {
- /**
- * Get the path to a file descriptor of the current process
- *
- * @param int $num the file descriptor id
- * @return string
- */
- public function getFD($num);
-
- /**
- * Get the full path to the `smbclient` binary of false if the binary is not available
- *
- * @return string|bool
- */
- public function getSmbclientPath();
-
- /**
- * Get the full path to the `net` binary of false if the binary is not available
- *
- * @return string|bool
- */
- public function getNetPath();
-
- /**
- * Get the full path to the `smbcacls` binary of false if the binary is not available
- *
- * @return string|bool
- */
- public function getSmbcAclsPath();
-
- /**
- * Get the full path to the `stdbuf` binary of false if the binary is not available
- *
- * @return string|bool
- */
- public function getStdBufPath();
-
- /**
- * Get the full path to the `date` binary of false if the binary is not available
- *
- * @return string|bool
- */
- public function getDatePath();
-
- /**
- * Whether or not the smbclient php extension is enabled
- *
- * @return bool
- */
- public function libSmbclientAvailable();
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/ITimeZoneProvider.php b/apps/files_external/3rdparty/icewind/smb/src/ITimeZoneProvider.php
deleted file mode 100644
index 56e09ffb392..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/ITimeZoneProvider.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-interface ITimeZoneProvider {
- /**
- * Get the timezone of the smb server
- *
- * @param string $host
- * @return string
- */
- public function get($host);
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/KerberosAuth.php b/apps/files_external/3rdparty/icewind/smb/src/KerberosAuth.php
deleted file mode 100644
index 0e91202cb76..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/KerberosAuth.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-/**
- * Use existing kerberos ticket to authenticate
- */
-class KerberosAuth implements IAuth {
- public function getUsername() {
- return 'dummy';
- }
-
- public function getWorkgroup() {
- return 'dummy';
- }
-
- public function getPassword() {
- return null;
- }
-
- public function getExtraCommandLineArguments() {
- return '-k';
- }
-
- public function setExtraSmbClientOptions($smbClientState) {
- smbclient_option_set($smbClientState, SMBCLIENT_OPT_USE_KERBEROS, true);
- smbclient_option_set($smbClientState, SMBCLIENT_OPT_FALLBACK_AFTER_KERBEROS, false);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php
deleted file mode 100644
index d8be57c7311..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php
+++ /dev/null
@@ -1,196 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Native;
-
-use Icewind\SMB\ACL;
-use Icewind\SMB\IFileInfo;
-
-class NativeFileInfo implements IFileInfo {
- /**
- * @var string
- */
- protected $path;
-
- /**
- * @var string
- */
- protected $name;
-
- /**
- * @var NativeShare
- */
- protected $share;
-
- /**
- * @var array|null
- */
- protected $attributeCache = null;
-
- /**
- * @param NativeShare $share
- * @param string $path
- * @param string $name
- */
- public function __construct($share, $path, $name) {
- $this->share = $share;
- $this->path = $path;
- $this->name = $name;
- }
-
- /**
- * @return string
- */
- public function getPath() {
- return $this->path;
- }
-
- /**
- * @return string
- */
- public function getName() {
- return $this->name;
- }
-
- /**
- * @return array
- */
- protected function stat() {
- if (is_null($this->attributeCache)) {
- $rawAttributes = explode(',', $this->share->getAttribute($this->path, 'system.dos_attr.*'));
- $this->attributeCache = [];
- foreach ($rawAttributes as $rawAttribute) {
- list($name, $value) = explode(':', $rawAttribute);
- $name = strtolower($name);
- if ($name == 'mode') {
- $this->attributeCache[$name] = (int)hexdec(substr($value, 2));
- } else {
- $this->attributeCache[$name] = (int)$value;
- }
- }
- }
- return $this->attributeCache;
- }
-
- /**
- * @return int
- */
- public function getSize() {
- $stat = $this->stat();
- return $stat['size'];
- }
-
- /**
- * @return int
- */
- public function getMTime() {
- $stat = $this->stat();
- return $stat['change_time'];
- }
-
- /**
- * On "mode":
- *
- * different smbclient versions seem to return different mode values for 'system.dos_attr.mode'
- *
- * older versions return the dos permissions mask as defined in `IFileInfo::MODE_*` while
- * newer versions return the equivalent unix permission mask.
- *
- * Since the unix mask doesn't contain the proper hidden/archive/system flags we have to assume them
- * as false (except for `hidden` where we use the unix dotfile convention)
- */
-
- /**
- * @return int
- */
- protected function getMode() {
- $mode = $this->stat()['mode'];
-
- // Let us ignore the ATTR_NOT_CONTENT_INDEXED for now
- $mode &= ~0x00002000;
-
- return $mode;
- }
-
- /**
- * @return bool
- */
- public function isDirectory() {
- $mode = $this->getMode();
- if ($mode > 0x1000) {
- return (bool)($mode & 0x4000); // 0x4000: unix directory flag
- } else {
- return (bool)($mode & IFileInfo::MODE_DIRECTORY);
- }
- }
-
- /**
- * @return bool
- */
- public function isReadOnly() {
- $mode = $this->getMode();
- if ($mode > 0x1000) {
- return !(bool)($mode & 0x80); // 0x80: owner write permissions
- } else {
- return (bool)($mode & IFileInfo::MODE_READONLY);
- }
- }
-
- /**
- * @return bool
- */
- public function isHidden() {
- $mode = $this->getMode();
- if ($mode > 0x1000) {
- return strlen($this->name) > 0 && $this->name[0] === '.';
- } else {
- return (bool)($mode & IFileInfo::MODE_HIDDEN);
- }
- }
-
- /**
- * @return bool
- */
- public function isSystem() {
- $mode = $this->getMode();
- if ($mode > 0x1000) {
- return false;
- } else {
- return (bool)($mode & IFileInfo::MODE_SYSTEM);
- }
- }
-
- /**
- * @return bool
- */
- public function isArchived() {
- $mode = $this->getMode();
- if ($mode > 0x1000) {
- return false;
- } else {
- return (bool)($mode & IFileInfo::MODE_ARCHIVE);
- }
- }
-
- /**
- * @return ACL[]
- */
- public function getAcls(): array {
- $acls = [];
- $attribute = $this->share->getAttribute($this->path, 'system.nt_sec_desc.acl.*+');
-
- foreach (explode(',', $attribute) as $acl) {
- list($user, $permissions) = explode(':', $acl, 2);
- list($type, $flags, $mask) = explode('/', $permissions);
- $mask = hexdec($mask);
-
- $acls[$user] = new ACL($type, $flags, $mask);
- }
-
- return $acls;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeReadStream.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeReadStream.php
deleted file mode 100644
index fe0af760d3f..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeReadStream.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Native;
-
-/**
- * Stream optimized for read only usage
- */
-class NativeReadStream extends NativeStream {
- const CHUNK_SIZE = 1048576; // 1MB chunks
- /**
- * @var resource
- */
- private $readBuffer = null;
-
- private $bufferSize = 0;
-
- private $pos = 0;
-
- public function stream_open($path, $mode, $options, &$opened_path) {
- $this->readBuffer = fopen('php://memory', 'r+');
-
- return parent::stream_open($path, $mode, $options, $opened_path);
- }
-
- /**
- * Wrap a stream from libsmbclient-php into a regular php stream
- *
- * @param \Icewind\SMB\NativeState $state
- * @param resource $smbStream
- * @param string $mode
- * @param string $url
- * @return resource
- */
- public static function wrap($state, $smbStream, $mode, $url) {
- stream_wrapper_register('nativesmb', NativeReadStream::class);
- $context = stream_context_create([
- 'nativesmb' => [
- 'state' => $state,
- 'handle' => $smbStream,
- 'url' => $url
- ]
- ]);
- $fh = fopen('nativesmb://', $mode, false, $context);
- stream_wrapper_unregister('nativesmb');
- return $fh;
- }
-
- public function stream_read($count) {
- // php reads 8192 bytes at once
- // however due to network latency etc, it's faster to read in larger chunks
- // and buffer the result
- if (!parent::stream_eof() && $this->bufferSize < $count) {
- $remaining = $this->readBuffer;
- $this->readBuffer = fopen('php://memory', 'r+');
- $this->bufferSize = 0;
- stream_copy_to_stream($remaining, $this->readBuffer);
- $this->bufferSize += fwrite($this->readBuffer, parent::stream_read(self::CHUNK_SIZE));
- fseek($this->readBuffer, 0);
- }
-
- $result = fread($this->readBuffer, $count);
- $this->bufferSize -= $count;
-
- $read = strlen($result);
- $this->pos += $read;
-
- return $result;
- }
-
- public function stream_seek($offset, $whence = SEEK_SET) {
- $result = parent::stream_seek($offset, $whence);
- if ($result) {
- $this->readBuffer = fopen('php://memory', 'r+');
- $this->bufferSize = 0;
- $this->pos = parent::stream_tell();
- }
- return $result;
- }
-
- public function stream_eof() {
- return $this->bufferSize <= 0 && parent::stream_eof();
- }
-
- public function stream_tell() {
- return $this->pos;
- }
-
- public function stream_write($data) {
- return false;
- }
-
- public function stream_truncate($size) {
- return false;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeServer.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeServer.php
deleted file mode 100644
index aadb05d0fea..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeServer.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Native;
-
-use Icewind\SMB\AbstractServer;
-use Icewind\SMB\IAuth;
-use Icewind\SMB\IOptions;
-use Icewind\SMB\ISystem;
-use Icewind\SMB\TimeZoneProvider;
-
-class NativeServer extends AbstractServer {
- /**
- * @var NativeState
- */
- protected $state;
-
- public function __construct($host, IAuth $auth, ISystem $system, TimeZoneProvider $timeZoneProvider, IOptions $options) {
- parent::__construct($host, $auth, $system, $timeZoneProvider, $options);
- $this->state = new NativeState();
- }
-
- protected function connect() {
- $this->state->init($this->getAuth(), $this->getOptions());
- }
-
- /**
- * @return \Icewind\SMB\IShare[]
- * @throws \Icewind\SMB\Exception\AuthenticationException
- * @throws \Icewind\SMB\Exception\InvalidHostException
- */
- public function listShares() {
- $this->connect();
- $shares = [];
- $dh = $this->state->opendir('smb://' . $this->getHost());
- while ($share = $this->state->readdir($dh)) {
- if ($share['type'] === 'file share') {
- $shares[] = $this->getShare($share['name']);
- }
- }
- $this->state->closedir($dh);
- return $shares;
- }
-
- /**
- * @param string $name
- * @return \Icewind\SMB\IShare
- */
- public function getShare($name) {
- return new NativeShare($this, $name);
- }
-
- /**
- * Check if the smbclient php extension is available
- *
- * @param ISystem $system
- * @return bool
- */
- public static function available(ISystem $system) {
- return $system->libSmbclientAvailable();
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php
deleted file mode 100644
index 5368538edca..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeShare.php
+++ /dev/null
@@ -1,360 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Native;
-
-use Icewind\SMB\AbstractShare;
-use Icewind\SMB\Exception\DependencyException;
-use Icewind\SMB\Exception\InvalidPathException;
-use Icewind\SMB\Exception\InvalidResourceException;
-use Icewind\SMB\INotifyHandler;
-use Icewind\SMB\IServer;
-use Icewind\SMB\Wrapped\Server;
-use Icewind\SMB\Wrapped\Share;
-
-class NativeShare extends AbstractShare {
- /**
- * @var IServer $server
- */
- private $server;
-
- /**
- * @var string $name
- */
- private $name;
-
- /**
- * @var NativeState $state
- */
- private $state;
-
- /**
- * @param IServer $server
- * @param string $name
- */
- public function __construct($server, $name) {
- parent::__construct();
- $this->server = $server;
- $this->name = $name;
- }
-
- /**
- * @throws \Icewind\SMB\Exception\ConnectionException
- * @throws \Icewind\SMB\Exception\AuthenticationException
- * @throws \Icewind\SMB\Exception\InvalidHostException
- */
- protected function getState() {
- if ($this->state and $this->state instanceof NativeState) {
- return $this->state;
- }
-
- $this->state = new NativeState();
- $this->state->init($this->server->getAuth(), $this->server->getOptions());
- return $this->state;
- }
-
- /**
- * Get the name of the share
- *
- * @return string
- */
- public function getName() {
- return $this->name;
- }
-
- private function buildUrl($path) {
- $this->verifyPath($path);
- $url = sprintf('smb://%s/%s', $this->server->getHost(), $this->name);
- if ($path) {
- $path = trim($path, '/');
- $url .= '/';
- $url .= implode('/', array_map('rawurlencode', explode('/', $path)));
- }
- return $url;
- }
-
- /**
- * List the content of a remote folder
- *
- * @param string $path
- * @return \Icewind\SMB\IFileInfo[]
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function dir($path) {
- $files = [];
-
- $dh = $this->getState()->opendir($this->buildUrl($path));
- while ($file = $this->getState()->readdir($dh)) {
- $name = $file['name'];
- if ($name !== '.' and $name !== '..') {
- $fullPath = $path . '/' . $name;
- $files [] = new NativeFileInfo($this, $fullPath, $name);
- }
- }
-
- $this->getState()->closedir($dh);
- return $files;
- }
-
- /**
- * @param string $path
- * @return \Icewind\SMB\IFileInfo
- */
- public function stat($path) {
- $info = new NativeFileInfo($this, $path, self::mb_basename($path));
-
- // trigger attribute loading
- $info->getSize();
-
- return $info;
- }
-
- /**
- * Multibyte unicode safe version of basename()
- *
- * @param string $path
- * @link https://www.php.net/manual/en/function.basename.php#121405
- * @return string
- */
- protected static function mb_basename($path) {
- if (preg_match('@^.*[\\\\/]([^\\\\/]+)$@s', $path, $matches)) {
- return $matches[1];
- } elseif (preg_match('@^([^\\\\/]+)$@s', $path, $matches)) {
- return $matches[1];
- }
-
- return '';
- }
-
- /**
- * Create a folder on the share
- *
- * @param string $path
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\AlreadyExistsException
- */
- public function mkdir($path) {
- return $this->getState()->mkdir($this->buildUrl($path));
- }
-
- /**
- * Remove a folder on the share
- *
- * @param string $path
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function rmdir($path) {
- return $this->getState()->rmdir($this->buildUrl($path));
- }
-
- /**
- * Delete a file on the share
- *
- * @param string $path
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function del($path) {
- return $this->getState()->unlink($this->buildUrl($path));
- }
-
- /**
- * Rename a remote file
- *
- * @param string $from
- * @param string $to
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\AlreadyExistsException
- */
- public function rename($from, $to) {
- return $this->getState()->rename($this->buildUrl($from), $this->buildUrl($to));
- }
-
- /**
- * Upload a local file
- *
- * @param string $source local file
- * @param string $target remove file
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function put($source, $target) {
- $sourceHandle = fopen($source, 'rb');
- $targetUrl = $this->buildUrl($target);
-
- $targetHandle = $this->getState()->create($targetUrl);
-
- while ($data = fread($sourceHandle, NativeReadStream::CHUNK_SIZE)) {
- $this->getState()->write($targetHandle, $data, $targetUrl);
- }
- $this->getState()->close($targetHandle, $targetUrl);
- return true;
- }
-
- /**
- * Download a remote file
- *
- * @param string $source remove file
- * @param string $target local file
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- * @throws \Icewind\SMB\Exception\InvalidPathException
- * @throws \Icewind\SMB\Exception\InvalidResourceException
- */
- public function get($source, $target) {
- if (!$target) {
- throw new InvalidPathException('Invalid target path: Filename cannot be empty');
- }
-
- $sourceHandle = $this->getState()->open($this->buildUrl($source), 'r');
- if (!$sourceHandle) {
- throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading');
- }
-
- $targetHandle = @fopen($target, 'wb');
- if (!$targetHandle) {
- $error = error_get_last();
- if (is_array($error)) {
- $reason = $error['message'];
- } else {
- $reason = 'Unknown error';
- }
- $this->getState()->close($sourceHandle, $this->buildUrl($source));
- throw new InvalidResourceException('Failed opening local file "' . $target . '" for writing: ' . $reason);
- }
-
- while ($data = $this->getState()->read($sourceHandle, NativeReadStream::CHUNK_SIZE)) {
- fwrite($targetHandle, $data);
- }
- $this->getState()->close($sourceHandle, $this->buildUrl($source));
- return true;
- }
-
- /**
- * Open a readable stream to a remote file
- *
- * @param string $source
- * @return resource a read only stream with the contents of the remote file
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function read($source) {
- $url = $this->buildUrl($source);
- $handle = $this->getState()->open($url, 'r');
- return NativeReadStream::wrap($this->getState(), $handle, 'r', $url);
- }
-
- /**
- * Open a writeable stream to a remote file
- * Note: This method will truncate the file to 0bytes first
- *
- * @param string $source
- * @return resource a writeable stream
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function write($source) {
- $url = $this->buildUrl($source);
- $handle = $this->getState()->create($url);
- return NativeWriteStream::wrap($this->getState(), $handle, 'w', $url);
- }
-
- /**
- * Open a writeable stream and set the cursor to the end of the stream
- *
- * @param string $source
- * @return resource a writeable stream
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function append($source) {
- $url = $this->buildUrl($source);
- $handle = $this->getState()->open($url, "a+");
- return NativeWriteStream::wrap($this->getState(), $handle, "a", $url);
- }
-
- /**
- * Get extended attributes for the path
- *
- * @param string $path
- * @param string $attribute attribute to get the info
- * @return string the attribute value
- */
- public function getAttribute($path, $attribute) {
- return $this->getState()->getxattr($this->buildUrl($path), $attribute);
- }
-
- /**
- * Set extended attributes for the given path
- *
- * @param string $path
- * @param string $attribute attribute to get the info
- * @param string|int $value
- * @return mixed the attribute value
- */
- public function setAttribute($path, $attribute, $value) {
- if ($attribute === 'system.dos_attr.mode' and is_int($value)) {
- $value = '0x' . dechex($value);
- }
-
- return $this->getState()->setxattr($this->buildUrl($path), $attribute, $value);
- }
-
- /**
- * Set DOS comaptible node mode
- *
- * @param string $path
- * @param int $mode a combination of FileInfo::MODE_READONLY, FileInfo::MODE_ARCHIVE, FileInfo::MODE_SYSTEM and FileInfo::MODE_HIDDEN, FileInfo::NORMAL
- * @return mixed
- */
- public function setMode($path, $mode) {
- return $this->setAttribute($path, 'system.dos_attr.mode', $mode);
- }
-
- /**
- * Start smb notify listener
- * Note: This is a blocking call
- *
- * @param string $path
- * @return INotifyHandler
- */
- public function notify($path) {
- // php-smbclient does not support notify (https://github.com/eduardok/libsmbclient-php/issues/29)
- // so we use the smbclient based backend for this
- if (!Server::available($this->server->getSystem())) {
- throw new DependencyException('smbclient not found in path for notify command');
- }
- $share = new Share($this->server, $this->getName(), $this->server->getSystem());
- return $share->notify($path);
- }
-
- public function getServer(): IServer {
- return $this->server;
- }
-
- public function __destruct() {
- unset($this->state);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php
deleted file mode 100644
index 3bfb1c3da24..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php
+++ /dev/null
@@ -1,317 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Native;
-
-use Icewind\SMB\Exception\AlreadyExistsException;
-use Icewind\SMB\Exception\ConnectionRefusedException;
-use Icewind\SMB\Exception\ConnectionResetException;
-use Icewind\SMB\Exception\Exception;
-use Icewind\SMB\Exception\FileInUseException;
-use Icewind\SMB\Exception\ForbiddenException;
-use Icewind\SMB\Exception\HostDownException;
-use Icewind\SMB\Exception\InvalidArgumentException;
-use Icewind\SMB\Exception\InvalidTypeException;
-use Icewind\SMB\Exception\ConnectionAbortedException;
-use Icewind\SMB\Exception\NoRouteToHostException;
-use Icewind\SMB\Exception\NotEmptyException;
-use Icewind\SMB\Exception\NotFoundException;
-use Icewind\SMB\Exception\OutOfSpaceException;
-use Icewind\SMB\Exception\TimedOutException;
-use Icewind\SMB\IAuth;
-use Icewind\SMB\IOptions;
-
-/**
- * Low level wrapper for libsmbclient-php with error handling
- */
-class NativeState {
- /**
- * @var resource
- */
- protected $state;
-
- protected $handlerSet = false;
-
- protected $connected = false;
-
- // see error.h
- const EXCEPTION_MAP = [
- 1 => ForbiddenException::class,
- 2 => NotFoundException::class,
- 13 => ForbiddenException::class,
- 16 => FileInUseException::class,
- 17 => AlreadyExistsException::class,
- 20 => InvalidTypeException::class,
- 21 => InvalidTypeException::class,
- 22 => InvalidArgumentException::class,
- 28 => OutOfSpaceException::class,
- 39 => NotEmptyException::class,
- 103 => ConnectionAbortedException::class,
- 104 => ConnectionResetException::class,
- 110 => TimedOutException::class,
- 111 => ConnectionRefusedException::class,
- 112 => HostDownException::class,
- 113 => NoRouteToHostException::class
- ];
-
- protected function handleError($path) {
- $error = smbclient_state_errno($this->state);
- if ($error === 0) {
- return;
- }
- throw Exception::fromMap(self::EXCEPTION_MAP, $error, $path);
- }
-
- protected function testResult($result, $uri) {
- if ($result === false or $result === null) {
- // smb://host/share/path
- if (is_string($uri) && count(explode('/', $uri, 5)) > 4) {
- list(, , , , $path) = explode('/', $uri, 5);
- $path = '/' . $path;
- } else {
- $path = null;
- }
- $this->handleError($path);
- }
- }
-
- /**
- * @param IAuth $auth
- * @param IOptions $options
- * @return bool
- */
- public function init(IAuth $auth, IOptions $options) {
- if ($this->connected) {
- return true;
- }
- $this->state = smbclient_state_new();
- smbclient_option_set($this->state, SMBCLIENT_OPT_AUTO_ANONYMOUS_LOGIN, false);
- smbclient_option_set($this->state, SMBCLIENT_OPT_TIMEOUT, $options->getTimeout() * 1000);
- $auth->setExtraSmbClientOptions($this->state);
- $result = @smbclient_state_init($this->state, $auth->getWorkgroup(), $auth->getUsername(), $auth->getPassword());
-
- $this->testResult($result, '');
- $this->connected = true;
- return $result;
- }
-
- /**
- * @param string $uri
- * @return resource
- */
- public function opendir($uri) {
- $result = @smbclient_opendir($this->state, $uri);
-
- $this->testResult($result, $uri);
- return $result;
- }
-
- /**
- * @param resource $dir
- * @return array
- */
- public function readdir($dir) {
- $result = @smbclient_readdir($this->state, $dir);
-
- $this->testResult($result, $dir);
- return $result;
- }
-
- /**
- * @param $dir
- * @return bool
- */
- public function closedir($dir) {
- $result = smbclient_closedir($this->state, $dir);
-
- $this->testResult($result, $dir);
- return $result;
- }
-
- /**
- * @param string $old
- * @param string $new
- * @return bool
- */
- public function rename($old, $new) {
- $result = @smbclient_rename($this->state, $old, $this->state, $new);
-
- $this->testResult($result, $new);
- return $result;
- }
-
- /**
- * @param string $uri
- * @return bool
- */
- public function unlink($uri) {
- $result = @smbclient_unlink($this->state, $uri);
-
- $this->testResult($result, $uri);
- return $result;
- }
-
- /**
- * @param string $uri
- * @param int $mask
- * @return bool
- */
- public function mkdir($uri, $mask = 0777) {
- $result = @smbclient_mkdir($this->state, $uri, $mask);
-
- $this->testResult($result, $uri);
- return $result;
- }
-
- /**
- * @param string $uri
- * @return bool
- */
- public function rmdir($uri) {
- $result = @smbclient_rmdir($this->state, $uri);
-
- $this->testResult($result, $uri);
- return $result;
- }
-
- /**
- * @param string $uri
- * @return array
- */
- public function stat($uri) {
- $result = @smbclient_stat($this->state, $uri);
-
- $this->testResult($result, $uri);
- return $result;
- }
-
- /**
- * @param resource $file
- * @return array
- */
- public function fstat($file) {
- $result = @smbclient_fstat($this->state, $file);
-
- $this->testResult($result, $file);
- return $result;
- }
-
- /**
- * @param string $uri
- * @param string $mode
- * @param int $mask
- * @return resource
- */
- public function open($uri, $mode, $mask = 0666) {
- $result = @smbclient_open($this->state, $uri, $mode, $mask);
-
- $this->testResult($result, $uri);
- return $result;
- }
-
- /**
- * @param string $uri
- * @param int $mask
- * @return resource
- */
- public function create($uri, $mask = 0666) {
- $result = @smbclient_creat($this->state, $uri, $mask);
-
- $this->testResult($result, $uri);
- return $result;
- }
-
- /**
- * @param resource $file
- * @param int $bytes
- * @return string
- */
- public function read($file, $bytes) {
- $result = @smbclient_read($this->state, $file, $bytes);
-
- $this->testResult($result, $file);
- return $result;
- }
-
- /**
- * @param resource $file
- * @param string $data
- * @param string $path
- * @param int $length
- * @return int
- */
- public function write($file, $data, $path, $length = null) {
- $result = @smbclient_write($this->state, $file, $data, $length);
-
- $this->testResult($result, $path);
- return $result;
- }
-
- /**
- * @param resource $file
- * @param int $offset
- * @param int $whence SEEK_SET | SEEK_CUR | SEEK_END
- * @return int|bool new file offset as measured from the start of the file on success, false on failure.
- */
- public function lseek($file, $offset, $whence = SEEK_SET) {
- $result = @smbclient_lseek($this->state, $file, $offset, $whence);
-
- $this->testResult($result, $file);
- return $result;
- }
-
- /**
- * @param resource $file
- * @param int $size
- * @return bool
- */
- public function ftruncate($file, $size) {
- $result = @smbclient_ftruncate($this->state, $file, $size);
-
- $this->testResult($result, $file);
- return $result;
- }
-
- public function close($file, $path) {
- $result = @smbclient_close($this->state, $file);
-
- $this->testResult($result, $path);
- return $result;
- }
-
- /**
- * @param string $uri
- * @param string $key
- * @return string
- */
- public function getxattr($uri, $key) {
- $result = @smbclient_getxattr($this->state, $uri, $key);
-
- $this->testResult($result, $uri);
- return $result;
- }
-
- /**
- * @param string $uri
- * @param string $key
- * @param string $value
- * @param int $flags
- * @return mixed
- */
- public function setxattr($uri, $key, $value, $flags = 0) {
- $result = @smbclient_setxattr($this->state, $uri, $key, $value, $flags);
-
- $this->testResult($result, $uri);
- return $result;
- }
-
- public function __destruct() {
- if ($this->connected) {
- smbclient_state_free($this->state);
- }
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php
deleted file mode 100644
index c75afaa5f1d..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Native;
-
-use Icewind\SMB\Exception\Exception;
-use Icewind\SMB\Exception\InvalidRequestException;
-use Icewind\Streams\File;
-
-class NativeStream implements File {
- /**
- * @var resource
- */
- public $context;
-
- /**
- * @var NativeState
- */
- protected $state;
-
- /**
- * @var resource
- */
- protected $handle;
-
- /**
- * @var bool
- */
- protected $eof = false;
-
- /**
- * @var string
- */
- protected $url;
-
- /**
- * Wrap a stream from libsmbclient-php into a regular php stream
- *
- * @param \Icewind\SMB\NativeState $state
- * @param resource $smbStream
- * @param string $mode
- * @param string $url
- * @return resource
- */
- public static function wrap($state, $smbStream, $mode, $url) {
- stream_wrapper_register('nativesmb', NativeStream::class);
- $context = stream_context_create([
- 'nativesmb' => [
- 'state' => $state,
- 'handle' => $smbStream,
- 'url' => $url
- ]
- ]);
- $fh = fopen('nativesmb://', $mode, false, $context);
- stream_wrapper_unregister('nativesmb');
- return $fh;
- }
-
- public function stream_close() {
- try {
- return $this->state->close($this->handle, $this->url);
- } catch (\Exception $e) {
- return false;
- }
- }
-
- public function stream_eof() {
- return $this->eof;
- }
-
- public function stream_flush() {
- }
-
-
- public function stream_open($path, $mode, $options, &$opened_path) {
- $context = stream_context_get_options($this->context);
- $this->state = $context['nativesmb']['state'];
- $this->handle = $context['nativesmb']['handle'];
- $this->url = $context['nativesmb']['url'];
- return true;
- }
-
- public function stream_read($count) {
- $result = $this->state->read($this->handle, $count);
- if (strlen($result) < $count) {
- $this->eof = true;
- }
- return $result;
- }
-
- public function stream_seek($offset, $whence = SEEK_SET) {
- $this->eof = false;
- try {
- return $this->state->lseek($this->handle, $offset, $whence) !== false;
- } catch (InvalidRequestException $e) {
- return false;
- }
- }
-
- public function stream_stat() {
- try {
- return $this->state->stat($this->url);
- } catch (Exception $e) {
- return false;
- }
- }
-
- public function stream_tell() {
- return $this->state->lseek($this->handle, 0, SEEK_CUR);
- }
-
- public function stream_write($data) {
- return $this->state->write($this->handle, $data, $this->url);
- }
-
- public function stream_truncate($size) {
- return $this->state->ftruncate($this->handle, $size);
- }
-
- public function stream_set_option($option, $arg1, $arg2) {
- return false;
- }
-
- public function stream_lock($operation) {
- return false;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeWriteStream.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeWriteStream.php
deleted file mode 100644
index 4e90e5a655d..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeWriteStream.php
+++ /dev/null
@@ -1,104 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Native;
-
-/**
- * Stream optimized for write only usage
- */
-class NativeWriteStream extends NativeStream {
- const CHUNK_SIZE = 1048576; // 1MB chunks
- /**
- * @var resource
- */
- private $writeBuffer = null;
-
- private $bufferSize = 0;
-
- private $pos = 0;
-
- public function stream_open($path, $mode, $options, &$opened_path) {
- $this->writeBuffer = fopen('php://memory', 'r+');
-
- return parent::stream_open($path, $mode, $options, $opened_path);
- }
-
- /**
- * Wrap a stream from libsmbclient-php into a regular php stream
- *
- * @param \Icewind\SMB\NativeState $state
- * @param resource $smbStream
- * @param string $mode
- * @param string $url
- * @return resource
- */
- public static function wrap($state, $smbStream, $mode, $url) {
- stream_wrapper_register('nativesmb', NativeWriteStream::class);
- $context = stream_context_create([
- 'nativesmb' => [
- 'state' => $state,
- 'handle' => $smbStream,
- 'url' => $url
- ]
- ]);
- $fh = fopen('nativesmb://', $mode, false, $context);
- stream_wrapper_unregister('nativesmb');
- return $fh;
- }
-
- public function stream_seek($offset, $whence = SEEK_SET) {
- $this->flushWrite();
- $result = parent::stream_seek($offset, $whence);
- if ($result) {
- $this->pos = parent::stream_tell();
- }
- return $result;
- }
-
- private function flushWrite() {
- rewind($this->writeBuffer);
- $this->state->write($this->handle, stream_get_contents($this->writeBuffer), $this->url);
- $this->writeBuffer = fopen('php://memory', 'r+');
- $this->bufferSize = 0;
- }
-
- public function stream_write($data) {
- $written = fwrite($this->writeBuffer, $data);
- $this->bufferSize += $written;
- $this->pos += $written;
-
- if ($this->bufferSize >= self::CHUNK_SIZE) {
- $this->flushWrite();
- }
-
- return $written;
- }
-
- public function stream_close() {
- try {
- $this->flushWrite();
- $flushResult = true;
- } catch (\Exception $e) {
- $flushResult = false;
- }
- return parent::stream_close() && $flushResult;
- }
-
- public function stream_tell() {
- return $this->pos;
- }
-
- public function stream_read($count) {
- return false;
- }
-
- public function stream_truncate($size) {
- $this->flushWrite();
- $this->pos = $size;
- return parent::stream_truncate($size);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Options.php b/apps/files_external/3rdparty/icewind/smb/src/Options.php
deleted file mode 100644
index 7a0d0149b73..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Options.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-class Options implements IOptions {
- /** @var int */
- private $timeout = 20;
-
- public function getTimeout() {
- return $this->timeout;
- }
-
- public function setTimeout($timeout) {
- $this->timeout = $timeout;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/ServerFactory.php b/apps/files_external/3rdparty/icewind/smb/src/ServerFactory.php
deleted file mode 100644
index 807b0b872cf..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/ServerFactory.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace Icewind\SMB;
-
-use Icewind\SMB\Exception\DependencyException;
-use Icewind\SMB\Native\NativeServer;
-use Icewind\SMB\Wrapped\Server;
-
-class ServerFactory {
- const BACKENDS = [
- NativeServer::class,
- Server::class
- ];
-
- /** @var System */
- private $system;
-
- /** @var IOptions */
- private $options;
-
- /** @var ITimeZoneProvider */
- private $timeZoneProvider;
-
- /**
- * ServerFactory constructor.
- *
- * @param IOptions|null $options
- * @param ISystem|null $system
- * @param ITimeZoneProvider|null $timeZoneProvider
- */
- public function __construct(
- IOptions $options = null,
- ISystem $system = null,
- ITimeZoneProvider $timeZoneProvider = null
- ) {
- if (is_null($options)) {
- $options = new Options();
- }
- if (is_null($system)) {
- $system = new System();
- }
- if (is_null($timeZoneProvider)) {
- $timeZoneProvider = new TimeZoneProvider($system);
- }
- $this->options = $options;
- $this->system = $system;
- $this->timeZoneProvider = $timeZoneProvider;
- }
-
-
- /**
- * @param $host
- * @param IAuth $credentials
- * @return IServer
- * @throws DependencyException
- */
- public function createServer($host, IAuth $credentials) {
- foreach (self::BACKENDS as $backend) {
- if (call_user_func("$backend::available", $this->system)) {
- return new $backend($host, $credentials, $this->system, $this->timeZoneProvider, $this->options);
- }
- }
-
- throw new DependencyException('No valid backend available, ensure smbclient is in the path or php-smbclient is installed');
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/System.php b/apps/files_external/3rdparty/icewind/smb/src/System.php
deleted file mode 100644
index 0e41ee032d6..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/System.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB;
-
-use Icewind\SMB\Exception\Exception;
-
-class System implements ISystem {
- /** @var (string|bool)[] */
- private $paths = [];
-
- /**
- * Get the path to a file descriptor of the current process
- *
- * @param int $num the file descriptor id
- * @return string
- * @throws Exception
- */
- public function getFD($num) {
- $folders = [
- '/proc/self/fd',
- '/dev/fd'
- ];
- foreach ($folders as $folder) {
- if (file_exists($folder)) {
- return $folder . '/' . $num;
- }
- }
- throw new Exception('Cant find file descriptor path');
- }
-
- public function getSmbclientPath() {
- return $this->getBinaryPath('smbclient');
- }
-
- public function getNetPath() {
- return $this->getBinaryPath('net');
- }
-
- public function getSmbcAclsPath() {
- return $this->getBinaryPath('smbcacls');
- }
-
- public function getStdBufPath() {
- return $this->getBinaryPath('stdbuf');
- }
-
- public function getDatePath() {
- return $this->getBinaryPath('date');
- }
-
- public function libSmbclientAvailable() {
- return function_exists('smbclient_state_new');
- }
-
- protected function getBinaryPath($binary) {
- if (!isset($this->paths[$binary])) {
- $result = null;
- $output = [];
- exec("which $binary 2>&1", $output, $result);
- $this->paths[$binary] = $result === 0 ? trim(implode('', $output)) : false;
- }
- return $this->paths[$binary];
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php b/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php
deleted file mode 100644
index 7ae049c406f..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB;
-
-class TimeZoneProvider implements ITimeZoneProvider {
- /**
- * @var string[]
- */
- private $timeZones = [];
-
- /**
- * @var ISystem
- */
- private $system;
-
- /**
- * @param ISystem $system
- */
- public function __construct(ISystem $system) {
- $this->system = $system;
- }
-
- public function get($host) {
- if (!isset($this->timeZones[$host])) {
- $timeZone = null;
- $net = $this->system->getNetPath();
- // for local domain names we can assume same timezone
- if ($net && $host && strpos($host, '.') !== false) {
- $command = sprintf(
- '%s time zone -S %s',
- $net,
- escapeshellarg($host)
- );
- $timeZone = exec($command);
- }
-
- if (!$timeZone) {
- $date = $this->system->getDatePath();
- if ($date) {
- $timeZone = exec($date . " +%z");
- } else {
- $timeZone = date_default_timezone_get();
- }
- }
- $this->timeZones[$host] = $timeZone;
- }
- return $this->timeZones[$host];
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Connection.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Connection.php
deleted file mode 100644
index 347b63db110..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Connection.php
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Wrapped;
-
-use Icewind\SMB\Exception\AuthenticationException;
-use Icewind\SMB\Exception\ConnectException;
-use Icewind\SMB\Exception\ConnectionException;
-use Icewind\SMB\Exception\InvalidHostException;
-use Icewind\SMB\Exception\NoLoginServerException;
-
-class Connection extends RawConnection {
- const DELIMITER = 'smb:';
- const DELIMITER_LENGTH = 4;
-
- /** @var Parser */
- private $parser;
-
- public function __construct($command, Parser $parser, $env = []) {
- parent::__construct($command, $env);
- $this->parser = $parser;
- }
-
- /**
- * send input to smbclient
- *
- * @param string $input
- */
- public function write($input) {
- parent::write($input . PHP_EOL);
- }
-
- /**
- * @throws ConnectException
- */
- public function clearTillPrompt() {
- $this->write('');
- do {
- $promptLine = $this->readLine();
- $this->parser->checkConnectionError($promptLine);
- } while (!$this->isPrompt($promptLine));
- $this->write('');
- $this->readLine();
- }
-
- /**
- * get all unprocessed output from smbclient until the next prompt
- *
- * @param callable $callback (optional) callback to call for every line read
- * @return string[]
- * @throws AuthenticationException
- * @throws ConnectException
- * @throws ConnectionException
- * @throws InvalidHostException
- * @throws NoLoginServerException
- */
- public function read(callable $callback = null) {
- if (!$this->isValid()) {
- throw new ConnectionException('Connection not valid');
- }
- $promptLine = $this->readLine(); //first line is prompt
- $this->parser->checkConnectionError($promptLine);
-
- $output = [];
- if (!$this->isPrompt($promptLine)) {
- $line = $promptLine;
- } else {
- $line = $this->readLine();
- }
- if ($line === false) {
- $this->unknownError($promptLine);
- }
- while (!$this->isPrompt($line)) { //next prompt functions as delimiter
- if (is_callable($callback)) {
- $result = $callback($line);
- if ($result === false) { // allow the callback to close the connection for infinite running commands
- $this->close(true);
- break;
- }
- } else {
- $output[] .= $line;
- }
- $line = $this->readLine();
- }
- return $output;
- }
-
- /**
- * Check
- *
- * @param $line
- * @return bool
- */
- private function isPrompt($line) {
- return mb_substr($line, 0, self::DELIMITER_LENGTH) === self::DELIMITER || $line === false;
- }
-
- /**
- * @param string $promptLine (optional) prompt line that might contain some info about the error
- * @throws ConnectException
- */
- private function unknownError($promptLine = '') {
- if ($promptLine) { //maybe we have some error we missed on the previous line
- throw new ConnectException('Unknown error (' . $promptLine . ')');
- } else {
- $error = $this->readError(); // maybe something on stderr
- if ($error) {
- throw new ConnectException('Unknown error (' . $error . ')');
- } else {
- throw new ConnectException('Unknown error');
- }
- }
- }
-
- public function close($terminate = true) {
- if (get_resource_type($this->getInputStream()) === 'stream') {
- // ignore any errors while trying to send the close command, the process might already be dead
- @$this->write('close' . PHP_EOL);
- }
- parent::close($terminate);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/ErrorCodes.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/ErrorCodes.php
deleted file mode 100644
index 7df83b268d8..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/ErrorCodes.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Wrapped;
-
-class ErrorCodes {
- /**
- * connection errors
- */
- const LogonFailure = 'NT_STATUS_LOGON_FAILURE';
- const BadHostName = 'NT_STATUS_BAD_NETWORK_NAME';
- const Unsuccessful = 'NT_STATUS_UNSUCCESSFUL';
- const ConnectionRefused = 'NT_STATUS_CONNECTION_REFUSED';
- const NoLogonServers = 'NT_STATUS_NO_LOGON_SERVERS';
-
- const PathNotFound = 'NT_STATUS_OBJECT_PATH_NOT_FOUND';
- const NoSuchFile = 'NT_STATUS_NO_SUCH_FILE';
- const ObjectNotFound = 'NT_STATUS_OBJECT_NAME_NOT_FOUND';
- const NameCollision = 'NT_STATUS_OBJECT_NAME_COLLISION';
- const AccessDenied = 'NT_STATUS_ACCESS_DENIED';
- const DirectoryNotEmpty = 'NT_STATUS_DIRECTORY_NOT_EMPTY';
- const FileIsADirectory = 'NT_STATUS_FILE_IS_A_DIRECTORY';
- const NotADirectory = 'NT_STATUS_NOT_A_DIRECTORY';
- const SharingViolation = 'NT_STATUS_SHARING_VIOLATION';
- const InvalidParameter = 'NT_STATUS_INVALID_PARAMETER';
- const RevisionMismatch = 'NT_STATUS_REVISION_MISMATCH';
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/FileInfo.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/FileInfo.php
deleted file mode 100644
index a310a6bc913..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/FileInfo.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Wrapped;
-
-use Icewind\SMB\ACL;
-use Icewind\SMB\IFileInfo;
-
-class FileInfo implements IFileInfo {
- /**
- * @var string
- */
- protected $path;
-
- /**
- * @var string
- */
- protected $name;
-
- /**
- * @var int
- */
- protected $size;
-
- /**
- * @var int
- */
- protected $time;
-
- /**
- * @var int
- */
- protected $mode;
-
- /**
- * @var callable
- */
- protected $aclCallback;
-
- /**
- * @param string $path
- * @param string $name
- * @param int $size
- * @param int $time
- * @param int $mode
- * @param callable $aclCallback
- */
- public function __construct($path, $name, $size, $time, $mode, callable $aclCallback) {
- $this->path = $path;
- $this->name = $name;
- $this->size = $size;
- $this->time = $time;
- $this->mode = $mode;
- $this->aclCallback = $aclCallback;
- }
-
- /**
- * @return string
- */
- public function getPath() {
- return $this->path;
- }
-
- /**
- * @return string
- */
- public function getName() {
- return $this->name;
- }
-
- /**
- * @return int
- */
- public function getSize() {
- return $this->size;
- }
-
- /**
- * @return int
- */
- public function getMTime() {
- return $this->time;
- }
-
- /**
- * @return bool
- */
- public function isDirectory() {
- return (bool)($this->mode & IFileInfo::MODE_DIRECTORY);
- }
-
- /**
- * @return bool
- */
- public function isReadOnly() {
- return (bool)($this->mode & IFileInfo::MODE_READONLY);
- }
-
- /**
- * @return bool
- */
- public function isHidden() {
- return (bool)($this->mode & IFileInfo::MODE_HIDDEN);
- }
-
- /**
- * @return bool
- */
- public function isSystem() {
- return (bool)($this->mode & IFileInfo::MODE_SYSTEM);
- }
-
- /**
- * @return bool
- */
- public function isArchived() {
- return (bool)($this->mode & IFileInfo::MODE_ARCHIVE);
- }
-
- /**
- * @return ACL[]
- */
- public function getAcls(): array {
- return ($this->aclCallback)();
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/NotifyHandler.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/NotifyHandler.php
deleted file mode 100644
index 090734381bb..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/NotifyHandler.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- *
- */
-
-namespace Icewind\SMB\Wrapped;
-
-use Icewind\SMB\Change;
-use Icewind\SMB\Exception\Exception;
-use Icewind\SMB\Exception\RevisionMismatchException;
-use Icewind\SMB\INotifyHandler;
-
-class NotifyHandler implements INotifyHandler {
- /**
- * @var Connection
- */
- private $connection;
-
- /**
- * @var string
- */
- private $path;
-
- private $listening = true;
-
- // see error.h
- const EXCEPTION_MAP = [
- ErrorCodes::RevisionMismatch => RevisionMismatchException::class,
- ];
-
- /**
- * @param Connection $connection
- * @param string $path
- */
- public function __construct(Connection $connection, $path) {
- $this->connection = $connection;
- $this->path = $path;
- }
-
- /**
- * Get all changes detected since the start of the notify process or the last call to getChanges
- *
- * @return Change[]
- */
- public function getChanges() {
- if (!$this->listening) {
- return [];
- }
- stream_set_blocking($this->connection->getOutputStream(), 0);
- $lines = [];
- while (($line = $this->connection->readLine())) {
- $this->checkForError($line);
- $lines[] = $line;
- }
- stream_set_blocking($this->connection->getOutputStream(), 1);
- return array_values(array_filter(array_map([$this, 'parseChangeLine'], $lines)));
- }
-
- /**
- * Listen actively to all incoming changes
- *
- * Note that this is a blocking process and will cause the process to block forever if not explicitly terminated
- *
- * @param callable $callback
- */
- public function listen($callback) {
- if ($this->listening) {
- $this->connection->read(function ($line) use ($callback) {
- $this->checkForError($line);
- $change = $this->parseChangeLine($line);
- if ($change) {
- return $callback($change);
- }
- });
- }
- }
-
- private function parseChangeLine($line) {
- $code = (int)substr($line, 0, 4);
- if ($code === 0) {
- return null;
- }
- $subPath = str_replace('\\', '/', substr($line, 5));
- if ($this->path === '') {
- return new Change($code, $subPath);
- } else {
- return new Change($code, $this->path . '/' . $subPath);
- }
- }
-
- private function checkForError($line) {
- if (substr($line, 0, 16) === 'notify returned ') {
- $error = substr($line, 16);
- throw Exception::fromMap(array_merge(self::EXCEPTION_MAP, Parser::EXCEPTION_MAP), $error, 'Notify is not supported with the used smb version');
- }
- }
-
- public function stop() {
- $this->listening = false;
- $this->connection->close();
- }
-
- public function __destruct() {
- $this->stop();
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php
deleted file mode 100644
index a28432e4319..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php
+++ /dev/null
@@ -1,191 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Wrapped;
-
-use Icewind\SMB\Exception\AccessDeniedException;
-use Icewind\SMB\Exception\AlreadyExistsException;
-use Icewind\SMB\Exception\AuthenticationException;
-use Icewind\SMB\Exception\Exception;
-use Icewind\SMB\Exception\FileInUseException;
-use Icewind\SMB\Exception\InvalidHostException;
-use Icewind\SMB\Exception\InvalidParameterException;
-use Icewind\SMB\Exception\InvalidResourceException;
-use Icewind\SMB\Exception\InvalidTypeException;
-use Icewind\SMB\Exception\NoLoginServerException;
-use Icewind\SMB\Exception\NotEmptyException;
-use Icewind\SMB\Exception\NotFoundException;
-
-class Parser {
- const MSG_NOT_FOUND = 'Error opening local file ';
-
- /**
- * @var string
- */
- protected $timeZone;
-
- /**
- * @var string
- */
- private $host;
-
- // see error.h
- const EXCEPTION_MAP = [
- ErrorCodes::LogonFailure => AuthenticationException::class,
- ErrorCodes::PathNotFound => NotFoundException::class,
- ErrorCodes::ObjectNotFound => NotFoundException::class,
- ErrorCodes::NoSuchFile => NotFoundException::class,
- ErrorCodes::NameCollision => AlreadyExistsException::class,
- ErrorCodes::AccessDenied => AccessDeniedException::class,
- ErrorCodes::DirectoryNotEmpty => NotEmptyException::class,
- ErrorCodes::FileIsADirectory => InvalidTypeException::class,
- ErrorCodes::NotADirectory => InvalidTypeException::class,
- ErrorCodes::SharingViolation => FileInUseException::class,
- ErrorCodes::InvalidParameter => InvalidParameterException::class
- ];
-
- const MODE_STRINGS = [
- 'R' => FileInfo::MODE_READONLY,
- 'H' => FileInfo::MODE_HIDDEN,
- 'S' => FileInfo::MODE_SYSTEM,
- 'D' => FileInfo::MODE_DIRECTORY,
- 'A' => FileInfo::MODE_ARCHIVE,
- 'N' => FileInfo::MODE_NORMAL
- ];
-
- /**
- * @param string $timeZone
- */
- public function __construct($timeZone) {
- $this->timeZone = $timeZone;
- }
-
- private function getErrorCode($line) {
- $parts = explode(' ', $line);
- foreach ($parts as $part) {
- if (substr($part, 0, 9) === 'NT_STATUS') {
- return $part;
- }
- }
- return false;
- }
-
- public function checkForError($output, $path) {
- if (strpos($output[0], 'does not exist')) {
- throw new NotFoundException($path);
- }
- $error = $this->getErrorCode($output[0]);
-
- if (substr($output[0], 0, strlen(self::MSG_NOT_FOUND)) === self::MSG_NOT_FOUND) {
- $localPath = substr($output[0], strlen(self::MSG_NOT_FOUND));
- throw new InvalidResourceException('Failed opening local file "' . $localPath . '" for writing');
- }
-
- throw Exception::fromMap(self::EXCEPTION_MAP, $error, $path);
- }
-
- /**
- * check if the first line holds a connection failure
- *
- * @param $line
- * @throws AuthenticationException
- * @throws InvalidHostException
- * @throws NoLoginServerException
- * @throws AccessDeniedException
- */
- public function checkConnectionError($line) {
- $line = rtrim($line, ')');
- if (substr($line, -23) === ErrorCodes::LogonFailure) {
- throw new AuthenticationException('Invalid login');
- }
- if (substr($line, -26) === ErrorCodes::BadHostName) {
- throw new InvalidHostException('Invalid hostname');
- }
- if (substr($line, -22) === ErrorCodes::Unsuccessful) {
- throw new InvalidHostException('Connection unsuccessful');
- }
- if (substr($line, -28) === ErrorCodes::ConnectionRefused) {
- throw new InvalidHostException('Connection refused');
- }
- if (substr($line, -26) === ErrorCodes::NoLogonServers) {
- throw new NoLoginServerException('No login server');
- }
- if (substr($line, -23) === ErrorCodes::AccessDenied) {
- throw new AccessDeniedException('Access denied');
- }
- }
-
- public function parseMode($mode) {
- $result = 0;
- foreach (self::MODE_STRINGS as $char => $val) {
- if (strpos($mode, $char) !== false) {
- $result |= $val;
- }
- }
- return $result;
- }
-
- public function parseStat($output) {
- $data = [];
- foreach ($output as $line) {
- // A line = explode statement may not fill all array elements
- // properly. May happen when accessing non Windows Fileservers
- $words = explode(':', $line, 2);
- $name = isset($words[0]) ? $words[0] : '';
- $value = isset($words[1]) ? $words[1] : '';
- $value = trim($value);
-
- if (!isset($data[$name])) {
- $data[$name] = $value;
- }
- }
- return [
- 'mtime' => strtotime($data['write_time']),
- 'mode' => hexdec(substr($data['attributes'], strpos($data['attributes'], '(') + 1, -1)),
- 'size' => isset($data['stream']) ? (int)(explode(' ', $data['stream'])[1]) : 0
- ];
- }
-
- public function parseDir($output, $basePath, callable $aclCallback) {
- //last line is used space
- array_pop($output);
- $regex = '/^\s*(.*?)\s\s\s\s+(?:([NDHARS]*)\s+)?([0-9]+)\s+(.*)$/';
- //2 spaces, filename, optional type, size, date
- $content = [];
- foreach ($output as $line) {
- if (preg_match($regex, $line, $matches)) {
- list(, $name, $mode, $size, $time) = $matches;
- if ($name !== '.' and $name !== '..') {
- $mode = $this->parseMode($mode);
- $time = strtotime($time . ' ' . $this->timeZone);
- $path = $basePath . '/' . $name;
- $content[] = new FileInfo($path, $name, $size, $time, $mode, function () use ($aclCallback, $path) {
- return $aclCallback($path);
- });
- }
- }
- }
- return $content;
- }
-
- public function parseListShares($output) {
- $shareNames = [];
- foreach ($output as $line) {
- if (strpos($line, '|')) {
- list($type, $name, $description) = explode('|', $line);
- if (strtolower($type) === 'disk') {
- $shareNames[$name] = $description;
- }
- } elseif (strpos($line, 'Disk')) {
- // new output format
- list($name, $description) = explode('Disk', $line);
- $shareNames[trim($name)] = trim($description);
- }
- }
- return $shareNames;
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php
deleted file mode 100644
index 3a114af5e4f..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php
+++ /dev/null
@@ -1,189 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Wrapped;
-
-use Icewind\SMB\Exception\ConnectException;
-use Icewind\SMB\Exception\ConnectionException;
-
-class RawConnection {
- /**
- * @var string
- */
- private $command;
-
- /**
- * @var string[]
- */
- private $env;
-
- /**
- * @var resource[] $pipes
- *
- * $pipes[0] holds STDIN for smbclient
- * $pipes[1] holds STDOUT for smbclient
- * $pipes[3] holds the authfile for smbclient
- * $pipes[4] holds the stream for writing files
- * $pipes[5] holds the stream for reading files
- */
- private $pipes;
-
- /**
- * @var resource $process
- */
- private $process;
-
- /**
- * @var resource|null $authStream
- */
- private $authStream = null;
-
- private $connected = false;
-
- public function __construct($command, array $env = []) {
- $this->command = $command;
- $this->env = $env;
- }
-
- /**
- * @throws ConnectException
- */
- public function connect() {
- if (is_null($this->getAuthStream())) {
- throw new ConnectException('Authentication not set before connecting');
- }
-
- $descriptorSpec = [
- 0 => ['pipe', 'r'], // child reads from stdin
- 1 => ['pipe', 'w'], // child writes to stdout
- 2 => ['pipe', 'w'], // child writes to stderr
- 3 => $this->getAuthStream(), // child reads from fd#3
- 4 => ['pipe', 'r'], // child reads from fd#4
- 5 => ['pipe', 'w'] // child writes to fd#5
- ];
-
- setlocale(LC_ALL, Server::LOCALE);
- $env = array_merge($this->env, [
- 'CLI_FORCE_INTERACTIVE' => 'y', // Needed or the prompt isn't displayed!!
- 'LC_ALL' => Server::LOCALE,
- 'LANG' => Server::LOCALE,
- 'COLUMNS' => 8192 // prevent smbclient from line-wrapping it's output
- ]);
- $this->process = proc_open($this->command, $descriptorSpec, $this->pipes, '/', $env);
- if (!$this->isValid()) {
- throw new ConnectionException();
- }
- $this->connected = true;
- }
-
- /**
- * check if the connection is still active
- *
- * @return bool
- */
- public function isValid() {
- if (is_resource($this->process)) {
- $status = proc_get_status($this->process);
- return $status['running'];
- } else {
- return false;
- }
- }
-
- /**
- * send input to the process
- *
- * @param string $input
- */
- public function write($input) {
- fwrite($this->getInputStream(), $input);
- fflush($this->getInputStream());
- }
-
- /**
- * read a line of output
- *
- * @return string|false
- */
- public function readLine() {
- return stream_get_line($this->getOutputStream(), 4086, "\n");
- }
-
- /**
- * read a line of output
- *
- * @return string
- */
- public function readError() {
- return trim(stream_get_line($this->getErrorStream(), 4086));
- }
-
- /**
- * get all output until the process closes
- *
- * @return array
- */
- public function readAll() {
- $output = [];
- while ($line = $this->readLine()) {
- $output[] = $line;
- }
- return $output;
- }
-
- public function getInputStream() {
- return $this->pipes[0];
- }
-
- public function getOutputStream() {
- return $this->pipes[1];
- }
-
- public function getErrorStream() {
- return $this->pipes[2];
- }
-
- public function getAuthStream() {
- return $this->authStream;
- }
-
- public function getFileInputStream() {
- return $this->pipes[4];
- }
-
- public function getFileOutputStream() {
- return $this->pipes[5];
- }
-
- public function writeAuthentication($user, $password) {
- $auth = ($password === false)
- ? "username=$user"
- : "username=$user\npassword=$password\n";
-
- $this->authStream = fopen('php://temp', 'w+');
- fwrite($this->getAuthStream(), $auth);
- }
-
- public function close($terminate = true) {
- if (!is_resource($this->process)) {
- return;
- }
- if ($terminate) {
- proc_terminate($this->process);
- }
- proc_close($this->process);
- }
-
- public function reconnect() {
- $this->close();
- $this->connect();
- }
-
- public function __destruct() {
- $this->close();
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Server.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Server.php
deleted file mode 100644
index b3763a73245..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Server.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Wrapped;
-
-use Icewind\SMB\AbstractServer;
-use Icewind\SMB\Exception\AuthenticationException;
-use Icewind\SMB\Exception\ConnectException;
-use Icewind\SMB\Exception\ConnectionException;
-use Icewind\SMB\Exception\InvalidHostException;
-use Icewind\SMB\IShare;
-use Icewind\SMB\ISystem;
-
-class Server extends AbstractServer {
- /**
- * Check if the smbclient php extension is available
- *
- * @param ISystem $system
- * @return bool
- */
- public static function available(ISystem $system) {
- return $system->getSmbclientPath();
- }
-
- private function getAuthFileArgument() {
- if ($this->getAuth()->getUsername()) {
- return '--authentication-file=' . $this->system->getFD(3);
- } else {
- return '';
- }
- }
-
- /**
- * @return IShare[]
- *
- * @throws AuthenticationException
- * @throws InvalidHostException
- * @throws ConnectException
- */
- public function listShares() {
- $command = sprintf(
- '%s %s %s -L %s',
- $this->system->getSmbclientPath(),
- $this->getAuthFileArgument(),
- $this->getAuth()->getExtraCommandLineArguments(),
- escapeshellarg('//' . $this->getHost())
- );
- $connection = new RawConnection($command);
- $connection->writeAuthentication($this->getAuth()->getUsername(), $this->getAuth()->getPassword());
- $connection->connect();
- if (!$connection->isValid()) {
- throw new ConnectionException($connection->readLine());
- }
-
- $parser = new Parser($this->timezoneProvider);
-
- $output = $connection->readAll();
- if (isset($output[0])) {
- $parser->checkConnectionError($output[0]);
- }
-
- // sometimes we get an empty line first
- if (count($output) < 2) {
- $output = $connection->readAll();
- }
-
- if (isset($output[0])) {
- $parser->checkConnectionError($output[0]);
- }
-
- $shareNames = $parser->parseListShares($output);
-
- $shares = [];
- foreach ($shareNames as $name => $description) {
- $shares[] = $this->getShare($name);
- }
- return $shares;
- }
-
- /**
- * @param string $name
- * @return IShare
- */
- public function getShare($name) {
- return new Share($this, $name, $this->system);
- }
-}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php
deleted file mode 100644
index ea386a87bfc..00000000000
--- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php
+++ /dev/null
@@ -1,562 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Licensed under the MIT license:
- * http://opensource.org/licenses/MIT
- */
-
-namespace Icewind\SMB\Wrapped;
-
-use Icewind\SMB\AbstractShare;
-use Icewind\SMB\ACL;
-use Icewind\SMB\Exception\ConnectionException;
-use Icewind\SMB\Exception\DependencyException;
-use Icewind\SMB\Exception\FileInUseException;
-use Icewind\SMB\Exception\InvalidTypeException;
-use Icewind\SMB\Exception\NotFoundException;
-use Icewind\SMB\Exception\InvalidRequestException;
-use Icewind\SMB\IFileInfo;
-use Icewind\SMB\INotifyHandler;
-use Icewind\SMB\IServer;
-use Icewind\SMB\ISystem;
-use Icewind\Streams\CallbackWrapper;
-use Icewind\SMB\Native\NativeShare;
-use Icewind\SMB\Native\NativeServer;
-
-class Share extends AbstractShare {
- /**
- * @var IServer $server
- */
- private $server;
-
- /**
- * @var string $name
- */
- private $name;
-
- /**
- * @var Connection $connection
- */
- public $connection;
-
- /**
- * @var Parser
- */
- protected $parser;
-
- /**
- * @var ISystem
- */
- private $system;
-
- const MODE_MAP = [
- FileInfo::MODE_READONLY => 'r',
- FileInfo::MODE_HIDDEN => 'h',
- FileInfo::MODE_ARCHIVE => 'a',
- FileInfo::MODE_SYSTEM => 's'
- ];
-
- const EXEC_CMD = 'exec';
-
- /**
- * @param IServer $server
- * @param string $name
- * @param ISystem $system
- */
- public function __construct(IServer $server, $name, ISystem $system) {
- parent::__construct();
- $this->server = $server;
- $this->name = $name;
- $this->system = $system;
- $this->parser = new Parser($server->getTimeZone());
- }
-
- private function getAuthFileArgument() {
- if ($this->server->getAuth()->getUsername()) {
- return '--authentication-file=' . $this->system->getFD(3);
- } else {
- return '';
- }
- }
-
- protected function getConnection() {
- $command = sprintf(
- '%s %s%s -t %s %s %s %s',
- self::EXEC_CMD,
- $this->system->getStdBufPath() ? $this->system->getStdBufPath() . ' -o0 ' : '',
- $this->system->getSmbclientPath(),
- $this->server->getOptions()->getTimeout(),
- $this->getAuthFileArgument(),
- $this->server->getAuth()->getExtraCommandLineArguments(),
- escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
- );
- $connection = new Connection($command, $this->parser);
- $connection->writeAuthentication($this->server->getAuth()->getUsername(), $this->server->getAuth()->getPassword());
- $connection->connect();
- if (!$connection->isValid()) {
- throw new ConnectionException($connection->readLine());
- }
- // some versions of smbclient add a help message in first of the first prompt
- $connection->clearTillPrompt();
- return $connection;
- }
-
- /**
- * @throws \Icewind\SMB\Exception\ConnectionException
- * @throws \Icewind\SMB\Exception\AuthenticationException
- * @throws \Icewind\SMB\Exception\InvalidHostException
- */
- protected function connect() {
- if ($this->connection and $this->connection->isValid()) {
- return;
- }
- $this->connection = $this->getConnection();
- }
-
- protected function reconnect() {
- $this->connection->reconnect();
- if (!$this->connection->isValid()) {
- throw new ConnectionException();
- }
- }
-
- /**
- * Get the name of the share
- *
- * @return string
- */
- public function getName() {
- return $this->name;
- }
-
- protected function simpleCommand($command, $path) {
- $escapedPath = $this->escapePath($path);
- $cmd = $command . ' ' . $escapedPath;
- $output = $this->execute($cmd);
- return $this->parseOutput($output, $path);
- }
-
- /**
- * List the content of a remote folder
- *
- * @param $path
- * @return \Icewind\SMB\IFileInfo[]
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function dir($path) {
- $escapedPath = $this->escapePath($path);
- $output = $this->execute('cd ' . $escapedPath);
- //check output for errors
- $this->parseOutput($output, $path);
- $output = $this->execute('dir');
-
- $this->execute('cd /');
-
- return $this->parser->parseDir($output, $path, function ($path) {
- return $this->getAcls($path);
- });
- }
-
- /**
- * @param string $path
- * @return \Icewind\SMB\IFileInfo
- */
- public function stat($path) {
- // some windows server setups don't seem to like the allinfo command
- // use the dir command instead to get the file info where possible
- if ($path !== "" && $path !== "/") {
- $parent = dirname($path);
- $dir = $this->dir($parent);
- $file = array_values(array_filter($dir, function (IFileInfo $info) use ($path) {
- return $info->getPath() === $path;
- }));
- if ($file) {
- return $file[0];
- }
- }
-
- $escapedPath = $this->escapePath($path);
- $output = $this->execute('allinfo ' . $escapedPath);
- // Windows and non Windows Fileserver may respond different
- // to the allinfo command for directories. If the result is a single
- // line = error line, redo it with a different allinfo parameter
- if ($escapedPath == '""' && count($output) < 2) {
- $output = $this->execute('allinfo ' . '"."');
- }
- if (count($output) < 3) {
- $this->parseOutput($output, $path);
- }
- $stat = $this->parser->parseStat($output);
- return new FileInfo($path, basename($path), $stat['size'], $stat['mtime'], $stat['mode'], function () use ($path) {
- return $this->getAcls($path);
- });
- }
-
- /**
- * Create a folder on the share
- *
- * @param string $path
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\AlreadyExistsException
- */
- public function mkdir($path) {
- return $this->simpleCommand('mkdir', $path);
- }
-
- /**
- * Remove a folder on the share
- *
- * @param string $path
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function rmdir($path) {
- return $this->simpleCommand('rmdir', $path);
- }
-
- /**
- * Delete a file on the share
- *
- * @param string $path
- * @param bool $secondTry
- * @return bool
- * @throws InvalidTypeException
- * @throws NotFoundException
- * @throws \Exception
- */
- public function del($path, $secondTry = false) {
- //del return a file not found error when trying to delete a folder
- //we catch it so we can check if $path doesn't exist or is of invalid type
- try {
- return $this->simpleCommand('del', $path);
- } catch (NotFoundException $e) {
- //no need to do anything with the result, we just check if this throws the not found error
- try {
- $this->simpleCommand('ls', $path);
- } catch (NotFoundException $e2) {
- throw $e;
- } catch (\Exception $e2) {
- throw new InvalidTypeException($path);
- }
- throw $e;
- } catch (FileInUseException $e) {
- if ($secondTry) {
- throw $e;
- }
- $this->reconnect();
- return $this->del($path, true);
- }
- }
-
- /**
- * Rename a remote file
- *
- * @param string $from
- * @param string $to
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\AlreadyExistsException
- */
- public function rename($from, $to) {
- $path1 = $this->escapePath($from);
- $path2 = $this->escapePath($to);
- $output = $this->execute('rename ' . $path1 . ' ' . $path2);
- return $this->parseOutput($output, $to);
- }
-
- /**
- * Upload a local file
- *
- * @param string $source local file
- * @param string $target remove file
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function put($source, $target) {
- $path1 = $this->escapeLocalPath($source); //first path is local, needs different escaping
- $path2 = $this->escapePath($target);
- $output = $this->execute('put ' . $path1 . ' ' . $path2);
- return $this->parseOutput($output, $target);
- }
-
- /**
- * Download a remote file
- *
- * @param string $source remove file
- * @param string $target local file
- * @return bool
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function get($source, $target) {
- $path1 = $this->escapePath($source);
- $path2 = $this->escapeLocalPath($target); //second path is local, needs different escaping
- $output = $this->execute('get ' . $path1 . ' ' . $path2);
- return $this->parseOutput($output, $source);
- }
-
- /**
- * Open a readable stream to a remote file
- *
- * @param string $source
- * @return resource a read only stream with the contents of the remote file
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function read($source) {
- $source = $this->escapePath($source);
- // since returned stream is closed by the caller we need to create a new instance
- // since we can't re-use the same file descriptor over multiple calls
- $connection = $this->getConnection();
-
- $connection->write('get ' . $source . ' ' . $this->system->getFD(5));
- $connection->write('exit');
- $fh = $connection->getFileOutputStream();
- stream_context_set_option($fh, 'file', 'connection', $connection);
- return $fh;
- }
-
- /**
- * Open a writable stream to a remote file
- *
- * @param string $target
- * @return resource a write only stream to upload a remote file
- *
- * @throws \Icewind\SMB\Exception\NotFoundException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- */
- public function write($target) {
- $target = $this->escapePath($target);
- // since returned stream is closed by the caller we need to create a new instance
- // since we can't re-use the same file descriptor over multiple calls
- $connection = $this->getConnection();
-
- $fh = $connection->getFileInputStream();
- $connection->write('put ' . $this->system->getFD(4) . ' ' . $target);
- $connection->write('exit');
-
- // use a close callback to ensure the upload is finished before continuing
- // this also serves as a way to keep the connection in scope
- return CallbackWrapper::wrap($fh, null, null, function () use ($connection, $target) {
- $connection->close(false); // dont terminate, give the upload some time
- });
- }
-
- /**
- * Append to stream
- * Note: smbclient does not support this (Use php-libsmbclient)
- *
- * @param string $target
- *
- * @throws \Icewind\SMB\Exception\DependencyException
- */
- public function append($target) {
- throw new DependencyException('php-libsmbclient is required for append');
- }
-
- /**
- * @param string $path
- * @param int $mode a combination of FileInfo::MODE_READONLY, FileInfo::MODE_ARCHIVE, FileInfo::MODE_SYSTEM and FileInfo::MODE_HIDDEN, FileInfo::NORMAL
- * @return mixed
- */
- public function setMode($path, $mode) {
- $modeString = '';
- foreach (self::MODE_MAP as $modeByte => $string) {
- if ($mode & $modeByte) {
- $modeString .= $string;
- }
- }
- $path = $this->escapePath($path);
-
- // first reset the mode to normal
- $cmd = 'setmode ' . $path . ' -rsha';
- $output = $this->execute($cmd);
- $this->parseOutput($output, $path);
-
- if ($mode !== FileInfo::MODE_NORMAL) {
- // then set the modes we want
- $cmd = 'setmode ' . $path . ' ' . $modeString;
- $output = $this->execute($cmd);
- return $this->parseOutput($output, $path);
- } else {
- return true;
- }
- }
-
- /**
- * @param string $path
- * @return INotifyHandler
- * @throws ConnectionException
- * @throws DependencyException
- */
- public function notify($path) {
- if (!$this->system->getStdBufPath()) { //stdbuf is required to disable smbclient's output buffering
- throw new DependencyException('stdbuf is required for usage of the notify command');
- }
- $connection = $this->getConnection(); // use a fresh connection since the notify command blocks the process
- $command = 'notify ' . $this->escapePath($path);
- $connection->write($command . PHP_EOL);
- return new NotifyHandler($connection, $path);
- }
-
- /**
- * @param string $command
- * @return array
- */
- protected function execute($command) {
- $this->connect();
- $this->connection->write($command . PHP_EOL);
- return $this->connection->read();
- }
-
- /**
- * check output for errors
- *
- * @param string[] $lines
- * @param string $path
- *
- * @return bool
- * @throws \Icewind\SMB\Exception\AlreadyExistsException
- * @throws \Icewind\SMB\Exception\AccessDeniedException
- * @throws \Icewind\SMB\Exception\NotEmptyException
- * @throws \Icewind\SMB\Exception\InvalidTypeException
- * @throws \Icewind\SMB\Exception\Exception
- * @throws NotFoundException
- */
- protected function parseOutput($lines, $path = '') {
- if (count($lines) === 0) {
- return true;
- } else {
- $this->parser->checkForError($lines, $path);
- return false;
- }
- }
-
- /**
- * @param string $string
- * @return string
- */
- protected function escape($string) {
- return escapeshellarg($string);
- }
-
- /**
- * @param string $path
- * @return string
- */
- protected function escapePath($path) {
- $this->verifyPath($path);
- if ($path === '/') {
- $path = '';
- }
- $path = str_replace('/', '\\', $path);
- $path = str_replace('"', '^"', $path);
- $path = ltrim($path, '\\');
- return '"' . $path . '"';
- }
-
- /**
- * @param string $path
- * @return string
- */
- protected function escapeLocalPath($path) {
- $path = str_replace('"', '\"', $path);
- return '"' . $path . '"';
- }
-
- protected function getAcls($path) {
- $commandPath = $this->system->getSmbcAclsPath();
- if (!$commandPath) {
- return [];
- }
-
- $command = sprintf(
- '%s %s %s %s/%s %s',
- $commandPath,
- $this->getAuthFileArgument(),
- $this->server->getAuth()->getExtraCommandLineArguments(),
- escapeshellarg('//' . $this->server->getHost()),
- escapeshellarg($this->name),
- escapeshellarg($path)
- );
- $connection = new RawConnection($command);
- $connection->writeAuthentication($this->server->getAuth()->getUsername(), $this->server->getAuth()->getPassword());
- $connection->connect();
- if (!$connection->isValid()) {
- throw new ConnectionException($connection->readLine());
- }
-
- $rawAcls = $connection->readAll();
-
- $acls = [];
- foreach ($rawAcls as $acl) {
- [$type, $acl] = explode(':', $acl, 2);
- if ($type !== 'ACL') {
- continue;
- }
- [$user, $permissions] = explode(':', $acl, 2);
- [$type, $flags, $mask] = explode('/', $permissions);
-
- $type = $type === 'ALLOWED' ? ACL::TYPE_ALLOW : ACL::TYPE_DENY;
-
- $flagsInt = 0;
- foreach (explode('|', $flags) as $flagString) {
- if ($flagString === 'OI') {
- $flagsInt += ACL::FLAG_OBJECT_INHERIT;
- } elseif ($flagString === 'CI') {
- $flagsInt += ACL::FLAG_CONTAINER_INHERIT;
- }
- }
-
- if (substr($mask, 0, 2) === '0x') {
- $maskInt = hexdec($mask);
- } else {
- $maskInt = 0;
- foreach (explode('|', $mask) as $maskString) {
- if ($maskString === 'R') {
- $maskInt += ACL::MASK_READ;
- } elseif ($maskString === 'W') {
- $maskInt += ACL::MASK_WRITE;
- } elseif ($maskString === 'X') {
- $maskInt += ACL::MASK_EXECUTE;
- } elseif ($maskString === 'D') {
- $maskInt += ACL::MASK_DELETE;
- } elseif ($maskString === 'READ') {
- $maskInt += ACL::MASK_READ + ACL::MASK_EXECUTE;
- } elseif ($maskString === 'CHANGE') {
- $maskInt += ACL::MASK_READ + ACL::MASK_EXECUTE + ACL::MASK_WRITE + ACL::MASK_DELETE;
- } elseif ($maskString === 'FULL') {
- $maskInt += ACL::MASK_READ + ACL::MASK_EXECUTE + ACL::MASK_WRITE + ACL::MASK_DELETE;
- }
- }
- }
-
- if (isset($acls[$user])) {
- $existing = $acls[$user];
- $maskInt += $existing->getMask();
- }
- $acls[$user] = new ACL($type, $flagsInt, $maskInt);
- }
-
- return $acls;
- }
-
- public function getServer(): IServer {
- return $this->server;
- }
-
- public function __destruct() {
- unset($this->connection);
- }
-}