Merge pull request #6635 from hashicorp/fix_6493
fix chroot communicator to properly escape quotes
This commit is contained in:
commit
d606339edc
|
@ -9,6 +9,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
@ -23,8 +24,10 @@ type Communicator struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Communicator) Start(cmd *packer.RemoteCmd) error {
|
func (c *Communicator) Start(cmd *packer.RemoteCmd) error {
|
||||||
|
// need extra escapes for the command since we're wrapping it in quotes
|
||||||
|
cmd.Command = strconv.Quote(cmd.Command)
|
||||||
command, err := c.CmdWrapper(
|
command, err := c.CmdWrapper(
|
||||||
fmt.Sprintf("chroot %s /bin/sh -c \"%s\"", c.Chroot, cmd.Command))
|
fmt.Sprintf("chroot %s /bin/sh -c %s", c.Chroot, cmd.Command))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue