From 8afddbeab83e52261ca4a9206a8719b3dc6d58be Mon Sep 17 00:00:00 2001 From: Nathan LeClaire Date: Wed, 13 May 2015 22:19:27 -0700 Subject: [PATCH] Fix cert copying bug Signed-off-by: Nathan LeClaire --- drivers/utils.go | 3 ++- libmachine/provision/utils.go | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/utils.go b/drivers/utils.go index fb7bcc24b5..a59127ec27 100644 --- a/drivers/utils.go +++ b/drivers/utils.go @@ -30,8 +30,9 @@ func RunSSHCommandFromDriver(d Driver, command string) (ssh.Output, error) { return output, err } + log.Debugf("About to run SSH command:\n%s", command) output, err = client.Run(command) - log.Debug(fmt.Sprintf("SSH cmd err, output: %v: %s", err, output)) + log.Debugf("SSH cmd err, output: %v: %s", err, output) return output, err } diff --git a/libmachine/provision/utils.go b/libmachine/provision/utils.go index 972fca6ff6..8b368111bd 100644 --- a/libmachine/provision/utils.go +++ b/libmachine/provision/utils.go @@ -130,16 +130,20 @@ func ConfigureAuth(p Provisioner) error { return err } + // printf will choke if we don't pass a format string because of the + // dashes, so that's the reason for the '%%s' + certTransferCmdFmt := "printf '%%s' '%s' | sudo tee %s" + // These ones are for Jessie and Mike <3 <3 <3 - if _, err := p.SSHCommand(fmt.Sprintf("printf \"%s\" | sudo tee %s", string(caCert), authOptions.CaCertRemotePath)); err != nil { + if _, err := p.SSHCommand(fmt.Sprintf(certTransferCmdFmt, string(caCert), authOptions.CaCertRemotePath)); err != nil { return err } - if _, err := p.SSHCommand(fmt.Sprintf("printf \"%s\" | sudo tee %s", string(serverCert), authOptions.ServerCertRemotePath)); err != nil { + if _, err := p.SSHCommand(fmt.Sprintf(certTransferCmdFmt, string(serverCert), authOptions.ServerCertRemotePath)); err != nil { return err } - if _, err := p.SSHCommand(fmt.Sprintf("printf \"%s\" | sudo tee %s", string(serverKey), authOptions.ServerKeyRemotePath)); err != nil { + if _, err := p.SSHCommand(fmt.Sprintf(certTransferCmdFmt, string(serverKey), authOptions.ServerKeyRemotePath)); err != nil { return err }