From a142af3206fb82bcb56e1471d9d486457aba1dc3 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 10 Mar 2016 20:29:23 -0600 Subject: [PATCH] provisioner/remote-exec: Clear out scripts after uploading Prevents residual script contents from remaining on machine. Fixes #483 --- builtin/provisioners/remote-exec/resource_provisioner.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/builtin/provisioners/remote-exec/resource_provisioner.go b/builtin/provisioners/remote-exec/resource_provisioner.go index 39e5f9583ac7..f3524a31ce70 100644 --- a/builtin/provisioners/remote-exec/resource_provisioner.go +++ b/builtin/provisioners/remote-exec/resource_provisioner.go @@ -192,6 +192,13 @@ func (p *ResourceProvisioner) runScripts( return fmt.Errorf("Error starting script: %v", err) } + // Upload a blank follow up file in the same path to prevent residual + // script contents from remaining on remote machine + empty := bytes.NewReader([]byte("")) + if err := comm.Upload(remotePath, empty); err != nil { + return fmt.Errorf("Failed to upload empty follow up script: %v", err) + } + return nil }) if err == nil {