From 1745d4e83155d72e49f99e7ad10918dea6bf60cd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 7 Jul 2013 20:50:53 -0700 Subject: [PATCH] provisioner/shell: close source script file handle --- provisioner/shell/provisioner.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index f027c5944..3d7571c0d 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -165,6 +165,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { if err != nil { return fmt.Errorf("Error opening shell script: %s", err) } + defer f.Close() log.Printf("Uploading %s => %s", path, p.config.RemotePath) err = comm.Upload(p.config.RemotePath, f) @@ -172,6 +173,9 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { return fmt.Errorf("Error uploading shell script: %s", err) } + // Close the original file since we copied it + f.Close() + // Flatten the environment variables flattendVars := strings.Join(p.config.Vars, " ")