mirror of
https://github.com/cs3org/reva.git
synced 2025-04-18 13:44:12 +03:00
eosgrpc: fixed panic when files have no SysACLs, parent == nil and versionFolder has ACLs
This commit is contained in:
parent
0dd18fb09b
commit
700f5cc638
6
changelog/unreleased/fix-eosgrpc-panic.md
Normal file
6
changelog/unreleased/fix-eosgrpc-panic.md
Normal file
@ -0,0 +1,6 @@
|
||||
Bugfix: eosgrpc: fixed panic with ACLs handling
|
||||
|
||||
Fixes a panic that happens when listing a folder where
|
||||
files have no SysACLs, parent == nil and versionFolder has ACLs.
|
||||
|
||||
https://github.com/cs3org/reva/pull/5143
|
@ -1305,34 +1305,29 @@ func (c *Client) List(ctx context.Context, auth eosclient.Authorization, dpath s
|
||||
}
|
||||
|
||||
for _, fi := range mylst {
|
||||
// For files, inherit ACLs from the parent
|
||||
// And set the inode to that of their version folder
|
||||
if !fi.IsDir && !isVersionFolder(dpath) {
|
||||
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 = &acl.ACLs{
|
||||
Entries: parent.SysACL.Entries,
|
||||
}
|
||||
} else {
|
||||
fi.SysACL.Entries = append(fi.SysACL.Entries, parent.SysACL.Entries...)
|
||||
}
|
||||
if fi.SysACL == nil {
|
||||
fi.SysACL = &acl.ACLs{
|
||||
Entries: []*acl.Entry{},
|
||||
}
|
||||
|
||||
// If there is a version folder then use its info
|
||||
// to emulate the invariability of the fileid
|
||||
// If there is no version folder then create one
|
||||
}
|
||||
if !fi.IsDir && !isVersionFolder(dpath) {
|
||||
// For files, inherit ACLs from the parent
|
||||
if parent != nil && parent.SysACL != nil {
|
||||
fi.SysACL.Entries = append(fi.SysACL.Entries, parent.SysACL.Entries...)
|
||||
}
|
||||
// If there is a version folder then use its inode
|
||||
// to implement the invariance of the fileid across updates
|
||||
versionFolderPath := getVersionFolder(fi.File)
|
||||
if vf, ok := versionFolders[versionFolderPath]; ok {
|
||||
fi.Inode = vf.Inode
|
||||
if vf.SysACL != nil {
|
||||
log.Debug().Str("func", "List").Str("path", dpath).Msg("vf.SysACL is nil")
|
||||
fi.SysACL.Entries = append(fi.SysACL.Entries, vf.SysACL.Entries...)
|
||||
}
|
||||
for k, v := range vf.Attrs {
|
||||
fi.Attrs[k] = v
|
||||
}
|
||||
} else if err := c.CreateDir(ctx, *ownerAuth, versionFolderPath); err == nil { // Create the version folder if it doesn't exist
|
||||
} else if err := c.CreateDir(ctx, *ownerAuth, versionFolderPath); err == nil {
|
||||
// Create the version folder if it doesn't exist
|
||||
if md, err := c.GetFileInfoByPath(ctx, auth, versionFolderPath); err == nil {
|
||||
fi.Inode = md.Inode
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user