Skip to content

Commit

Permalink
map more permission denied codes (#1269)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic authored Oct 23, 2020
1 parent 9379fa0 commit 5017ab4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/handle-more-eos-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Handle more eos errors

We now treat E2BIG, EACCES as a permission error, which occur, eg. when acl checks fail and return a permission denied error.

https://github.com/cs3org/reva/pull/1269
14 changes: 8 additions & 6 deletions pkg/eosclient/eosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (c *Client) execute(ctx context.Context, cmd *exec.Cmd) (string, string, er
switch exitStatus {
case 0:
err = nil
case 2:
case int(syscall.ENOENT):
err = errtypes.NotFound(errBuf.String())
}
}
Expand All @@ -208,7 +208,7 @@ func (c *Client) execute(ctx context.Context, cmd *exec.Cmd) (string, string, er
env := fmt.Sprintf("%s", cmd.Env)
log.Info().Str("args", args).Str("env", env).Int("exit", exitStatus).Msg("eos cmd")

if err != nil && exitStatus != 2 { // don't wrap the errtypes.NotFoundError
if err != nil && exitStatus != int(syscall.ENOENT) { // don't wrap the errtypes.NotFoundError
err = errors.Wrap(err, "eosclient: error while executing command")
}

Expand Down Expand Up @@ -249,10 +249,12 @@ func (c *Client) executeEOS(ctx context.Context, cmd *exec.Cmd) (string, string,
switch exitStatus {
case 0:
err = nil
case 2:
case int(syscall.ENOENT):
err = errtypes.NotFound(errBuf.String())
case 1, 22:
// eos reports back error code 22 when the user is not allowed to enter the instance
case int(syscall.EPERM), int(syscall.E2BIG), int(syscall.EINVAL):
// 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())
}
}
Expand All @@ -262,7 +264,7 @@ func (c *Client) executeEOS(ctx context.Context, cmd *exec.Cmd) (string, string,
env := fmt.Sprintf("%s", cmd.Env)
log.Info().Str("args", args).Str("env", env).Int("exit", exitStatus).Str("err", errBuf.String()).Msg("eos cmd")

if err != nil && exitStatus != 2 { // don't wrap the errtypes.NotFoundError
if err != nil && exitStatus != int(syscall.ENOENT) { // don't wrap the errtypes.NotFoundError
err = errors.Wrap(err, "eosclient: error while executing command")
}

Expand Down

0 comments on commit 5017ab4

Please sign in to comment.