From 9794702db9dd36bf07162786f1ad035769ca20b7 Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Wed, 15 Feb 2023 13:06:04 -0500 Subject: [PATCH] daemon: handle EISDIR error from runtime Go 1.20 made a change to the behaviour of package "os/exec" which was not mentioned in the release notes: https://github.com/golang/go/commit/2b8f21409480931b45c983853a78dc7984ed634e Attempts to execute a directory now return syscall.EISDIR instead of syscall.EACCESS. Check for EISDIR errors from the runtime and fudge the returned error message to maintain compatibility with existing versions of docker/cli when using a version of runc compiled with Go 1.20+. Signed-off-by: Cory Snider (cherry picked from commit 713e02e03e3675f58c4ed31396cd65233d4a1766) Signed-off-by: Cory Snider --- daemon/errors.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/daemon/errors.go b/daemon/errors.go index 6f9eb54039..a810c70688 100644 --- a/daemon/errors.go +++ b/daemon/errors.go @@ -154,6 +154,17 @@ func translateContainerdStartErr(cmd string, setExitCode func(int), err error) e retErr = startInvalidConfigError(errDesc) } + // Go 1.20 changed the error for attempting to execute a directory from + // syscall.EACCESS to syscall.EISDIR. Unfortunately docker/cli checks + // whether the error message contains syscall.EACCESS.Error() to + // determine whether to exit with code 126 or 125, so we have little + // choice but to fudge the error string. + if contains(errDesc, syscall.EISDIR.Error()) { + errDesc += ": " + syscall.EACCES.Error() + setExitCode(126) + return startInvalidConfigError(errDesc) + } + // attempted to mount a file onto a directory, or a directory onto a file, maybe from user specified bind mounts if contains(errDesc, syscall.ENOTDIR.Error()) { errDesc += ": Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type"