From cd0cae207cd4d7258f1dd7f47f5dcd77e06bd56b Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Wed, 25 Sep 2013 03:20:22 -0700 Subject: [PATCH] pass chroot command to /bin/sh this allows us to specify an arbitrary chroot command, i.e. for sudo --- builder/amazon/chroot/communicator.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/builder/amazon/chroot/communicator.go b/builder/amazon/chroot/communicator.go index 3e1e8deda..d434da8f1 100644 --- a/builder/amazon/chroot/communicator.go +++ b/builder/amazon/chroot/communicator.go @@ -13,13 +13,14 @@ import ( // Communicator is a special communicator that works by executing // commands locally but within a chroot. type Communicator struct { - Chroot string - ChrootCommand string + Chroot string + ChrootCommand string } 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.Stdout = cmd.Stdout localCmd.Stderr = cmd.Stderr