Skip to content

Commit 950b1c5

Browse files
committed
Fix broken permissions in PROPFIND on project folder over gRPC
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.
1 parent 10664f4 commit 950b1c5

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Bugfix: broken PROPFIND perms on gRPC
2+
3+
When using the EOS gRPC stack, the permissions returned by PROPFIND
4+
on a folder in a project were erroneous because ACL permissions were
5+
being ignored. This stems from a bug in grpcMDResponseToFileInfo,
6+
where the SysACL attribute of the FileInfo struct was not being populated.
7+
8+
See: https://github.com/cs3org/reva/pull/4901

pkg/eosclient/eosgrpc/eosgrpc.go

+31-1
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,9 @@ func (c *Client) List(ctx context.Context, auth eosclient.Authorization, dpath s
12421242
if parent != nil && parent.SysACL != nil {
12431243
if fi.SysACL == nil {
12441244
log.Warn().Str("func", "List").Str("path", dpath).Str("SysACL is nil, taking parent", "").Msg("grpc response")
1245-
fi.SysACL.Entries = parent.SysACL.Entries
1245+
fi.SysACL = &acl.ACLs{
1246+
Entries: parent.SysACL.Entries,
1247+
}
12461248
} else {
12471249
fi.SysACL.Entries = append(fi.SysACL.Entries, parent.SysACL.Entries...)
12481250
}
@@ -1629,6 +1631,10 @@ func (c *Client) grpcMDResponseToFileInfo(ctx context.Context, st *erpc.MDRespon
16291631
fi.Attrs[strings.TrimPrefix(k, "user.")] = string(v)
16301632
}
16311633

1634+
if fi.Attrs["sys.acl"] != "" {
1635+
fi.SysACL = aclAttrToAclStruct(fi.Attrs["sys.acl"])
1636+
}
1637+
16321638
fi.TreeSize = uint64(st.Cmd.TreeSize)
16331639
fi.Size = fi.TreeSize
16341640
// TODO(lopresti) this info is missing in the EOS Protobuf, cf. EOS-5974
@@ -1649,6 +1655,10 @@ func (c *Client) grpcMDResponseToFileInfo(ctx context.Context, st *erpc.MDRespon
16491655
fi.Attrs[strings.TrimPrefix(k, "user.")] = string(v)
16501656
}
16511657

1658+
if fi.Attrs["sys.acl"] != "" {
1659+
fi.SysACL = aclAttrToAclStruct(fi.Attrs["sys.acl"])
1660+
}
1661+
16521662
fi.Size = st.Fmd.Size
16531663

16541664
if st.Fmd.Checksum != nil {
@@ -1663,3 +1673,23 @@ func (c *Client) grpcMDResponseToFileInfo(ctx context.Context, st *erpc.MDRespon
16631673
}
16641674
return fi, nil
16651675
}
1676+
1677+
func aclAttrToAclStruct(aclAttr string) *acl.ACLs {
1678+
entries := strings.Split(aclAttr, ",")
1679+
1680+
acl := &acl.ACLs{}
1681+
1682+
for _, entry := range entries {
1683+
parts := strings.Split(entry, ":")
1684+
if len(parts) != 3 {
1685+
continue
1686+
}
1687+
aclType := parts[0]
1688+
qualifier := parts[1]
1689+
permissions := parts[2]
1690+
1691+
acl.SetEntry(aclType, qualifier, permissions)
1692+
}
1693+
1694+
return acl
1695+
}

0 commit comments

Comments
 (0)