Use lookup path for init

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-02-21 16:17:18 -08:00
parent e90b85bdc0
commit b9bc36a8bb
2 changed files with 9 additions and 2 deletions

View file

@ -230,5 +230,6 @@ func createCommand(container *libcontainer.Container, console, logFile string, p
command.SysProcAttr = &syscall.SysProcAttr{
Cloneflags: uintptr(getNamespaceFlags(container.Namespaces)),
}
command.Env = container.Env
return command
}

View file

@ -12,6 +12,7 @@ import (
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"syscall"
)
@ -80,8 +81,13 @@ func Init(container *libcontainer.Container, uncleanRootfs, console string, pipe
return fmt.Errorf("chdir to %s %s", container.WorkingDir, err)
}
}
log.Printf("execing %s goodbye", args[0])
if err := system.Exec(args[0], args[0:], container.Env); err != nil {
name, err := exec.LookPath(args[0])
if err != nil {
return err
}
log.Printf("execing %s goodbye", name)
if err := system.Exec(name, args[0:], container.Env); err != nil {
return fmt.Errorf("exec %s", err)
}
panic("unreachable")