From b03deb9d3ccb537141f62cafd386bb1695da5149 Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Wed, 18 Nov 2015 18:11:33 -0800 Subject: [PATCH] s3.go should return client.PathInsufficientPermission{} for access denied errors fixes #1421 --- pkg/client/s3/s3.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/client/s3/s3.go b/pkg/client/s3/s3.go index d5e8a0cf..2cd2341f 100644 --- a/pkg/client/s3/s3.go +++ b/pkg/client/s3/s3.go @@ -87,6 +87,12 @@ func (c *s3Client) Get(offset, length int64) (io.ReadCloser, int64, *probe.Error bucket, object := c.url2BucketAndObject() reader, metadata, err := c.api.GetPartialObject(bucket, object, offset, length) if err != nil { + errResponse := minio.ToErrorResponse(err) + if errResponse != nil { + if errResponse.Code == "AccessDenied" { + return nil, 0, probe.NewError(client.PathInsufficientPermission{Path: c.hostURL.String()}) + } + } return nil, length, probe.NewError(err) } return reader, metadata.Size, nil @@ -156,6 +162,9 @@ func (c *s3Client) Put(size int64, data io.Reader) *probe.Error { if err != nil { errResponse := minio.ToErrorResponse(err) if errResponse != nil { + if errResponse.Code == "AccessDenied" { + return probe.NewError(client.PathInsufficientPermission{Path: c.hostURL.String()}) + } if errResponse.Code == "MethodNotAllowed" { return probe.NewError(client.ObjectAlreadyExists{Object: object}) }