Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed permission mapping to EOS ACLs #4667

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/eos-perms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: fixed permission mapping to EOS ACLs

This is to remove "m" and "q" flags in EOS ACLs
for regular write shares (no re-sharing).

https://github.com/cs3org/reva/pull/4667
6 changes: 0 additions & 6 deletions internal/http/services/owncloud/ocs/conversions/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ func NewViewerRole() *Role {
Name: RoleViewer,
cS3ResourcePermissions: &provider.ResourcePermissions{
GetPath: true,
GetQuota: true,
InitiateFileDownload: true,
ListGrants: true,
ListContainer: true,
Expand All @@ -200,7 +199,6 @@ func NewReaderRole() *Role {
cS3ResourcePermissions: &provider.ResourcePermissions{
// read
GetPath: true,
GetQuota: true,
InitiateFileDownload: true,
ListGrants: true,
ListContainer: true,
Expand All @@ -218,7 +216,6 @@ func NewEditorRole() *Role {
Name: RoleEditor,
cS3ResourcePermissions: &provider.ResourcePermissions{
GetPath: true,
GetQuota: true,
InitiateFileDownload: true,
ListGrants: true,
ListContainer: true,
Expand All @@ -243,7 +240,6 @@ func NewFileEditorRole() *Role {
Name: RoleEditor,
cS3ResourcePermissions: &provider.ResourcePermissions{
GetPath: true,
GetQuota: true,
InitiateFileDownload: true,
ListGrants: true,
ListContainer: true,
Expand Down Expand Up @@ -368,7 +364,6 @@ func NewLegacyRoleFromOCSPermissions(p Permissions) *Role {
r.cS3ResourcePermissions.ListRecycle = true
r.cS3ResourcePermissions.Stat = true
r.cS3ResourcePermissions.GetPath = true
r.cS3ResourcePermissions.GetQuota = true
r.cS3ResourcePermissions.InitiateFileDownload = true
}
if p.Contain(PermissionWrite) {
Expand Down Expand Up @@ -424,7 +419,6 @@ func RoleFromResourcePermissions(rp *provider.ResourcePermissions) *Role {
rp.ListRecycle &&
rp.Stat &&
rp.GetPath &&
rp.GetQuota &&
rp.InitiateFileDownload {
r.ocsPermissions |= PermissionRead
}
Expand Down
22 changes: 8 additions & 14 deletions pkg/storage/utils/grants/grants.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
"github.com/google/go-cmp/cmp"
)

// GetACLPerm generates a string representation of CS3APIs' ResourcePermissions
// GetACLPerm generates a string representation of CS3APIs' ResourcePermissions,
// modeled after the EOS ACLs.
// TODO(labkode): fine grained permission controls.
func GetACLPerm(set *provider.ResourcePermissions) (string, error) {
// resource permission is denied
Expand All @@ -37,7 +38,7 @@ func GetACLPerm(set *provider.ResourcePermissions) (string, error) {

var b strings.Builder

if set.Stat || set.InitiateFileDownload {
if set.Stat || set.InitiateFileDownload || set.ListGrants {
b.WriteString("r")
}
if set.CreateContainer || set.InitiateFileUpload || set.Delete || set.Move {
Expand All @@ -46,12 +47,9 @@ func GetACLPerm(set *provider.ResourcePermissions) (string, error) {
if set.ListContainer || set.ListFileVersions {
b.WriteString("x")
}
if set.AddGrant || set.ListGrants || set.RemoveGrant {
if set.AddGrant || set.RemoveGrant {
b.WriteString("m")
}
if set.GetQuota {
b.WriteString("q")
}

if set.Delete {
b.WriteString("+d")
Expand All @@ -62,17 +60,18 @@ func GetACLPerm(set *provider.ResourcePermissions) (string, error) {
return b.String(), nil
}

// GetGrantPermissionSet converts CS3APIs' ResourcePermissions from a string
// TODO(labkode): add more fine grained controls.
// GetGrantPermissionSet converts CS3APIs' ResourcePermissions from a string:
// EOS acls are a mix of ACLs and POSIX permissions. More details can be found in
// https://github.com/cern-eos/eos/blob/master/doc/configuration/permission.rst
// https://github.com/cern-eos/eos/blob/master/doc/citrine/configuration/permission.rst.
// TODO(labkode): add more fine grained controls.
func GetGrantPermissionSet(perm string) *provider.ResourcePermissions {
var rp provider.ResourcePermissions // default to 0 == all denied

if strings.Contains(perm, "r") && !strings.Contains(perm, "!r") {
rp.GetPath = true
rp.Stat = true
rp.InitiateFileDownload = true
rp.ListGrants = true
}

if strings.Contains(perm, "w") && !strings.Contains(perm, "!w") {
Expand All @@ -98,14 +97,9 @@ func GetGrantPermissionSet(perm string) *provider.ResourcePermissions {

if strings.Contains(perm, "m") && !strings.Contains(perm, "!m") {
rp.AddGrant = true
rp.ListGrants = true
rp.RemoveGrant = true
}

if strings.Contains(perm, "q") && !strings.Contains(perm, "!q") {
rp.GetQuota = true
}

return &rp
}

Expand Down
Loading