Skip to content

Commit

Permalink
Fix broken permissions in PROPFIND on project folder over gRPC
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.
  • Loading branch information
jessegeens committed Oct 25, 2024
1 parent 10664f4 commit 950b1c5
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 @@ -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"] != "" {
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
}

0 comments on commit 950b1c5

Please sign in to comment.