From 59c3d8d85f77c1176099ddfd3d37086608a0d39d Mon Sep 17 00:00:00 2001 From: Sebastien Cat Date: Sun, 17 Feb 2019 15:59:47 +0100 Subject: [PATCH 1/4] Dont check Bucket Name in Nextcloud MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sebastien Cat Signed-off-by: Sébastien Cat --- lib/private/Files/ObjectStore/S3ConnectionTrait.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index feca792848e..02b6fff6846 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -99,10 +99,6 @@ trait S3ConnectionTrait { } $this->connection = new S3Client($options); - if (!$this->connection->isBucketDnsCompatible($this->bucket)) { - throw new \Exception("The configured bucket name is invalid: " . $this->bucket); - } - if (!$this->connection->doesBucketExist($this->bucket)) { $logger = \OC::$server->getLogger(); try { From 77473b0228d52ab7add4f0c469631cbb2a9171ba Mon Sep 17 00:00:00 2001 From: "S. Cat" <33800996+sparrowjack63@users.noreply.github.com> Date: Tue, 26 Feb 2019 09:32:14 +0100 Subject: [PATCH 2/4] Warning on S3 not compatible DNS bucket name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new created bucket should respect the DNS compatibility, nevertheless, Nextcloud should accept to mount "old created" buckets that does not respect DNS compatibility (Backward compatibility, or compatibility with CEPH). Signed-off-by: Sébastien Cat --- .../Files/ObjectStore/S3ConnectionTrait.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 02b6fff6846..4bb98e11490 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -99,13 +99,20 @@ trait S3ConnectionTrait { } $this->connection = new S3Client($options); - if (!$this->connection->doesBucketExist($this->bucket)) { + if (!$this->connection->isBucketDnsCompatible($this->bucket)) { + $logger = \OC::$server->getLogger(); + $logger->warning('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.', + ['app' => 'objectstore']); + } + + if (!$this->connection->doesBucketExist($this->bucket)) { $logger = \OC::$server->getLogger(); try { $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']); - $this->connection->createBucket(array( - 'Bucket' => $this->bucket - )); + if (!$this->connection->isBucketDnsCompatible($this->bucket)) { + throw new \Exception("The bucket will not be created because the name is not dns compatible, please correct it: " . $this->bucket); + } + $this->connection->createBucket(array('Bucket' => $this->bucket)); $this->testTimeout(); } catch (S3Exception $e) { $logger->logException($e, [ From 381ae44d38827d289f828094d065afcc8060fbbe Mon Sep 17 00:00:00 2001 From: "S. Cat" <33800996+sparrowjack63@users.noreply.github.com> Date: Tue, 26 Feb 2019 09:50:47 +0100 Subject: [PATCH 3/4] Correct code indent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just correct code indent. Signed-off-by: Sébastien Cat --- lib/private/Files/ObjectStore/S3ConnectionTrait.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 4bb98e11490..7f983c48ad7 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -100,12 +100,12 @@ trait S3ConnectionTrait { $this->connection = new S3Client($options); if (!$this->connection->isBucketDnsCompatible($this->bucket)) { - $logger = \OC::$server->getLogger(); - $logger->warning('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.', - ['app' => 'objectstore']); - } + $logger = \OC::$server->getLogger(); + $logger->warning('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.', + ['app' => 'objectstore']); + } - if (!$this->connection->doesBucketExist($this->bucket)) { + if (!$this->connection->doesBucketExist($this->bucket)) { $logger = \OC::$server->getLogger(); try { $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']); From e3142a91b229d9f11b5df1f1b33dfe5d67b5f761 Mon Sep 17 00:00:00 2001 From: "S. Cat" <33800996+sparrowjack63@users.noreply.github.com> Date: Thu, 28 Feb 2019 09:55:46 +0100 Subject: [PATCH 4/4] Bucket name - Alert in debug mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alert in debug mode only when trying to mount non compatible DNS bucket name (in order to not flood the logs) Signed-off-by: Sébastien Cat --- lib/private/Files/ObjectStore/S3ConnectionTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 7f983c48ad7..b2bb6d706e0 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -101,7 +101,7 @@ trait S3ConnectionTrait { if (!$this->connection->isBucketDnsCompatible($this->bucket)) { $logger = \OC::$server->getLogger(); - $logger->warning('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.', + $logger->debug('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.', ['app' => 'objectstore']); }