libct/system: Exec: wrap the error

If the container binary to be run is removed in between runc create
and runc start, the latter spits the following error:

> can't exec user process: no such file or directory

This is a bit confusing since we don't see what file is missing.

Wrap the unix.Exec error into os.PathError, like in many other cases,
to provide some context. Remove the error wrapping from
(*linuxStandardInit).Init as it is now redundant.

With this patch, the error is now:

> exec /bin/false: no such file or directory

Reported-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-10-07 10:25:55 -07:00
parent 3a5223d010
commit 794cd66df8
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -4,6 +4,7 @@
package system
import (
"os"
"os/exec"
"unsafe"
@@ -43,7 +44,7 @@ func Exec(cmd string, args []string, env []string) error {
for {
err := unix.Exec(cmd, args, env)
if err != unix.EINTR { //nolint:errorlint // unix errors are bare
return err
return &os.PathError{Op: "exec", Path: cmd, Err: err}
}
}
}