Disable ACL's for filesystem as it doesn't bring any direct meaning
This commit is contained in:
+5
-5
@@ -36,7 +36,7 @@ var accessCmd = cli.Command{
|
||||
mc {{.Name}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
mc {{.Name}}{{if .Flags}} [ARGS...]{{end}} PERMISSION TARGET [TARGET ...] {{if .Description}}
|
||||
mc {{.Name}}{{if .Flags}} [ARGS...]{{end}} [OPTION] PERMISSION TARGET [TARGET ...] {{if .Description}}
|
||||
|
||||
DESCRIPTION:
|
||||
{{.Description}}{{end}}{{if .Flags}}
|
||||
@@ -48,16 +48,16 @@ FLAGS:
|
||||
EXAMPLES:
|
||||
|
||||
1. Set bucket to "private" on Amazon S3 cloud storage.
|
||||
$ mc {{.Name}} private https://s3.amazonaws.com/burningman2011
|
||||
$ mc {{.Name}} set private https://s3.amazonaws.com/burningman2011
|
||||
|
||||
2. Set bucket to "public" on Amazon S3 cloud storage.
|
||||
$ mc {{.Name}} public https://s3.amazonaws.com/shared
|
||||
$ mc {{.Name}} set public https://s3.amazonaws.com/shared
|
||||
|
||||
3. Set bucket to "authenticated" on Amazon S3 cloud storage to provide read access to IAM Authenticated Users group.
|
||||
$ mc {{.Name}} authenticated https://s3.amazonaws.com/shared-authenticated
|
||||
$ mc {{.Name}} set authorized https://s3.amazonaws.com/shared-authenticated
|
||||
|
||||
4. Set folder to world readwrite (chmod 777) on local filesystem.
|
||||
$ mc {{.Name}} public /shared/Music
|
||||
$ mc {{.Name}} get https://s3.amazonaws.com/shared
|
||||
`,
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -25,7 +25,7 @@ func (b bucketPerms) isValidBucketPERM() bool {
|
||||
fallthrough
|
||||
case b.isPublic():
|
||||
fallthrough
|
||||
case b.isAuthenticated():
|
||||
case b.isAuthorized():
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
@@ -37,10 +37,10 @@ type bucketPerms string
|
||||
|
||||
// different types of ACL's currently supported for buckets
|
||||
const (
|
||||
bucketPrivate = bucketPerms("private")
|
||||
bucketReadOnly = bucketPerms("readonly")
|
||||
bucketPublic = bucketPerms("public")
|
||||
bucketAuthenticated = bucketPerms("authenticated")
|
||||
bucketPrivate = bucketPerms("private")
|
||||
bucketReadOnly = bucketPerms("readonly")
|
||||
bucketPublic = bucketPerms("public")
|
||||
bucketAuthorized = bucketPerms("authorized")
|
||||
)
|
||||
|
||||
func (b bucketPerms) String() string {
|
||||
@@ -53,7 +53,7 @@ func (b bucketPerms) String() string {
|
||||
if b.isPublic() {
|
||||
return "public-read-write"
|
||||
}
|
||||
if b.isAuthenticated() {
|
||||
if b.isAuthorized() {
|
||||
return "authenticated-read"
|
||||
}
|
||||
return "private"
|
||||
@@ -74,7 +74,7 @@ func (b bucketPerms) isPublic() bool {
|
||||
return b == bucketPublic
|
||||
}
|
||||
|
||||
// IsAuthenticated - is acl AuthenticatedRead
|
||||
func (b bucketPerms) isAuthenticated() bool {
|
||||
return b == bucketAuthenticated
|
||||
// IsAuthorized - is acl AuthorizedRead
|
||||
func (b bucketPerms) isAuthorized() bool {
|
||||
return b == bucketAuthorized
|
||||
}
|
||||
|
||||
+1
-1
@@ -194,7 +194,7 @@ func (s *CmdTestSuite) TestValidPERMS(c *C) {
|
||||
perms = bucketPerms("readonly")
|
||||
c.Assert(perms.isValidBucketPERM(), Equals, true)
|
||||
c.Assert(perms.String(), Equals, "public-read")
|
||||
perms = bucketPerms("authenticated")
|
||||
perms = bucketPerms("authorized")
|
||||
c.Assert(perms.isValidBucketPERM(), Equals, true)
|
||||
c.Assert(perms.String(), Equals, "authenticated-read")
|
||||
}
|
||||
|
||||
+2
-18
@@ -17,30 +17,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/minio/mc/pkg/console"
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
func (s *CmdTestSuite) TestMbAndAccessCmd(c *C) {
|
||||
/// filesystem
|
||||
root, err := ioutil.TempDir(os.TempDir(), "cmd-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(root)
|
||||
|
||||
perr := doMakeBucketCmd(filepath.Join(root, "bucket"))
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
perr = doUpdateAccessCmd(filepath.Join(root, "bucket"), "public-read-write")
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
perr = doUpdateAccessCmd(filepath.Join(root, "bucket"), "invalid")
|
||||
c.Assert(perr, Not(IsNil))
|
||||
|
||||
perr = doMakeBucketCmd(server.URL + "/bucket")
|
||||
perr := doMakeBucketCmd(server.URL + "/bucket")
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
perr = doUpdateAccessCmd(server.URL+"/bucket", "public-read-write")
|
||||
@@ -92,7 +76,7 @@ func (s *CmdTestSuite) TestAccessContext(c *C) {
|
||||
// reset back
|
||||
console.IsExited = false
|
||||
|
||||
err = app.Run([]string{os.Args[0], "access", "authenticated", server.URL + "/bucket"})
|
||||
err = app.Run([]string{os.Args[0], "access", "authorized", server.URL + "/bucket"})
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(console.IsExited, Equals, false)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ type Client interface {
|
||||
|
||||
// Bucket operations
|
||||
MakeBucket() *probe.Error
|
||||
GetBucketACL() (acl string, error *probe.Error)
|
||||
SetBucketACL(acl string) *probe.Error
|
||||
|
||||
// Object operations
|
||||
|
||||
+7
-47
@@ -348,40 +348,6 @@ func (f *fsClient) listRecursiveInRoutine(contentCh chan client.ContentOnChannel
|
||||
}
|
||||
}
|
||||
|
||||
// isValidBucketACL - is acl a valid ACL?
|
||||
func isValidBucketACL(acl string) bool {
|
||||
switch acl {
|
||||
case "private":
|
||||
fallthrough
|
||||
case "public-read":
|
||||
fallthrough
|
||||
case "public-read-write":
|
||||
fallthrough
|
||||
case "authenticated-read":
|
||||
fallthrough
|
||||
case "":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// aclToPerm - convert acl to filesystem mode
|
||||
func aclToPerm(acl string) os.FileMode {
|
||||
switch acl {
|
||||
case "private":
|
||||
return os.FileMode(0700)
|
||||
case "public-read":
|
||||
return os.FileMode(0500)
|
||||
case "public-read-write":
|
||||
return os.FileMode(0777)
|
||||
case "authenticated-read":
|
||||
return os.FileMode(0770)
|
||||
default:
|
||||
return os.FileMode(0700)
|
||||
}
|
||||
}
|
||||
|
||||
// MakeBucket - create a new bucket
|
||||
func (f *fsClient) MakeBucket() *probe.Error {
|
||||
err := os.MkdirAll(f.path, 0775)
|
||||
@@ -391,20 +357,14 @@ func (f *fsClient) MakeBucket() *probe.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetBucketACL - create a new bucket
|
||||
// GetBucketACL - get bucket acl
|
||||
func (f *fsClient) GetBucketACL() (acl string, error *probe.Error) {
|
||||
return "", probe.NewError(client.APINotImplemented{API: "GetBucketACL", APIType: "filesystem"})
|
||||
}
|
||||
|
||||
// SetBucketACL - create a new bucket acl
|
||||
func (f *fsClient) SetBucketACL(acl string) *probe.Error {
|
||||
if !isValidBucketACL(acl) {
|
||||
return probe.NewError(client.InvalidACLType{ACL: acl})
|
||||
}
|
||||
err := os.MkdirAll(f.path, aclToPerm(acl))
|
||||
if err != nil {
|
||||
return probe.NewError(err)
|
||||
}
|
||||
err = os.Chmod(f.path, aclToPerm(acl))
|
||||
if err != nil {
|
||||
return probe.NewError(err)
|
||||
}
|
||||
return nil
|
||||
return probe.NewError(client.APINotImplemented{API: "SetBucketACL", APIType: "filesystem"})
|
||||
}
|
||||
|
||||
// getFSMetadata -
|
||||
|
||||
@@ -161,7 +161,7 @@ func (s *MySuite) TestStatBucket(c *C) {
|
||||
c.Assert(perr, IsNil)
|
||||
}
|
||||
|
||||
func (s *MySuite) TestPutBucketACL(c *C) {
|
||||
func (s *MySuite) TestBucketACLFails(c *C) {
|
||||
root, err := ioutil.TempDir(os.TempDir(), "fs-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(root)
|
||||
@@ -173,7 +173,10 @@ func (s *MySuite) TestPutBucketACL(c *C) {
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
perr = fsc.SetBucketACL("private")
|
||||
c.Assert(perr, IsNil)
|
||||
c.Assert(perr, Not(IsNil))
|
||||
|
||||
_, perr = fsc.GetBucketACL()
|
||||
c.Assert(perr, Not(IsNil))
|
||||
}
|
||||
|
||||
func (s *MySuite) TestPutObject(c *C) {
|
||||
|
||||
@@ -146,6 +146,19 @@ func (c *s3Client) MakeBucket() *probe.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetBucketACL get canned acl's on a bucket
|
||||
func (c *s3Client) GetBucketACL() (acl string, error *probe.Error) {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
if object != "" {
|
||||
return "", probe.NewError(client.InvalidQueryURL{URL: c.hostURL.String()})
|
||||
}
|
||||
bucketACL, err := c.api.GetBucketACL(bucket)
|
||||
if err != nil {
|
||||
return "", probe.NewError(err)
|
||||
}
|
||||
return bucketACL.String(), nil
|
||||
}
|
||||
|
||||
// SetBucketACL add canned acl's on a bucket
|
||||
func (c *s3Client) SetBucketACL(acl string) *probe.Error {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
|
||||
Reference in New Issue
Block a user