mirror of
https://github.com/minio/minio.git
synced 2025-11-26 04:26:12 -05:00
Implement Bucket ACL support
This commit is contained in:
45
pkg/fs/acl.go
Normal file
45
pkg/fs/acl.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package fs
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// IsPrivateBucket - is private bucket
|
||||
func (fs API) IsPrivateBucket(bucket string) bool {
|
||||
fs.lock.Lock()
|
||||
defer fs.lock.Unlock()
|
||||
// get bucket path
|
||||
bucketDir := filepath.Join(fs.path, bucket)
|
||||
fi, err := os.Stat(bucketDir)
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
return permToACL(fi.Mode()).IsPrivate()
|
||||
}
|
||||
|
||||
// IsPublicBucket - is public bucket
|
||||
func (fs API) IsPublicBucket(bucket string) bool {
|
||||
fs.lock.Lock()
|
||||
defer fs.lock.Unlock()
|
||||
// get bucket path
|
||||
bucketDir := filepath.Join(fs.path, bucket)
|
||||
fi, err := os.Stat(bucketDir)
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
return permToACL(fi.Mode()).IsPublicReadWrite()
|
||||
}
|
||||
|
||||
// IsReadOnlyBucket - is read only bucket
|
||||
func (fs API) IsReadOnlyBucket(bucket string) bool {
|
||||
fs.lock.Lock()
|
||||
defer fs.lock.Unlock()
|
||||
// get bucket path
|
||||
bucketDir := filepath.Join(fs.path, bucket)
|
||||
fi, err := os.Stat(bucketDir)
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
return permToACL(fi.Mode()).IsPublicRead()
|
||||
}
|
||||
Reference in New Issue
Block a user