From 0f94e9bdc6720e52e1a8ce1032ec9ab9b17dcac2 Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Thu, 21 Mar 2024 14:31:39 +0100 Subject: [PATCH] eos: fixed error reporting for too large recycle bin listing --- changelog/unreleased/recycle-fix.md | 6 ++++++ pkg/eosclient/eosbinary/eosbinary.go | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/recycle-fix.md diff --git a/changelog/unreleased/recycle-fix.md b/changelog/unreleased/recycle-fix.md new file mode 100644 index 0000000000..4772657355 --- /dev/null +++ b/changelog/unreleased/recycle-fix.md @@ -0,0 +1,6 @@ +Bugfix: eos: fixed error reporting for too large recycle bin listing + +EOS returns E2BIG, which internally gets converted to PermissionDenied +and has to be properly handled in this case. + +https://github.com/cs3org/reva/pull/4591 diff --git a/pkg/eosclient/eosbinary/eosbinary.go b/pkg/eosclient/eosbinary/eosbinary.go index 17322d73e8..c8d080757a 100644 --- a/pkg/eosclient/eosbinary/eosbinary.go +++ b/pkg/eosclient/eosbinary/eosbinary.go @@ -265,7 +265,11 @@ func (c *Client) executeEOS(ctx context.Context, cmdArgs []string, auth eosclien // eos reports back error code 1 (EPERM) when ? // eos reports back error code 7 (E2BIG) when the user is not allowed to read the directory // eos reports back error code 22 (EINVAL) when the user is not allowed to enter the instance - err = errtypes.PermissionDenied(errBuf.String()) + errString := errBuf.String() + if errString == "" { + errString = fmt.Sprintf("rc = %d", exitStatus) + } + err = errtypes.PermissionDenied(errString) } } } @@ -794,7 +798,13 @@ func (c *Client) ListDeletedEntries(ctx context.Context, auth eosclient.Authoriz args := []string{"recycle", "ls", "-m", d.Format("2006/01/02"), fmt.Sprintf("%d", maxentries+1)} stdout, _, err := c.executeEOS(ctx, args, auth) if err != nil { - return nil, err + switch err.(type) { + case errtypes.IsPermissionDenied: + // in this context, this is an E2BIG that gets converted to PermissionDenied by executeEOS() + return nil, errtypes.BadRequest("list too long") + default: + return nil, err + } } list, err := parseRecycleList(stdout)