Permalink
Browse files

stage1-fly/run: allow non absolute commands to be run

changes stage1-fly to convert a command name into an absolute path so
that syscall.Exec is able to properly execute it.
  • Loading branch information...
samm81 committed Nov 14, 2017
1 parent a1a97d4 commit 7ba8208176f4a6cb45ef3d8d95d7ff2f49ec967f
Showing with 11 additions and 0 deletions.
  1. +11 −0 stage1_fly/run/main.go
@@ -460,6 +460,17 @@ func stage1(rp *stage1commontypes.RuntimePod) int {
return 254
}
// syscall.Exec takes a path and not a command name, so in the event that args[0] is a command name we have to convert it into a path
path, err := stage1initcommon.FindBinPath(p, &ra)
if err != nil {
log.PrintE(fmt.Sprintf("can't find the absolute executable for %q", args[0]), err)
return 254
}
if path != args[0] {
diag.Printf("converting args[0] (%q) into an absolute path: %q", args[0], path)
args[0] = path
}
diag.Printf("chroot to %q", rfs)
if err := syscall.Chroot(rfs); err != nil {
log.PrintE("can't chroot", err)

0 comments on commit 7ba8208

Please sign in to comment.