s3.go should return client.PathInsufficientPermission{} for access denied errors fixes #1421

This commit is contained in:
Krishna Srinivas
2015-11-18 18:18:06 -08:00
parent 54864b12b4
commit b03deb9d3c
+9
View File
@@ -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})
}