diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/adapter/containers.go | 9 | ||||
-rw-r--r-- | pkg/adapter/containers_remote.go | 2 | ||||
-rw-r--r-- | pkg/varlinkapi/containers.go | 12 |
3 files changed, 19 insertions, 4 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index 47f1b091e..a8bff187c 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -1000,7 +1000,14 @@ func (r *LocalRuntime) ExecContainer(ctx context.Context, cli *cliconfig.ExecVal streams.AttachOutput = true streams.AttachError = true - return ExecAttachCtr(ctx, ctr.Container, cli.Tty, cli.Privileged, envs, cmd, cli.User, cli.Workdir, streams, cli.PreserveFDs, cli.DetachKeys) + ec, err = ExecAttachCtr(ctx, ctr.Container, cli.Tty, cli.Privileged, envs, cmd, cli.User, cli.Workdir, streams, cli.PreserveFDs, cli.DetachKeys) + if errors.Cause(err) == define.ErrOCIRuntimePermissionDenied { + ec = 126 + } + if errors.Cause(err) == define.ErrOCIRuntimeNotFound { + ec = 127 + } + return ec, err } // Prune removes stopped containers diff --git a/pkg/adapter/containers_remote.go b/pkg/adapter/containers_remote.go index 7a9cf94b7..7fce30378 100644 --- a/pkg/adapter/containers_remote.go +++ b/pkg/adapter/containers_remote.go @@ -997,7 +997,7 @@ func (r *LocalRuntime) Commit(ctx context.Context, c *cliconfig.CommitValues, co func (r *LocalRuntime) ExecContainer(ctx context.Context, cli *cliconfig.ExecValues) (int, error) { var ( oldTermState *term.State - ec int = 125 + ec int = define.ExecErrorCodeGeneric ) // default invalid command exit code // Validate given environment variables diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go index a70a87675..fa17bed84 100644 --- a/pkg/varlinkapi/containers.go +++ b/pkg/varlinkapi/containers.go @@ -812,7 +812,7 @@ func (i *LibpodAPI) ExecContainer(call iopodman.VarlinkCall, opts iopodman.ExecO go func() { if err := virtwriter.Reader(reader, nil, nil, pipeWriter, resizeChan, nil); err != nil { ecErrChan <- ExitCodeError{ - 125, //TODO FIXME magic number, define package? + define.ExecErrorCodeGeneric, err, } } @@ -833,7 +833,15 @@ func (i *LibpodAPI) ExecContainer(call iopodman.VarlinkCall, opts iopodman.ExecO ecErr := <-ecErrChan // TODO FIXME prevent all of these conversions - if err = virtwriter.HangUp(writer, int(ecErr.ExitCode)); err != nil { + exitCode := int(ecErr.ExitCode) + if errors.Cause(ecErr.Error) == define.ErrOCIRuntimePermissionDenied { + exitCode = define.ExecErrorCodeCannotInvoke + } + if errors.Cause(ecErr.Error) == define.ErrOCIRuntimeNotFound { + exitCode = define.ExecErrorCodeNotFound + } + + if err = virtwriter.HangUp(writer, exitCode); err != nil { logrus.Errorf("ExecContainer failed to HANG-UP on %s: %s", ctr.ID(), err.Error()) } |