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

Fix stat file for a read only share #3765

Merged
merged 2 commits into from
Apr 3, 2023
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
9 changes: 9 additions & 0 deletions changelog/unreleased/fix-create-version-folder-eos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bugfix: Fix create version folder in EOS driver

In a read only share, a stat could fail, beacause the EOS
storage driver was not able to create the version folder
for a file in case this did not exist.
This fixes this bug impersonating the owner of the
file when creating the version folder.

https://github.com/cs3org/reva/pull/3765
10 changes: 7 additions & 3 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,11 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, auth eosclient.Authoriza
}

if c.opt.VersionInvariant && !isVersionFolder(path) && !info.IsDir {
if inode, err := c.getVersionFolderInode(ctx, auth, path); err == nil {
ownerAuth := eosclient.Authorization{Role: eosclient.Role{
UID: strconv.FormatUint(info.UID, 10),
GID: strconv.FormatUint(info.GID, 10),
}}
if inode, err := c.getVersionFolderInode(ctx, auth, ownerAuth, path); err == nil {
info.Inode = inode
}
}
Expand Down Expand Up @@ -837,11 +841,11 @@ func (c *Client) GenerateToken(ctx context.Context, auth eosclient.Authorization
return strings.TrimSpace(stdout), err
}

func (c *Client) getVersionFolderInode(ctx context.Context, auth eosclient.Authorization, p string) (uint64, error) {
func (c *Client) getVersionFolderInode(ctx context.Context, auth, ownerAuth eosclient.Authorization, p string) (uint64, error) {
versionFolder := getVersionFolder(p)
md, err := c.getRawFileInfoByPath(ctx, auth, versionFolder)
if err != nil {
if err = c.CreateDir(ctx, auth, versionFolder); err != nil {
if err = c.CreateDir(ctx, ownerAuth, versionFolder); err != nil {
return 0, err
}
md, err = c.getRawFileInfoByPath(ctx, auth, versionFolder)
Expand Down