Skip to content

Commit

Permalink
eos: Use sys ACLs for file permissions (#2494)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 authored Mar 2, 2022
1 parent 812d9e6 commit c0c6d55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 51 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/eos-sys-acl-files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Use sys ACLs for file permissions

https://github.com/cs3org/reva/pull/2494
38 changes: 4 additions & 34 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
const (
versionPrefix = ".sys.v#."
lwShareAttrKey = "reva.lwshare"
userACLEvalKey = "eval.useracl"
)

const (
Expand Down Expand Up @@ -323,20 +322,9 @@ func (c *Client) AddACL(ctx context.Context, auth, rootAuth eosclient.Authorizat
}

sysACL := a.CitrineSerialize()
args := []string{"acl"}

args := []string{"acl", "--sys"}
if finfo.IsDir {
args = append(args, "--sys", "--recursive")
} else {
args = append(args, "--user")
userACLAttr := &eosclient.Attribute{
Type: SystemAttr,
Key: userACLEvalKey,
Val: "1",
}
if err = c.SetAttr(ctx, auth, userACLAttr, false, path); err != nil {
return err
}
args = append(args, "--recursive")
}

// set position of ACLs to add. The default is to append to the end, so no arguments will be added in this case
Expand Down Expand Up @@ -387,11 +375,9 @@ func (c *Client) RemoveACL(ctx context.Context, auth, rootAuth eosclient.Authori
}

sysACL := a.CitrineSerialize()
args := []string{"acl"}
args := []string{"acl", "--sys"}
if finfo.IsDir {
args = append(args, "--sys", "--recursive")
} else {
args = append(args, "--user")
args = append(args, "--recursive")
}
args = append(args, sysACL, path)

Expand Down Expand Up @@ -1121,22 +1107,6 @@ func (c *Client) mapToFileInfo(kv, attrs map[string]string) (*eosclient.FileInfo
return nil, err
}

// Read user ACLs if sys.eval.useracl is set
if userACLEval, ok := attrs["sys."+userACLEvalKey]; ok && userACLEval == "1" {
if userACL, ok := attrs["user.acl"]; ok {
userAcls, err := acl.Parse(userACL, acl.ShortTextForm)
if err != nil {
return nil, err
}
for _, e := range userAcls.Entries {
err = sysACL.SetEntry(e.Type, e.Qualifier, e.Permissions)
if err != nil {
return nil, err
}
}
}
}

// Read lightweight ACLs recognized by the sys.reva.lwshare attr
if lwACLStr, ok := attrs["sys."+lwShareAttrKey]; ok {
lwAcls, err := acl.Parse(lwACLStr, acl.ShortTextForm)
Expand Down
17 changes: 0 additions & 17 deletions pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import (
const (
versionPrefix = ".sys.v#."
// lwShareAttrKey = "reva.lwshare"
userACLEvalKey = "eval.useracl"
)

const (
Expand Down Expand Up @@ -502,22 +501,6 @@ func (c *Client) fixupACLs(ctx context.Context, auth eosclient.Authorization, in
}
}

// Read user ACLs if sys.eval.useracl is set
if userACLEval, ok := info.Attrs["sys."+userACLEvalKey]; ok && userACLEval == "1" {
if userACL, ok := info.Attrs["user.acl"]; ok {
userAcls, err := acl.Parse(userACL, acl.ShortTextForm)
if err != nil {
return nil
}
for _, e := range userAcls.Entries {
err = info.SysACL.SetEntry(e.Type, e.Qualifier, e.Permissions)
if err != nil {
return nil
}
}
}
}

// We need to inherit the ACLs for the parent directory as these are not available for files
if !info.IsDir {
parentInfo, err := c.GetFileInfoByPath(ctx, auth, path.Dir(info.File))
Expand Down

0 comments on commit c0c6d55

Please sign in to comment.