Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit ACLs for files from parent directories #2174

Merged
merged 4 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/unreleased/eos-file-perms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Inherit ACLs for files from parent directories

https://github.com/cs3org/reva/pull/2174
24 changes: 21 additions & 3 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, auth eosclient.Authoriz
info.Inode = inode
}

return info, nil
return c.mergeParentACLsForFiles(ctx, auth, info), nil
}

// GetFileInfoByFXID returns the FileInfo by the given file id in hexadecimal
Expand All @@ -472,7 +472,13 @@ func (c *Client) GetFileInfoByFXID(ctx context.Context, auth eosclient.Authoriza
if err != nil {
return nil, err
}
return c.parseFileInfo(stdout)

info, err := c.parseFileInfo(stdout)
if err != nil {
return nil, err
}

return c.mergeParentACLsForFiles(ctx, auth, info), nil
}

// GetFileInfoByPath returns the FilInfo at the given path
Expand All @@ -493,7 +499,19 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, auth eosclient.Authoriza
}
}

return info, nil
return c.mergeParentACLsForFiles(ctx, auth, info), nil
}

func (c *Client) mergeParentACLsForFiles(ctx context.Context, auth eosclient.Authorization, info *eosclient.FileInfo) *eosclient.FileInfo {
// We need to inherit the ACLs for the parent directory as these are not available for files
if !info.IsDir {
parentInfo, err := c.GetFileInfoByPath(ctx, auth, path.Dir(info.File))
// Even if this call fails, at least return the current file object
if err == nil {
info.SysACL.Entries = append(info.SysACL.Entries, parentInfo.SysACL.Entries...)
}
}
return info
}

// SetAttr sets an extended attributes on a path.
Expand Down
17 changes: 15 additions & 2 deletions pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,19 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, auth eosclient.Authoriz
}

log.Debug().Str("func", "GetFileInfoByInode").Uint64("inode", inode).Msg("")
return info, nil
return c.mergeParentACLsForFiles(ctx, auth, info), nil
}

func (c *Client) mergeParentACLsForFiles(ctx context.Context, auth eosclient.Authorization, info *eosclient.FileInfo) *eosclient.FileInfo {
// We need to inherit the ACLs for the parent directory as these are not available for files
if !info.IsDir {
parentInfo, err := c.GetFileInfoByPath(ctx, auth, path.Dir(info.File))
// Even if this call fails, at least return the current file object
if err == nil {
info.SysACL.Entries = append(info.SysACL.Entries, parentInfo.SysACL.Entries...)
}
}
return info
}

// SetAttr sets an extended attributes on a path.
Expand Down Expand Up @@ -627,7 +639,8 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, auth eosclient.Authoriza
}
info.Inode = inode
}
return info, nil

return c.mergeParentACLsForFiles(ctx, auth, info), nil
}

// GetFileInfoByFXID returns the FileInfo by the given file id in hexadecimal
Expand Down