diff --git a/changelog/unreleased/fix-create-version-folder-eos.md b/changelog/unreleased/fix-create-version-folder-eos.md new file mode 100644 index 0000000000..1a4fdb308c --- /dev/null +++ b/changelog/unreleased/fix-create-version-folder-eos.md @@ -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 diff --git a/pkg/eosclient/eosbinary/eosbinary.go b/pkg/eosclient/eosbinary/eosbinary.go index 37db6f5028..0cd76c87c0 100644 --- a/pkg/eosclient/eosbinary/eosbinary.go +++ b/pkg/eosclient/eosbinary/eosbinary.go @@ -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 } } @@ -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)