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

eos: Use sys ACLs for file permissions #2494

Merged
merged 4 commits into from
Mar 2, 2022
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
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