From 0c1e76a22103fed5fcde449a1aa2bde9bdda7d32 Mon Sep 17 00:00:00 2001 From: Jean-Francois Roy Date: Wed, 30 Oct 2024 08:57:21 -0700 Subject: [PATCH] inline execve Signed-off-by: Jean-Francois Roy --- tools/container/wrapper/wrapper.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/container/wrapper/wrapper.go b/tools/container/wrapper/wrapper.go index 9c9761aa..ac6ef90f 100644 --- a/tools/container/wrapper/wrapper.go +++ b/tools/container/wrapper/wrapper.go @@ -42,11 +42,16 @@ func main() { } argv := []string{"runc"} argv = append(argv, os.Args[1:]...) - execve(program, argv, os.Environ()) + if err := unix.Exec(program, argv, os.Environ()); err != nil { + log.Fatalf("failed to exec %s: %v", program, err) + } } argv := makeArgv(program) envv := makeEnvv(program) - execve(program+".real", argv, envv) + if err := unix.Exec(program+".real", argv, envv); err != nil { + log.Fatalf("failed to exec %s: %v", program+".real", err) + } + } func isRuntimeWrapper(program string) bool { @@ -107,9 +112,3 @@ func makeEnvv(program string) []string { } return append(env, os.Environ()...) } - -func execve(program string, argv []string, envv []string) { - if err := unix.Exec(program, argv, envv); err != nil { - log.Fatalf("failed to exec %s: %v", program, err) - } -}