Skip to content

Commit

Permalink
Fix broken permissions in PROPFIND on project folder over gRPC (#4901)
Browse files Browse the repository at this point in the history
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.

Co-authored-by: Jesse Geens <[email protected]>
  • Loading branch information
jessegeens and Jesse Geens authored Oct 29, 2024
1 parent 604b166 commit ce7d0f8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
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 @@ -1217,7 +1217,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 @@ -1604,6 +1606,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 @@ -1624,6 +1630,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 @@ -1638,3 +1648,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 ce7d0f8

Please sign in to comment.