From 4bba2cd03439b833f644936c550b4a8d7bfb4786 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 28 Jun 2020 08:15:15 -0700 Subject: [PATCH] fix: disallow versioning to be suspended with object lock (#9930) --- Makefile | 4 +++- cmd/bucket-versioning-handler.go | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4f6f3f6c3..22bb555a5 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,9 @@ build: checks @echo "Building minio binary to './minio'" @GO111MODULE=on CGO_ENABLED=0 go build -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null -docker: build +docker: checks + @echo "Building minio docker image '$(TAG)'" + @GOOS=linux GO111MODULE=on CGO_ENABLED=0 go build -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null @docker build -t $(TAG) . -f Dockerfile.dev # Builds minio and installs it to $GOPATH/bin. diff --git a/cmd/bucket-versioning-handler.go b/cmd/bucket-versioning-handler.go index 54b6da3bc..da7620507 100644 --- a/cmd/bucket-versioning-handler.go +++ b/cmd/bucket-versioning-handler.go @@ -62,6 +62,15 @@ func (api objectAPIHandlers) PutBucketVersioningHandler(w http.ResponseWriter, r return } + if rcfg, _ := globalBucketObjectLockSys.Get(bucket); rcfg.LockEnabled && v.Suspended() { + writeErrorResponse(ctx, w, APIError{ + Code: "InvalidBucketState", + Description: "An Object Lock configuration is present on this bucket, so the versioning state cannot be changed.", + HTTPStatusCode: http.StatusConflict, + }, r.URL, guessIsBrowserReq(r)) + return + } + configData, err := xml.Marshal(v) if err != nil { writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r))