aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/Lib')
-rw-r--r--apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/AuthMechanism.php2
-rw-r--r--apps/files_external/lib/Lib/Auth/Builtin.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/IUserProvided.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/InvalidAuth.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/NullMechanism.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php36
-rw-r--r--apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php7
-rw-r--r--apps/files_external/lib/Lib/Auth/OpenStack/OpenStackV2.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php6
-rw-r--r--apps/files_external/lib/Lib/Auth/Password/Password.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php9
-rw-r--r--apps/files_external/lib/Lib/Auth/Password/UserProvided.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/PublicKey/RSA.php4
-rw-r--r--apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php1
-rw-r--r--apps/files_external/lib/Lib/Auth/SMB/KerberosAuth.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/AmazonS3.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/Backend.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/DAV.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/FTP.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/InvalidBackend.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/LegacyBackend.php5
-rw-r--r--apps/files_external/lib/Lib/Backend/Local.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/OwnCloud.php4
-rw-r--r--apps/files_external/lib/Lib/Backend/SFTP.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/SFTP_Key.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/SMB.php52
-rw-r--r--apps/files_external/lib/Lib/Backend/SMB_OC.php1
-rw-r--r--apps/files_external/lib/Lib/Backend/Swift.php1
-rw-r--r--apps/files_external/lib/Lib/Config/IAuthMechanismProvider.php1
-rw-r--r--apps/files_external/lib/Lib/Config/IBackendProvider.php1
-rw-r--r--apps/files_external/lib/Lib/DefinitionParameter.php3
-rw-r--r--apps/files_external/lib/Lib/DependencyTrait.php1
-rw-r--r--apps/files_external/lib/Lib/FrontendDefinitionTrait.php1
-rw-r--r--apps/files_external/lib/Lib/IFrontendDefinition.php1
-rw-r--r--apps/files_external/lib/Lib/IIdentifier.php1
-rw-r--r--apps/files_external/lib/Lib/IdentifierTrait.php1
-rw-r--r--apps/files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php1
-rw-r--r--apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php1
-rw-r--r--apps/files_external/lib/Lib/MissingDependency.php14
-rw-r--r--apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php1
-rw-r--r--apps/files_external/lib/Lib/PersonalMount.php1
-rw-r--r--apps/files_external/lib/Lib/PriorityTrait.php1
-rw-r--r--apps/files_external/lib/Lib/SessionStorageWrapper.php1
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php6
-rw-r--r--apps/files_external/lib/Lib/Storage/FTP.php12
-rw-r--r--apps/files_external/lib/Lib/Storage/OwnCloud.php1
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php29
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php21
-rw-r--r--apps/files_external/lib/Lib/Storage/StreamWrapper.php1
-rw-r--r--apps/files_external/lib/Lib/Storage/Swift.php55
-rw-r--r--apps/files_external/lib/Lib/StorageConfig.php1
-rw-r--r--apps/files_external/lib/Lib/StorageModifierTrait.php1
-rw-r--r--apps/files_external/lib/Lib/VisibilityTrait.php1
56 files changed, 194 insertions, 111 deletions
diff --git a/apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php b/apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php
index 04019404a90..c86c88a13d7 100644
--- a/apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php
+++ b/apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Auth/AuthMechanism.php b/apps/files_external/lib/Lib/Auth/AuthMechanism.php
index ebdf768cda3..7b0544100fb 100644
--- a/apps/files_external/lib/Lib/Auth/AuthMechanism.php
+++ b/apps/files_external/lib/Lib/Auth/AuthMechanism.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -39,7 +40,6 @@ class AuthMechanism implements \JsonSerializable, IIdentifier, IFrontendDefiniti
public const SCHEME_NULL = 'null';
public const SCHEME_BUILTIN = 'builtin';
public const SCHEME_PASSWORD = 'password';
- public const SCHEME_OAUTH1 = 'oauth1';
public const SCHEME_OAUTH2 = 'oauth2';
public const SCHEME_PUBLICKEY = 'publickey';
public const SCHEME_OPENSTACK = 'openstack';
diff --git a/apps/files_external/lib/Lib/Auth/Builtin.php b/apps/files_external/lib/Lib/Auth/Builtin.php
index cd4b8a22af4..8e12a6daca6 100644
--- a/apps/files_external/lib/Lib/Auth/Builtin.php
+++ b/apps/files_external/lib/Lib/Auth/Builtin.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Auth/IUserProvided.php b/apps/files_external/lib/Lib/Auth/IUserProvided.php
index 60f978f673d..2350d7f6db4 100644
--- a/apps/files_external/lib/Lib/Auth/IUserProvided.php
+++ b/apps/files_external/lib/Lib/Auth/IUserProvided.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
diff --git a/apps/files_external/lib/Lib/Auth/InvalidAuth.php b/apps/files_external/lib/Lib/Auth/InvalidAuth.php
index d5a6fdcbe5d..2af24f1ea07 100644
--- a/apps/files_external/lib/Lib/Auth/InvalidAuth.php
+++ b/apps/files_external/lib/Lib/Auth/InvalidAuth.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud GmbH.
diff --git a/apps/files_external/lib/Lib/Auth/NullMechanism.php b/apps/files_external/lib/Lib/Auth/NullMechanism.php
index 7847c111415..8e2e5b656b2 100644
--- a/apps/files_external/lib/Lib/Auth/NullMechanism.php
+++ b/apps/files_external/lib/Lib/Auth/NullMechanism.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php b/apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php
deleted file mode 100644
index b215201b4f4..00000000000
--- a/apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
- * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
- * SPDX-License-Identifier: AGPL-3.0-only
- */
-namespace OCA\Files_External\Lib\Auth\OAuth1;
-
-use OCA\Files_External\Lib\Auth\AuthMechanism;
-use OCA\Files_External\Lib\DefinitionParameter;
-use OCP\IL10N;
-
-/**
- * OAuth1 authentication
- */
-class OAuth1 extends AuthMechanism {
- public function __construct(IL10N $l) {
- $this
- ->setIdentifier('oauth1::oauth1')
- ->setScheme(self::SCHEME_OAUTH1)
- ->setText($l->t('OAuth1'))
- ->addParameters([
- (new DefinitionParameter('configured', 'configured'))
- ->setType(DefinitionParameter::VALUE_HIDDEN),
- new DefinitionParameter('app_key', $l->t('App key')),
- (new DefinitionParameter('app_secret', $l->t('App secret')))
- ->setType(DefinitionParameter::VALUE_PASSWORD),
- (new DefinitionParameter('token', 'token'))
- ->setType(DefinitionParameter::VALUE_HIDDEN),
- (new DefinitionParameter('token_secret', 'token_secret'))
- ->setType(DefinitionParameter::VALUE_HIDDEN),
- ])
- ->addCustomJs('oauth1')
- ;
- }
-}
diff --git a/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php b/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php
index 6b41fef90d5..beaf73c2344 100644
--- a/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php
+++ b/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -21,12 +22,14 @@ class OAuth2 extends AuthMechanism {
->setText($l->t('OAuth2'))
->addParameters([
(new DefinitionParameter('configured', 'configured'))
- ->setType(DefinitionParameter::VALUE_HIDDEN),
+ ->setType(DefinitionParameter::VALUE_TEXT)
+ ->setFlag(DefinitionParameter::FLAG_HIDDEN),
new DefinitionParameter('client_id', $l->t('Client ID')),
(new DefinitionParameter('client_secret', $l->t('Client secret')))
->setType(DefinitionParameter::VALUE_PASSWORD),
(new DefinitionParameter('token', 'token'))
- ->setType(DefinitionParameter::VALUE_HIDDEN),
+ ->setType(DefinitionParameter::VALUE_PASSWORD)
+ ->setFlag(DefinitionParameter::FLAG_HIDDEN),
])
->addCustomJs('oauth2')
;
diff --git a/apps/files_external/lib/Lib/Auth/OpenStack/OpenStackV2.php b/apps/files_external/lib/Lib/Auth/OpenStack/OpenStackV2.php
index 3be4169831b..3b1c9f123af 100644
--- a/apps/files_external/lib/Lib/Auth/OpenStack/OpenStackV2.php
+++ b/apps/files_external/lib/Lib/Auth/OpenStack/OpenStackV2.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php b/apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php
index a47d2ea0ca8..b1d1068e586 100644
--- a/apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php
+++ b/apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php b/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php
index ee23c28b993..916b496b506 100644
--- a/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php
+++ b/apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2015 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php b/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php
index 176e1877d94..ce38140b6ee 100644
--- a/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php
+++ b/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2015 ownCloud, Inc.
@@ -7,6 +8,7 @@
namespace OCA\Files_External\Lib\Auth\Password;
use OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Listener\StorePasswordListener;
@@ -41,6 +43,10 @@ class LoginCredentials extends AuthMechanism {
->setScheme(self::SCHEME_PASSWORD)
->setText($l->t('Log-in credentials, save in database'))
->addParameters([
+ (new DefinitionParameter('password', $l->t('Password')))
+ ->setType(DefinitionParameter::VALUE_PASSWORD)
+ ->setFlag(DefinitionParameter::FLAG_HIDDEN)
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
]);
$eventDispatcher->addServiceListener(UserLoggedInEvent::class, StorePasswordListener::class);
diff --git a/apps/files_external/lib/Lib/Auth/Password/Password.php b/apps/files_external/lib/Lib/Auth/Password/Password.php
index e3393233840..d4291148e3e 100644
--- a/apps/files_external/lib/Lib/Auth/Password/Password.php
+++ b/apps/files_external/lib/Lib/Auth/Password/Password.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
index ced43ebf357..8f161073771 100644
--- a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
+++ b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -7,6 +8,7 @@
namespace OCA\Files_External\Lib\Auth\Password;
use OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
use OCA\Files_External\Lib\SessionStorageWrapper;
use OCA\Files_External\Lib\StorageConfig;
@@ -29,7 +31,12 @@ class SessionCredentials extends AuthMechanism {
$this->setIdentifier('password::sessioncredentials')
->setScheme(self::SCHEME_PASSWORD)
->setText($l->t('Log-in credentials, save in session'))
- ->addParameters([]);
+ ->addParameters([
+ (new DefinitionParameter('password', $l->t('Password')))
+ ->setType(DefinitionParameter::VALUE_PASSWORD)
+ ->setFlag(DefinitionParameter::FLAG_HIDDEN)
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
+ ]);
}
/**
diff --git a/apps/files_external/lib/Lib/Auth/Password/UserProvided.php b/apps/files_external/lib/Lib/Auth/Password/UserProvided.php
index 7f937cf14c1..b158392f6eb 100644
--- a/apps/files_external/lib/Lib/Auth/Password/UserProvided.php
+++ b/apps/files_external/lib/Lib/Auth/Password/UserProvided.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2015 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
index 2371ce0a219..ad95c743d2d 100644
--- a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
+++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -31,7 +32,8 @@ class RSA extends AuthMechanism {
new DefinitionParameter('user', $l->t('Login')),
new DefinitionParameter('public_key', $l->t('Public key')),
(new DefinitionParameter('private_key', 'private_key'))
- ->setType(DefinitionParameter::VALUE_HIDDEN),
+ ->setType(DefinitionParameter::VALUE_PASSWORD)
+ ->setFlag(DefinitionParameter::FLAG_HIDDEN),
])
->addCustomJs('public_key')
;
diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php
index 8c2e2f3d6ec..8f58b71d5ac 100644
--- a/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php
+++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/files_external/lib/Lib/Auth/SMB/KerberosAuth.php b/apps/files_external/lib/Lib/Auth/SMB/KerberosAuth.php
index e7a0884d1bd..9210209192a 100644
--- a/apps/files_external/lib/Lib/Auth/SMB/KerberosAuth.php
+++ b/apps/files_external/lib/Lib/Auth/SMB/KerberosAuth.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/files_external/lib/Lib/Backend/AmazonS3.php b/apps/files_external/lib/Lib/Backend/AmazonS3.php
index f71ca40cdfc..464b03b55e0 100644
--- a/apps/files_external/lib/Lib/Backend/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Backend/AmazonS3.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Backend/Backend.php b/apps/files_external/lib/Lib/Backend/Backend.php
index f965e246d42..f7500ee24a4 100644
--- a/apps/files_external/lib/Lib/Backend/Backend.php
+++ b/apps/files_external/lib/Lib/Backend/Backend.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Backend/DAV.php b/apps/files_external/lib/Lib/Backend/DAV.php
index 9eb206f0272..dea9e7c5e77 100644
--- a/apps/files_external/lib/Lib/Backend/DAV.php
+++ b/apps/files_external/lib/Lib/Backend/DAV.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Backend/FTP.php b/apps/files_external/lib/Lib/Backend/FTP.php
index cdf7d187b4d..72a8184c9b9 100644
--- a/apps/files_external/lib/Lib/Backend/FTP.php
+++ b/apps/files_external/lib/Lib/Backend/FTP.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Backend/InvalidBackend.php b/apps/files_external/lib/Lib/Backend/InvalidBackend.php
index 6082d46bd67..48912c0e49e 100644
--- a/apps/files_external/lib/Lib/Backend/InvalidBackend.php
+++ b/apps/files_external/lib/Lib/Backend/InvalidBackend.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud GmbH.
diff --git a/apps/files_external/lib/Lib/Backend/LegacyBackend.php b/apps/files_external/lib/Lib/Backend/LegacyBackend.php
index 11396913fbd..9c7e5b01bc3 100644
--- a/apps/files_external/lib/Lib/Backend/LegacyBackend.php
+++ b/apps/files_external/lib/Lib/Backend/LegacyBackend.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -52,10 +53,6 @@ class LegacyBackend extends Backend {
$type = DefinitionParameter::VALUE_PASSWORD;
$placeholder = substr($placeholder, 1);
break;
- case '#':
- $type = DefinitionParameter::VALUE_HIDDEN;
- $placeholder = substr($placeholder, 1);
- break;
}
$this->addParameter((new DefinitionParameter($name, $placeholder))
->setType($type)
diff --git a/apps/files_external/lib/Lib/Backend/Local.php b/apps/files_external/lib/Lib/Backend/Local.php
index 2902ba770c6..56940b8e83b 100644
--- a/apps/files_external/lib/Lib/Backend/Local.php
+++ b/apps/files_external/lib/Lib/Backend/Local.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Backend/OwnCloud.php b/apps/files_external/lib/Lib/Backend/OwnCloud.php
index c3e16dd5404..0c0e2c6d300 100644
--- a/apps/files_external/lib/Lib/Backend/OwnCloud.php
+++ b/apps/files_external/lib/Lib/Backend/OwnCloud.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -25,9 +26,6 @@ class OwnCloud extends Backend {
(new DefinitionParameter('secure', $l->t('Secure https://')))
->setType(DefinitionParameter::VALUE_BOOLEAN)
->setDefaultValue(true),
- (new DefinitionParameter('password', $l->t('Password')))
- ->setFlag(DefinitionParameter::FLAG_OPTIONAL)
- ->setType(DefinitionParameter::VALUE_PASSWORD),
])
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
->setLegacyAuthMechanism($legacyAuth)
diff --git a/apps/files_external/lib/Lib/Backend/SFTP.php b/apps/files_external/lib/Lib/Backend/SFTP.php
index 93a5d87a5ff..0926cf7fd93 100644
--- a/apps/files_external/lib/Lib/Backend/SFTP.php
+++ b/apps/files_external/lib/Lib/Backend/SFTP.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Backend/SFTP_Key.php b/apps/files_external/lib/Lib/Backend/SFTP_Key.php
index a657dce66e5..278fae3fba7 100644
--- a/apps/files_external/lib/Lib/Backend/SFTP_Key.php
+++ b/apps/files_external/lib/Lib/Backend/SFTP_Key.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Backend/SMB.php b/apps/files_external/lib/Lib/Backend/SMB.php
index c4a68fea6e1..e86ad98880c 100644
--- a/apps/files_external/lib/Lib/Backend/SMB.php
+++ b/apps/files_external/lib/Lib/Backend/SMB.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -8,21 +9,22 @@
namespace OCA\Files_External\Lib\Backend;
use Icewind\SMB\BasicAuth;
-use Icewind\SMB\KerberosApacheAuth;
use Icewind\SMB\KerberosAuth;
+use Icewind\SMB\KerberosTicket;
+use Icewind\SMB\Native\NativeServer;
+use Icewind\SMB\Wrapped\Server;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Auth\Password\Password;
use OCA\Files_External\Lib\Auth\SMB\KerberosApacheAuth as KerberosApacheAuthMechanism;
use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
-use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
+use OCA\Files_External\Lib\MissingDependency;
+use OCA\Files_External\Lib\Storage\SystemBridge;
use OCA\Files_External\Lib\StorageConfig;
use OCP\IL10N;
use OCP\IUser;
class SMB extends Backend {
- use LegacyDependencyCheckPolyfill;
-
public function __construct(IL10N $l, Password $legacyAuth) {
$this
->setIdentifier('smb')
@@ -49,18 +51,16 @@ class SMB extends Backend {
->setFlag(DefinitionParameter::FLAG_OPTIONAL)
->setTooltip($l->t("Check the ACL's of each file or folder inside a directory to filter out items where the account has no read permissions, comes with a performance penalty")),
(new DefinitionParameter('timeout', $l->t('Timeout')))
- ->setType(DefinitionParameter::VALUE_HIDDEN)
- ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
+ ->setType(DefinitionParameter::VALUE_TEXT)
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL)
+ ->setFlag(DefinitionParameter::FLAG_HIDDEN),
])
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
->addAuthScheme(AuthMechanism::SCHEME_SMB)
->setLegacyAuthMechanism($legacyAuth);
}
- /**
- * @return void
- */
- public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
+ public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null): void {
$auth = $storage->getAuthMechanism();
if ($auth->getScheme() === AuthMechanism::SCHEME_PASSWORD) {
if (!is_string($storage->getBackendOption('user')) || !is_string($storage->getBackendOption('password'))) {
@@ -82,33 +82,33 @@ class SMB extends Backend {
throw new \InvalidArgumentException('invalid authentication backend');
}
$credentialsStore = $auth->getCredentialsStore();
- $kerbAuth = new KerberosApacheAuth();
+ $kerbAuth = new KerberosAuth();
+ $kerbAuth->setTicket(KerberosTicket::fromEnv());
// check if a kerberos ticket is available, else fallback to session credentials
- if ($kerbAuth->checkTicket()) {
+ if ($kerbAuth->getTicket()?->isValid()) {
$smbAuth = $kerbAuth;
} else {
try {
$credentials = $credentialsStore->getLoginCredentials();
- $user = $credentials->getLoginName();
+ $loginName = $credentials->getLoginName();
$pass = $credentials->getPassword();
- preg_match('/(.*)@(.*)/', $user, $matches);
+ preg_match('/(.*)@(.*)/', $loginName, $matches);
$realm = $storage->getBackendOption('default_realm');
if (empty($realm)) {
$realm = 'WORKGROUP';
}
if (count($matches) === 0) {
- $username = $user;
+ $username = $loginName;
$workgroup = $realm;
} else {
- $username = $matches[1];
- $workgroup = $matches[2];
+ [, $username, $workgroup] = $matches;
}
$smbAuth = new BasicAuth(
$username,
$workgroup,
$pass
);
- } catch (\Exception $e) {
+ } catch (\Exception) {
throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
}
}
@@ -121,4 +121,20 @@ class SMB extends Backend {
$storage->setBackendOption('auth', $smbAuth);
}
+
+ public function checkDependencies(): array {
+ $system = \OCP\Server::get(SystemBridge::class);
+ if (NativeServer::available($system)) {
+ return [];
+ } elseif (Server::available($system)) {
+ $missing = new MissingDependency('php-smbclient');
+ $missing->setOptional(true);
+ $missing->setMessage('The php-smbclient library provides improved compatibility and performance for SMB storages.');
+ return [$missing];
+ } else {
+ $missing = new MissingDependency('php-smbclient');
+ $missing->setMessage('Either the php-smbclient library (preferred) or the smbclient binary is required for SMB storages.');
+ return [$missing, new MissingDependency('smbclient')];
+ }
+ }
}
diff --git a/apps/files_external/lib/Lib/Backend/SMB_OC.php b/apps/files_external/lib/Lib/Backend/SMB_OC.php
index 55edec8a464..bcb8d0fbf16 100644
--- a/apps/files_external/lib/Lib/Backend/SMB_OC.php
+++ b/apps/files_external/lib/Lib/Backend/SMB_OC.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Backend/Swift.php b/apps/files_external/lib/Lib/Backend/Swift.php
index 386604e6e1d..37527ba3dbb 100644
--- a/apps/files_external/lib/Lib/Backend/Swift.php
+++ b/apps/files_external/lib/Lib/Backend/Swift.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Config/IAuthMechanismProvider.php b/apps/files_external/lib/Lib/Config/IAuthMechanismProvider.php
index 1d0cc3cca78..0c2e90a243c 100644
--- a/apps/files_external/lib/Lib/Config/IAuthMechanismProvider.php
+++ b/apps/files_external/lib/Lib/Config/IAuthMechanismProvider.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Config/IBackendProvider.php b/apps/files_external/lib/Lib/Config/IBackendProvider.php
index 3f66966950d..44c460c3138 100644
--- a/apps/files_external/lib/Lib/Config/IBackendProvider.php
+++ b/apps/files_external/lib/Lib/Config/IBackendProvider.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/DefinitionParameter.php b/apps/files_external/lib/Lib/DefinitionParameter.php
index 1e611edd1ed..a73dd2df967 100644
--- a/apps/files_external/lib/Lib/DefinitionParameter.php
+++ b/apps/files_external/lib/Lib/DefinitionParameter.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -18,12 +19,12 @@ class DefinitionParameter implements \JsonSerializable {
public const VALUE_TEXT = 0;
public const VALUE_BOOLEAN = 1;
public const VALUE_PASSWORD = 2;
- public const VALUE_HIDDEN = 3;
/** Flag constants */
public const FLAG_NONE = 0;
public const FLAG_OPTIONAL = 1;
public const FLAG_USER_PROVIDED = 2;
+ public const FLAG_HIDDEN = 4;
/** @var string human-readable parameter tooltip */
private string $tooltip = '';
diff --git a/apps/files_external/lib/Lib/DependencyTrait.php b/apps/files_external/lib/Lib/DependencyTrait.php
index 1d112532128..644132b82bc 100644
--- a/apps/files_external/lib/Lib/DependencyTrait.php
+++ b/apps/files_external/lib/Lib/DependencyTrait.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/FrontendDefinitionTrait.php b/apps/files_external/lib/Lib/FrontendDefinitionTrait.php
index 5602345fe89..0f280d1d486 100644
--- a/apps/files_external/lib/Lib/FrontendDefinitionTrait.php
+++ b/apps/files_external/lib/Lib/FrontendDefinitionTrait.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/IFrontendDefinition.php b/apps/files_external/lib/Lib/IFrontendDefinition.php
index 0184d5f536c..c8b06a1c30b 100644
--- a/apps/files_external/lib/Lib/IFrontendDefinition.php
+++ b/apps/files_external/lib/Lib/IFrontendDefinition.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/files_external/lib/Lib/IIdentifier.php b/apps/files_external/lib/Lib/IIdentifier.php
index df77d02b542..0677409a3cf 100644
--- a/apps/files_external/lib/Lib/IIdentifier.php
+++ b/apps/files_external/lib/Lib/IIdentifier.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/files_external/lib/Lib/IdentifierTrait.php b/apps/files_external/lib/Lib/IdentifierTrait.php
index ff7bb8a465e..f5ffde32307 100644
--- a/apps/files_external/lib/Lib/IdentifierTrait.php
+++ b/apps/files_external/lib/Lib/IdentifierTrait.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php b/apps/files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php
index b2400f4be28..1e872b35072 100644
--- a/apps/files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php
+++ b/apps/files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php b/apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php
index 313d4ae8cb2..f6311fae83e 100644
--- a/apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php
+++ b/apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/MissingDependency.php b/apps/files_external/lib/Lib/MissingDependency.php
index 5c2c6880f23..c2da7fcadbf 100644
--- a/apps/files_external/lib/Lib/MissingDependency.php
+++ b/apps/files_external/lib/Lib/MissingDependency.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -12,13 +13,14 @@ namespace OCA\Files_External\Lib;
class MissingDependency {
/** @var string|null Custom message */
- private $message = null;
+ private ?string $message = null;
+ private bool $optional = false;
/**
* @param string $dependency
*/
public function __construct(
- private $dependency,
+ private readonly string $dependency,
) {
}
@@ -38,4 +40,12 @@ class MissingDependency {
$this->message = $message;
return $this;
}
+
+ public function isOptional(): bool {
+ return $this->optional;
+ }
+
+ public function setOptional(bool $optional): void {
+ $this->optional = $optional;
+ }
}
diff --git a/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php b/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php
index deaf005e2c6..2812df6ad6a 100644
--- a/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php
+++ b/apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/files_external/lib/Lib/PersonalMount.php b/apps/files_external/lib/Lib/PersonalMount.php
index 01daddd7e2a..d9dbddd1449 100644
--- a/apps/files_external/lib/Lib/PersonalMount.php
+++ b/apps/files_external/lib/Lib/PersonalMount.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/PriorityTrait.php b/apps/files_external/lib/Lib/PriorityTrait.php
index fef308a56dd..fad2c07e58c 100644
--- a/apps/files_external/lib/Lib/PriorityTrait.php
+++ b/apps/files_external/lib/Lib/PriorityTrait.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/SessionStorageWrapper.php b/apps/files_external/lib/Lib/SessionStorageWrapper.php
index 06bece3bf7c..8754041b2fa 100644
--- a/apps/files_external/lib/Lib/SessionStorageWrapper.php
+++ b/apps/files_external/lib/Lib/SessionStorageWrapper.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 1a866e8c22b..5dc9e114532 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -20,6 +21,7 @@ use OCP\Files\FileInfo;
use OCP\Files\IMimeTypeDetector;
use OCP\ICache;
use OCP\ICacheFactory;
+use OCP\ITempManager;
use OCP\Server;
use Psr\Log\LoggerInterface;
@@ -451,7 +453,7 @@ class AmazonS3 extends Common {
}
case 'w':
case 'wb':
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
+ $tmpFile = Server::get(ITempManager::class)->getTemporaryFile();
$handle = fopen($tmpFile, 'w');
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile): void {
@@ -472,7 +474,7 @@ class AmazonS3 extends Common {
} else {
$ext = '';
}
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
+ $tmpFile = Server::get(ITempManager::class)->getTemporaryFile($ext);
if ($this->file_exists($path)) {
$source = $this->readObject($path);
file_put_contents($tmpFile, $source);
diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php
index 51b269b3eb0..944964de7a6 100644
--- a/apps/files_external/lib/Lib/Storage/FTP.php
+++ b/apps/files_external/lib/Lib/Storage/FTP.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
@@ -12,7 +13,10 @@ use OC\Files\Storage\Common;
use OC\Files\Storage\PolyFill\CopyDirectory;
use OCP\Constants;
use OCP\Files\FileInfo;
+use OCP\Files\IMimeTypeDetector;
use OCP\Files\StorageNotAvailableException;
+use OCP\ITempManager;
+use OCP\Server;
use Psr\Log\LoggerInterface;
class FTP extends Common {
@@ -101,7 +105,7 @@ class FTP extends Common {
if ($this->is_dir($path)) {
$list = $this->getConnection()->mlsd($this->buildPath($path));
if (!$list) {
- \OC::$server->get(LoggerInterface::class)->warning("Unable to get last modified date for ftp folder ($path), failed to list folder contents");
+ Server::get(LoggerInterface::class)->warning("Unable to get last modified date for ftp folder ($path), failed to list folder contents");
return time();
}
$currentDir = current(array_filter($list, function ($item) {
@@ -115,7 +119,7 @@ class FTP extends Common {
}
return $time->getTimestamp();
} else {
- \OC::$server->get(LoggerInterface::class)->warning("Unable to get last modified date for ftp folder ($path), folder contents doesn't include current folder");
+ Server::get(LoggerInterface::class)->warning("Unable to get last modified date for ftp folder ($path), folder contents doesn't include current folder");
return time();
}
} else {
@@ -270,7 +274,7 @@ class FTP extends Common {
if (!$this->isCreatable(dirname($path))) {
return false;
}
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
+ $tmpFile = Server::get(ITempManager::class)->getTemporaryFile();
}
$source = fopen($tmpFile, $mode);
return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $path): void {
@@ -322,7 +326,7 @@ class FTP extends Common {
public function getDirectoryContent(string $directory): \Traversable {
$files = $this->getConnection()->mlsd($this->buildPath($directory));
- $mimeTypeDetector = \OC::$server->getMimeTypeDetector();
+ $mimeTypeDetector = Server::get(IMimeTypeDetector::class);
foreach ($files as $file) {
$name = $file['name'];
diff --git a/apps/files_external/lib/Lib/Storage/OwnCloud.php b/apps/files_external/lib/Lib/Storage/OwnCloud.php
index 1bcf19b460e..12c305de750 100644
--- a/apps/files_external/lib/Lib/Storage/OwnCloud.php
+++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index 44073beedec..a2f5bafcca1 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -6,14 +7,17 @@
*/
namespace OCA\Files_External\Lib\Storage;
+use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\CountWrapper;
use Icewind\Streams\IteratorDirectory;
use Icewind\Streams\RetryWrapper;
use OC\Files\Storage\Common;
use OC\Files\View;
+use OCP\Cache\CappedMemoryCache;
use OCP\Constants;
use OCP\Files\FileInfo;
use OCP\Files\IMimeTypeDetector;
+use OCP\Server;
use phpseclib\Net\SFTP\Stream;
/**
@@ -32,6 +36,8 @@ class SFTP extends Common {
* @var \phpseclib\Net\SFTP
*/
protected $client;
+ private CappedMemoryCache $knownMTimes;
+
private IMimeTypeDetector $mimeTypeDetector;
public const COPY_CHUNK_SIZE = 8 * 1024 * 1024;
@@ -87,7 +93,10 @@ class SFTP extends Common {
$this->root = '/' . ltrim($this->root, '/');
$this->root = rtrim($this->root, '/') . '/';
- $this->mimeTypeDetector = \OC::$server->get(IMimeTypeDetector::class);
+
+ $this->knownMTimes = new CappedMemoryCache();
+
+ $this->mimeTypeDetector = Server::get(IMimeTypeDetector::class);
}
/**
@@ -297,6 +306,7 @@ class SFTP extends Common {
}
public function fopen(string $path, string $mode) {
+ $path = $this->cleanPath($path);
try {
$absPath = $this->absPath($path);
$connection = $this->getConnection();
@@ -317,7 +327,13 @@ class SFTP extends Common {
// the SFTPWriteStream doesn't go through the "normal" methods so it doesn't clear the stat cache.
$connection->_remove_from_stat_cache($absPath);
$context = stream_context_create(['sftp' => ['session' => $connection]]);
- return fopen('sftpwrite://' . trim($absPath, '/'), 'w', false, $context);
+ $fh = fopen('sftpwrite://' . trim($absPath, '/'), 'w', false, $context);
+ if ($fh) {
+ $fh = CallbackWrapper::wrap($fh, null, null, function () use ($path): void {
+ $this->knownMTimes->set($path, time());
+ });
+ }
+ return $fh;
case 'a':
case 'ab':
case 'r+':
@@ -343,14 +359,13 @@ class SFTP extends Common {
return false;
}
if (!$this->file_exists($path)) {
- $this->getConnection()->put($this->absPath($path), '');
+ return $this->getConnection()->put($this->absPath($path), '');
} else {
return false;
}
} catch (\Exception $e) {
return false;
}
- return true;
}
/**
@@ -379,11 +394,17 @@ class SFTP extends Common {
*/
public function stat(string $path): array|false {
try {
+ $path = $this->cleanPath($path);
$stat = $this->getConnection()->stat($this->absPath($path));
$mtime = isset($stat['mtime']) ? (int)$stat['mtime'] : -1;
$size = isset($stat['size']) ? (int)$stat['size'] : 0;
+ // the mtime can't be less than when we last touched it
+ if ($knownMTime = $this->knownMTimes->get($path)) {
+ $mtime = max($mtime, $knownMTime);
+ }
+
return [
'mtime' => $mtime,
'size' => $size,
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index ef203021566..8f8750864e1 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -31,12 +32,14 @@ use OCA\Files_External\Lib\Notify\SMBNotifyHandler;
use OCP\Cache\CappedMemoryCache;
use OCP\Constants;
use OCP\Files\EntityTooLargeException;
+use OCP\Files\IMimeTypeDetector;
use OCP\Files\Notify\IChange;
use OCP\Files\Notify\IRenameChange;
use OCP\Files\NotPermittedException;
use OCP\Files\Storage\INotifyStorage;
use OCP\Files\StorageAuthException;
use OCP\Files\StorageNotAvailableException;
+use OCP\ITempManager;
use Psr\Log\LoggerInterface;
class SMB extends Common implements INotifyStorage {
@@ -196,7 +199,7 @@ class SMB extends Common implements INotifyStorage {
try {
$acls = $file->getAcls();
} catch (Exception $e) {
- $this->logger->error('Error while getting file acls', ['exception' => $e]);
+ $this->logger->warning('Error while getting file acls', ['exception' => $e]);
return null;
}
foreach ($acls as $user => $acl) {
@@ -333,7 +336,7 @@ class SMB extends Common implements INotifyStorage {
if ($retry) {
return $this->stat($path, false);
} else {
- throw $e;
+ throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
}
}
if ($this->remoteIsShare() && $this->isRootDir($path)) {
@@ -424,6 +427,7 @@ class SMB extends Common implements INotifyStorage {
case 'r':
case 'rb':
if (!$this->file_exists($path)) {
+ $this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', file doesn\'t exist.');
return false;
}
return $this->share->read($fullPath);
@@ -451,14 +455,16 @@ class SMB extends Common implements INotifyStorage {
}
if ($this->file_exists($path)) {
if (!$this->isUpdatable($path)) {
+ $this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', file not updatable.');
return false;
}
$tmpFile = $this->getCachedFile($path);
} else {
if (!$this->isCreatable(dirname($path))) {
+ $this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', parent directory not writable.');
return false;
}
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
+ $tmpFile = \OCP\Server::get(ITempManager::class)->getTemporaryFile($ext);
}
$source = fopen($tmpFile, $mode);
$share = $this->share;
@@ -470,13 +476,16 @@ class SMB extends Common implements INotifyStorage {
}
return false;
} catch (NotFoundException $e) {
+ $this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', not found.', ['exception' => $e]);
return false;
} catch (ForbiddenException $e) {
+ $this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', forbidden.', ['exception' => $e]);
return false;
} catch (OutOfSpaceException $e) {
+ $this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', out of space.', ['exception' => $e]);
throw new EntityTooLargeException('not enough available space to create file', 0, $e);
} catch (ConnectException $e) {
- $this->logger->error('Error while opening file', ['exception' => $e]);
+ $this->logger->error('Error while opening file ' . $path . ' on ' . $this->getId(), ['exception' => $e]);
throw new StorageNotAvailableException($e->getMessage(), (int)$e->getCode(), $e);
}
}
@@ -553,7 +562,7 @@ class SMB extends Common implements INotifyStorage {
if ($fileInfo->isDirectory()) {
$data['mimetype'] = 'httpd/unix-directory';
} else {
- $data['mimetype'] = \OC::$server->getMimeTypeDetector()->detectPath($fileInfo->getPath());
+ $data['mimetype'] = \OCP\Server::get(IMimeTypeDetector::class)->detectPath($fileInfo->getPath());
}
$data['mtime'] = $fileInfo->getMTime();
if ($fileInfo->isDirectory()) {
@@ -625,7 +634,7 @@ class SMB extends Common implements INotifyStorage {
// Case sensitive filesystem doesn't matter for root directory
if ($this->caseSensitive === false && $path !== '') {
$filename = basename($path);
- $siblings = $this->getDirectoryContent(dirname($this->buildPath($path)));
+ $siblings = $this->getDirectoryContent(dirname($path));
foreach ($siblings as $sibling) {
if ($sibling['name'] === $filename) {
return true;
diff --git a/apps/files_external/lib/Lib/Storage/StreamWrapper.php b/apps/files_external/lib/Lib/Storage/StreamWrapper.php
index 0490acc98e1..1272b9d4d8a 100644
--- a/apps/files_external/lib/Lib/Storage/StreamWrapper.php
+++ b/apps/files_external/lib/Lib/Storage/StreamWrapper.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php
index cb72ab8c070..e80570f14ba 100644
--- a/apps/files_external/lib/Lib/Storage/Swift.php
+++ b/apps/files_external/lib/Lib/Storage/Swift.php
@@ -21,6 +21,9 @@ use OCP\Files\StorageAuthException;
use OCP\Files\StorageBadConfigException;
use OCP\Files\StorageNotAvailableException;
use OCP\ICache;
+use OCP\ICacheFactory;
+use OCP\ITempManager;
+use OCP\Server;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\ObjectStore\v1\Models\Container;
use OpenStack\ObjectStore\v1\Models\StorageObject;
@@ -101,7 +104,7 @@ class Swift extends Common {
} catch (BadResponseError $e) {
// Expected response is "404 Not Found", so only log if it isn't
if ($e->getResponse()->getStatusCode() !== 404) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -163,13 +166,13 @@ class Swift extends Common {
// FIXME: private class...
$this->objectCache = new CappedMemoryCache();
$this->connectionFactory = new SwiftFactory(
- \OC::$server->getMemCacheFactory()->createDistributed('swift/'),
+ Server::get(ICacheFactory::class)->createDistributed('swift/'),
$this->params,
- \OC::$server->get(LoggerInterface::class)
+ Server::get(LoggerInterface::class)
);
$this->objectStore = new \OC\Files\ObjectStore\Swift($this->params, $this->connectionFactory);
$this->bucket = $parameters['bucket'];
- $this->mimeDetector = \OC::$server->get(IMimeTypeDetector::class);
+ $this->mimeDetector = Server::get(IMimeTypeDetector::class);
}
public function mkdir(string $path): bool {
@@ -193,7 +196,7 @@ class Swift extends Common {
// with all properties
$this->objectCache->remove($path);
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -237,7 +240,7 @@ class Swift extends Common {
$this->objectStore->deleteObject($path . '/');
$this->objectCache->remove($path . '/');
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -275,7 +278,7 @@ class Swift extends Common {
return IteratorDirectory::wrap($files);
} catch (\Exception $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -285,7 +288,6 @@ class Swift extends Common {
public function stat(string $path): array|false {
$path = $this->normalizePath($path);
-
if ($path === '.') {
$path = '';
} elseif ($this->is_dir($path)) {
@@ -298,29 +300,30 @@ class Swift extends Common {
return false;
}
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
return false;
}
- $dateTime = $object->lastModified ? \DateTime::createFromFormat(\DateTime::RFC1123, $object->lastModified) : false;
- $mtime = $dateTime ? $dateTime->getTimestamp() : null;
- $objectMetadata = $object->getMetadata();
- if (isset($objectMetadata['timestamp'])) {
- $mtime = $objectMetadata['timestamp'];
+ $mtime = null;
+ if (!empty($object->lastModified)) {
+ $dateTime = \DateTime::createFromFormat(\DateTime::RFC1123, $object->lastModified);
+ if ($dateTime !== false) {
+ $mtime = $dateTime->getTimestamp();
+ }
}
- if (!empty($mtime)) {
- $mtime = floor($mtime);
+ if (is_numeric($object->getMetadata()['timestamp'] ?? null)) {
+ $mtime = (float)$object->getMetadata()['timestamp'];
}
- $stat = [];
- $stat['size'] = (int)$object->contentLength;
- $stat['mtime'] = $mtime;
- $stat['atime'] = time();
- return $stat;
+ return [
+ 'size' => (int)$object->contentLength,
+ 'mtime' => isset($mtime) ? (int)floor($mtime) : null,
+ 'atime' => time(),
+ ];
}
public function filetype(string $path) {
@@ -352,7 +355,7 @@ class Swift extends Common {
$this->objectCache->remove($path . '/');
} catch (BadResponseError $e) {
if ($e->getResponse()->getStatusCode() !== 404) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -376,7 +379,7 @@ class Swift extends Common {
try {
return $this->objectStore->readObject($path);
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -396,7 +399,7 @@ class Swift extends Common {
} else {
$ext = '';
}
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
+ $tmpFile = Server::get(ITempManager::class)->getTemporaryFile($ext);
// Fetch existing file if required
if ($mode[0] !== 'w' && $this->file_exists($path)) {
if ($mode[0] === 'x') {
@@ -463,7 +466,7 @@ class Swift extends Common {
$this->objectCache->remove($target);
$this->objectCache->remove($target . '/');
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -479,7 +482,7 @@ class Swift extends Common {
$this->objectCache->remove($target);
$this->objectCache->remove($target . '/');
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
diff --git a/apps/files_external/lib/Lib/StorageConfig.php b/apps/files_external/lib/Lib/StorageConfig.php
index a9a03528b8f..2cb82d3790a 100644
--- a/apps/files_external/lib/Lib/StorageConfig.php
+++ b/apps/files_external/lib/Lib/StorageConfig.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/StorageModifierTrait.php b/apps/files_external/lib/Lib/StorageModifierTrait.php
index 4b9264f4223..4062ff1635e 100644
--- a/apps/files_external/lib/Lib/StorageModifierTrait.php
+++ b/apps/files_external/lib/Lib/StorageModifierTrait.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/lib/Lib/VisibilityTrait.php b/apps/files_external/lib/Lib/VisibilityTrait.php
index 63aa709b21c..62b26f3edb1 100644
--- a/apps/files_external/lib/Lib/VisibilityTrait.php
+++ b/apps/files_external/lib/Lib/VisibilityTrait.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.