pass chroot command to /bin/sh

this allows us to specify an arbitrary chroot command, i.e. for sudo
This commit is contained in:
Matthew Hooker 2013-09-25 03:20:22 -07:00
parent 4f6fc96397
commit 5086ff1a4e
1 changed files with 4 additions and 3 deletions

View File

@ -19,7 +19,8 @@ type Communicator struct {
func (c *Communicator) Start(cmd *packer.RemoteCmd) error { func (c *Communicator) Start(cmd *packer.RemoteCmd) error {
localCmd := exec.Command(c.ChrootCommand, c.Chroot, "/bin/sh", "-c", cmd.Command) chrootCommand := fmt.Sprintf("%s %s %s", c.ChrootCommand, c.Chroot, cmd.Command)
localcmd := exec.Command("/bin/sh", "-c", chrootCommand)
localCmd.Stdin = cmd.Stdin localCmd.Stdin = cmd.Stdin
localCmd.Stdout = cmd.Stdout localCmd.Stdout = cmd.Stdout
localCmd.Stderr = cmd.Stderr localCmd.Stderr = cmd.Stderr