From f1f0f37dc142dc1687df1750c0d8c8fe1f79111a Mon Sep 17 00:00:00 2001 From: baude Date: Wed, 21 Feb 2018 09:43:28 -0600 Subject: Correct exit code 126 and 127 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The exit codes for 126 and 127 were reversed. For the record, the exit codes used are as follows: * 125 if ‘chroot’ itself fails * 126 if COMMAND is found but cannot be invoked * 127 if COMMAND cannot be found This resolves issue #367 Signed-off-by: baude Closes: #378 Approved by: baude --- cmd/podman/run.go | 4 ++-- test/e2e/run_exit_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 2f3468fd2..169fe6645 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -80,9 +80,9 @@ func runCmd(c *cli.Context) error { logrus.Debug("new container created ", ctr.ID()) if err := ctr.Init(); err != nil { // This means the command did not exist - exitCode = 126 + exitCode = 127 if strings.Index(err.Error(), "permission denied") > -1 { - exitCode = 127 + exitCode = 126 } return err } diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go index 3b9e08b5e..b381d0613 100644 --- a/test/e2e/run_exit_test.go +++ b/test/e2e/run_exit_test.go @@ -35,13 +35,13 @@ var _ = Describe("Podman run exit", func() { }) It("podman run exit 126", func() { - result := podmanTest.Podman([]string{"run", ALPINE, "foobar"}) + result := podmanTest.Podman([]string{"run", ALPINE, "/etc"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(126)) }) It("podman run exit 127", func() { - result := podmanTest.Podman([]string{"run", ALPINE, "/etc"}) + result := podmanTest.Podman([]string{"run", ALPINE, "foobar"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(127)) }) -- cgit v1.2.3-54-g00ecf