From 156848bcbda9b1ab20c43cc7d6a295ee7f4b0162 Mon Sep 17 00:00:00 2001 From: Jesse Geens Date: Fri, 25 Oct 2024 15:56:29 +0200 Subject: [PATCH] Set sys_acl to fileinfo directly, not hidden in attrs --- pkg/eosclient/eosgrpc/eosgrpc.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 5ef56cfe7d..0e32f6f9b7 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -1633,6 +1633,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.TreeSize = uint64(st.Cmd.TreeSize) fi.Size = fi.TreeSize // TODO(lopresti) this info is missing in the EOS Protobuf, cf. EOS-5974 @@ -1653,6 +1657,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 { @@ -1667,3 +1675,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 +}