remove unhelpful quotes to fix bug with reading key from a path with spaces in it.

This commit is contained in:
Megan Marsh
2020-01-14 13:57:11 -08:00
parent 06a26e74b4
commit 5980d32efb
2 changed files with 17 additions and 2 deletions
+6 -2
View File
@@ -199,7 +199,11 @@ func (d *Vagrant_2_2_Driver) vagrantCmd(args ...string) (string, string, error)
cmd.Stdout = &stdout
cmd.Stderr = &stderr
cmd.Start()
err := cmd.Start()
if err != nil {
return "", "", fmt.Errorf("Error starting vagrant command with args: %s",
strings.Join(args, " "))
}
stdoutString := ""
stderrString := ""
@@ -238,7 +242,7 @@ func (d *Vagrant_2_2_Driver) vagrantCmd(args ...string) (string, string, error)
}
}()
err := cmd.Wait()
err = cmd.Wait()
donech <- true
+11
View File
@@ -2,7 +2,9 @@ package vagrant
import (
"context"
"log"
"strconv"
"strings"
"github.com/hashicorp/packer/helper/multistep"
)
@@ -53,6 +55,15 @@ func (s *StepSSHConfig) Run(ctx context.Context, state multistep.StateBag) multi
// auth provided there.
return multistep.ActionContinue
}
log.Printf("identity file is %s", sshConfig.IdentityFile)
log.Printf("Removing quotes from identity file")
if strings.HasPrefix(sshConfig.IdentityFile, "\"") {
sshConfig.IdentityFile = sshConfig.IdentityFile[1:]
if strings.HasSuffix(sshConfig.IdentityFile, "\"") {
sshConfig.IdentityFile = sshConfig.IdentityFile[:len(sshConfig.IdentityFile)-1]
}
log.Printf("identity file is now %s", sshConfig.IdentityFile)
}
config.Comm.SSHPrivateKeyFile = sshConfig.IdentityFile
config.Comm.SSHUsername = sshConfig.User