diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 37dddff25..d6ae21bea 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -1032,6 +1032,12 @@ func (api objectAPIHandlers) PutBucketObjectLockConfigHandler(w http.ResponseWri return } + // Deny object locking configuration settings on existing buckets without object lock enabled. + if _, err = globalBucketMetadataSys.GetObjectLockConfig(bucket); err != nil { + writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) + return + } + if err = globalBucketMetadataSys.Update(bucket, objectLockConfig, configData); err != nil { writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) return