From 9b5ceb52b0a1271c6d0668adeedc55869709317b Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Fri, 3 Feb 2023 17:49:12 -0500 Subject: [PATCH] cli/command/container: exit 126 on EISDIR error The error returned from "os/exec".Command when attempting to execute a directory has been changed from syscall.EACCESS to syscall.EISDIR on Go 1.20. https://github.com/golang/go/commit/2b8f21409480931b45c983853a78dc7984ed634e Consequently, any runc runtime built against Go 1.20 will return an error containing 'is a directory' and not 'permission denied'. Update the string matching so the CLI exits with status code 126 on 'is a directory' errors (EISDIR) in addition to 'permission denied' (EACCESS). Signed-off-by: Cory Snider --- cli/command/container/run.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/command/container/run.go b/cli/command/container/run.go index dcf9dca9f2..f538c04a1d 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -308,7 +308,8 @@ func runStartContainerErr(err error) error { strings.Contains(trimmedErr, "no such file or directory") || strings.Contains(trimmedErr, "system cannot find the file specified") { statusError = cli.StatusError{StatusCode: 127} - } else if strings.Contains(trimmedErr, syscall.EACCES.Error()) { + } else if strings.Contains(trimmedErr, syscall.EACCES.Error()) || + strings.Contains(trimmedErr, syscall.EISDIR.Error()) { statusError = cli.StatusError{StatusCode: 126} }