cmd/vrun: Use exec.LookPath
Use exec.LookPath to find the binary to execute. So we can run "vrun
bash" instead of "vrun /bin/bash".
Change-Id: I7153c0057f7ea416f0d04c5c918cadcec544548f
diff --git a/cmd/vrun/vrun.go b/cmd/vrun/vrun.go
index e604d9f..4bdafd1 100644
--- a/cmd/vrun/vrun.go
+++ b/cmd/vrun/vrun.go
@@ -6,6 +6,7 @@
import (
"os"
+ "os/exec"
"path/filepath"
"syscall"
"time"
@@ -126,7 +127,12 @@
}
conn.Close()
}
- err := syscall.Exec(cmd[0], cmd, os.Environ())
+ p, err := exec.LookPath(cmd[0])
+ if err != nil {
+ vlog.Errorf("Couldn't find %q", cmd[0])
+ return err
+ }
+ err = syscall.Exec(p, cmd, os.Environ())
vlog.Errorf("Couldn't exec %s.", cmd[0])
return err
}