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

Fix broken PROPFIND permissions in projects over gRPC #4901

Merged
merged 1 commit into from
Oct 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
8 changes: 8 additions & 0 deletions changelog/unreleased/propfind-perms-grpc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: broken PROPFIND perms on gRPC

When using the EOS gRPC stack, the permissions returned by PROPFIND
on a folder in a project were erroneous because ACL permissions were
being ignored. This stems from a bug in grpcMDResponseToFileInfo,
where the SysACL attribute of the FileInfo struct was not being populated.

See: https://github.com/cs3org/reva/pull/4901
32 changes: 31 additions & 1 deletion pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,9 @@ func (c *Client) List(ctx context.Context, auth eosclient.Authorization, dpath s
if parent != nil && parent.SysACL != nil {
if fi.SysACL == nil {
log.Warn().Str("func", "List").Str("path", dpath).Str("SysACL is nil, taking parent", "").Msg("grpc response")
fi.SysACL.Entries = parent.SysACL.Entries
fi.SysACL = &acl.ACLs{
Entries: parent.SysACL.Entries,
}
} else {
fi.SysACL.Entries = append(fi.SysACL.Entries, parent.SysACL.Entries...)
}
Expand Down Expand Up @@ -1629,6 +1631,10 @@ func (c *Client) grpcMDResponseToFileInfo(ctx context.Context, st *erpc.MDRespon
fi.Attrs[strings.TrimPrefix(k, "user.")] = string(v)
}

if fi.Attrs["sys.acl"] != "" {
diocas marked this conversation as resolved.
Show resolved Hide resolved
fi.SysACL = aclAttrToAclStruct(fi.Attrs["sys.acl"])
}

fi.TreeSize = uint64(st.Cmd.TreeSize)
fi.Size = fi.TreeSize
// TODO(lopresti) this info is missing in the EOS Protobuf, cf. EOS-5974
Expand All @@ -1649,6 +1655,10 @@ func (c *Client) grpcMDResponseToFileInfo(ctx context.Context, st *erpc.MDRespon
fi.Attrs[strings.TrimPrefix(k, "user.")] = string(v)
}

if fi.Attrs["sys.acl"] != "" {
fi.SysACL = aclAttrToAclStruct(fi.Attrs["sys.acl"])
}

fi.Size = st.Fmd.Size

if st.Fmd.Checksum != nil {
Expand All @@ -1663,3 +1673,23 @@ func (c *Client) grpcMDResponseToFileInfo(ctx context.Context, st *erpc.MDRespon
}
return fi, nil
}

func aclAttrToAclStruct(aclAttr string) *acl.ACLs {
entries := strings.Split(aclAttr, ",")

acl := &acl.ACLs{}

for _, entry := range entries {
parts := strings.Split(entry, ":")
if len(parts) != 3 {
continue
}
aclType := parts[0]
qualifier := parts[1]
permissions := parts[2]

acl.SetEntry(aclType, qualifier, permissions)
}

return acl
}
Loading