"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
serve s3: make errors in --s3-auth-key fatal - fixes #9044
Nick Craig-Woodf81cd7d2797a
diff --git a/cmd/serve/s3/serve_s3.md b/cmd/serve/s3/serve_s3.mdindex 7143da9ac..a1281b515 100644--- a/cmd/serve/s3/serve_s3.md+++ b/cmd/serve/s3/serve_s3.md@@ -13,6 +13,26 @@ docs](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html)).`--auth-key` is not provided then `serve s3` will allow anonymousaccess.+Like all rclone flags `--auth-key` can be set via environment+variables, in this case `RCLONE_AUTH_KEY`. Since this flag can be+repeated, the input to `RCLONE_AUTH_KEY` is CSV encoded. Because the+`accessKey,secretKey` has a comma in, this means it needs to be in+quotes.++```console+export RCLONE_AUTH_KEY='"user,pass"'+rclone serve s3 ...+```++Or to supply multiple identities:++```console+export RCLONE_AUTH_KEY='"user1,pass1","user2,pass2"'+rclone serve s3 ...+```++Setting this variable without quotes will produce an error.+Please note that some clients may require HTTPS endpoints. See [theSSL docs](#tls-ssl) for more information.diff --git a/cmd/serve/s3/server.go b/cmd/serve/s3/server.goindex 4ef792701..0d690b642 100644--- a/cmd/serve/s3/server.go+++ b/cmd/serve/s3/server.go@@ -70,6 +70,11 @@ func newServer(ctx context.Context, f fs.Fs, opt *Options, vfsOpt *vfscommon.Optw.s3Secret = getAuthSecret(opt.AuthKey)}+ authList, err := authlistResolver(opt.AuthKey)+ if err != nil {+ return nil, fmt.Errorf("parsing auth list failed: %q", err)+ }+var newLogger loggerw.faker = gofakes3.New(newBackend(w),@@ -77,7 +82,7 @@ func newServer(ctx context.Context, f fs.Fs, opt *Options, vfsOpt *vfscommon.Optgofakes3.WithLogger(newLogger),gofakes3.WithRequestID(rand.Uint64()),gofakes3.WithoutVersioning(),- gofakes3.WithV4Auth(authlistResolver(opt.AuthKey)),+ gofakes3.WithV4Auth(authList),gofakes3.WithIntegrityCheck(true), // Check Content-MD5 if supplied)@@ -92,7 +97,7 @@ func newServer(ctx context.Context, f fs.Fs, opt *Options, vfsOpt *vfscommon.Optw._vfs = vfs.New(f, vfsOpt)if len(opt.AuthKey) > 0 {- w.faker.AddAuthKeys(authlistResolver(opt.AuthKey))+ w.faker.AddAuthKeys(authList)}}diff --git a/cmd/serve/s3/utils.go b/cmd/serve/s3/utils.goindex 5020df63a..cb6a926a3 100644--- a/cmd/serve/s3/utils.go+++ b/cmd/serve/s3/utils.go@@ -3,6 +3,7 @@ package s3import ("context""encoding/hex"+ "errors""io""os""path"@@ -125,15 +126,14 @@ func rmdirRecursive(p string, VFS *vfs.VFS) {}}-func authlistResolver(list []string) map[string]string {+func authlistResolver(list []string) (map[string]string, error) {authList := make(map[string]string)for _, v := range list {parts := strings.Split(v, ",")if len(parts) != 2 {- fs.Infof(nil, "Ignored: invalid auth pair %s", v)- continue+ return nil, errors.New("invalid auth pair: expecting a single comma")}authList[parts[0]] = parts[1]}- return authList+ return authList, nil}