Skip to content

Commit

Permalink
Set sys_acl to fileinfo directly, not hidden in attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Geens committed Oct 25, 2024
1 parent ad0b13f commit 156848b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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
}

0 comments on commit 156848b

Please sign in to comment.