Repository: rclone/rclone (language: go)

Issue:
S3(Alibaba): bucket ACL changed after `rclone mkdir`
#### The associated forum post URL from `https://forum.rclone.org`

No.

#### What is the problem you are having with rclone?

`rclone mkdir` will [`CreateBucket`](https://github.com/rclone/rclone/blob/fea61cac9ed70ae33f7274ae8e062ca4c2dc523c/backend/s3/s3.go#L4338) (aka [`PutBucket`](https://www.alibabacloud.com/help/en/oss/developer-reference/putbucket) in Alibaba (OSS)), and will change the ACL of an existing bucket.

To fix it, we need to avoid calling `CreateBucket` when bucket exists on Alibaba (OSS), maybe use [`GetBucketInfo`](https://www.alibabacloud.com/help/en/oss/developer-reference/getbucketinfo) to check when the `provider = Alibaba`?

P.S. Standard AWS S3 SDK does not have `GetBucketInfo` API, so we need to introduce [aliyun-oss-go-sdk](https://github.com/aliyun/aliyun-oss-go-sdk).

#### What is your rclone version (output from `rclone version`)

rclone v1.66.0
- os/version: darwin 14.4.1 (64 bit)
- os/kernel: 23.4.0 (arm64)
- os/type: darwin
- os/arch: arm64 (ARMv8 compatible)
- go/version: go1.22.1
- go/linking: dynamic
- go/tags: none

#### Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

darwin, 64bit


#### Which cloud storage system are you using? (e.g. Google Drive)

S3 (provider Alibaba)

#### The command you were trying to run (e.g. `rclone copy /tmp remote:tmp`)

`rclone mkdir xxx`

#### A log from the command with the `-vv` flag (e.g. output from `rclone -vv copy /tmp remote:tmp`)



<!--- Please keep the note below for others who read your bug report. -->

#### How to use GitHub

* Please use the 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are affected by the same issue.
* Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
* Subscribe to receive notifications on status change and new comments.

S3(Alibaba): bucket ACL changed after `rclone mkdir`
#### The associated forum post URL from `https://forum.rclone.org`

No.

#### What is the problem you are having with rclone?

`rclone mkdir` will [`CreateBucket`](https://github.com/rclone/rclone/blob/fea61cac9ed70ae33f7274ae8e062ca4c2dc523c/backend/s3/s3.go#L4338) (aka [`PutBucket`](https://www.alibabacloud.com/help/en/oss/developer-reference/putbucket) in Alibaba (OSS)), and will change the ACL of an existing bucket.

To fix it, we need to avoid calling `CreateBucket` when bucket exists on Alibaba (OSS), maybe use [`GetBucketInfo`](https://www.alibabacloud.com/help/en/oss/developer-reference/getbucketinfo) to check when the `provider = Alibaba`?

P.S. Standard AWS S3 SDK does not have `GetBucketInfo` API, so we need to introduce [aliyun-oss-go-sdk](https://github.com/aliyun/aliyun-oss-go-sdk).

#### What is your rclone version (output from `rclone version`)

rclone v1.66.0
- os/version: darwin 14.4.1 (64 bit)
- os/kernel: 23.4.0 (arm64)
- os/type: darwin
- os/arch: arm64 (ARMv8 compatible)
- go/version: go1.22.1
- go/linking: dynamic
- go/tags: none

#### Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

darwin, 64bit


#### Which cloud storage system are you using? (e.g. Google Drive)

S3 (provider Alibaba)

#### The command you were trying to run (e.g. `rclone copy /tmp remote:tmp`)

`rclone mkdir xxx`

#### A log from the command with the `-vv` flag (e.g. output from `rclone -vv copy /tmp remote:tmp`)



<!--- Please keep the note below for others who read your bug report. -->

#### How to use GitHub

* Please use the 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are affected by the same issue.
* Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
* Subscribe to receive notifications on status change and new comments.



Discussion / hints:
Try adding `no_check_bucket = true` to your config -  I think that should fix it.

If it does, then we should recommend that in the docs.
@ncw Thanks, it works for me.
Two things:
1. Recommend `no_check_bucket = true` in docs
2. Since the default behavior shouldn't be a bug, maybe we check if the directory exists before [`makeBucket`](https://github.com/rclone/rclone/blob/ce5024bf3317dbbe2072abda15036e2d8507d3fd/backend/s3/s3.go#L4352) in [`Mkdir()`](https://github.com/rclone/rclone/blob/ce5024bf3317dbbe2072abda15036e2d8507d3fd/backend/s3/s3.go#L4350)?
What should happen is `PutBucket` returns error `AlreadyOwnedByYou` rather than updating the bucket. That is what AWS does, so I'd class this as a bug in the Alibaba implementation.

We should at minimum Recommend `no_check_bucket = true` in the docs for Alibaba - do you want to send a PR for that?
> We should at minimum Recommend `no_check_bucket = true` in the docs for Alibaba - do you want to send a PR for that?

OK.
I might submit another PR later to specifically implement a `Fs` for Alibaba.

Try adding `no_check_bucket = true` to your config -  I think that should fix it.

If it does, then we should recommend that in the docs.
@ncw Thanks, it works for me.
Two things:
1. Recommend `no_check_bucket = true` in docs
2. Since the default behavior shouldn't be a bug, maybe we check if the directory exists before [`makeBucket`](https://github.com/rclone/rclone/blob/ce5024bf3317dbbe2072abda15036e2d8507d3fd/backend/s3/s3.go#L4352) in [`Mkdir()`](https://github.com/rclone/rclone/blob/ce5024bf3317dbbe2072abda15036e2d8507d3fd/backend/s3/s3.go#L4350)?
What should happen is `PutBucket` returns error `AlreadyOwnedByYou` rather than updating the bucket. That is what AWS does, so I'd class this as a bug in the Alibaba implementation.

We should at minimum Recommend `no_check_bucket = true` in the docs for Alibaba - do you want to send a PR for that?
> We should at minimum Recommend `no_check_bucket = true` in the docs for Alibaba - do you want to send a PR for that?

OK.
I might submit another PR later to specifically implement a `Fs` for Alibaba.


Fix patch:
diff --git a/docs/content/s3.md b/docs/content/s3.md
index 69f53a5404022..cf0e2d148ff92 100644
--- a/docs/content/s3.md
+++ b/docs/content/s3.md
@@ -1531,6 +1531,8 @@ It can also be needed if the user you are using does not have bucket
 creation permissions. Before v1.52.0 this would have passed silently
 due to a bug.
 
+We recommend setting `no_check_bucket = true` when the provider is Alibaba, otherwise the bucket ACL may changed after every `rclone mkdir`. See [#7889](https://github.com/rclone/rclone/issues/7889).
+
 
 Properties:
 


Test patch: