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

map more permission denied codes #1269

Merged
merged 1 commit into from
Oct 23, 2020
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
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