Skip to content

Commit

Permalink
inline execve
Browse files Browse the repository at this point in the history
  • Loading branch information
jfroy committed Oct 30, 2024
1 parent a8df137 commit 753b731
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tools/container/wrapper/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 753b731

Please sign in to comment.