summaryrefslogtreecommitdiff
path: root/lib/puppet
diff options
context:
space:
mode:
authorRaphaël Pinson <raphael.pinson@camptocamp.com>2013-01-18 21:54:35 +0100
committerRaphaël Pinson <raphael.pinson@camptocamp.com>2013-01-18 22:02:13 +0100
commitd568c4e0f7a6323cf462045159e8203b4715e196 (patch)
tree0147b0ca4dbf015204ae454846c7ebfeef852e9a /lib/puppet
parent41bc722139028929b9ab1f9a14b318d1a23206f9 (diff)
downloadpuppet-stdlib-d568c4e0f7a6323cf462045159e8203b4715e196.tar.gz
puppet-stdlib-d568c4e0f7a6323cf462045159e8203b4715e196.tar.bz2
validate_augeas: Ensure tmpfile is closed and unlinked
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/functions/validate_augeas.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/puppet/parser/functions/validate_augeas.rb b/lib/puppet/parser/functions/validate_augeas.rb
index 273b954..a407118 100644
--- a/lib/puppet/parser/functions/validate_augeas.rb
+++ b/lib/puppet/parser/functions/validate_augeas.rb
@@ -41,8 +41,11 @@ module Puppet::Parser::Functions
# Test content in a temporary file
tmpfile = Tempfile.new("validate_augeas")
- tmpfile.write(content)
- tmpfile.close
+ begin
+ tmpfile.write(content)
+ ensure
+ tmpfile.close
+ end
# Check for syntax
lens = args[1]
@@ -68,6 +71,7 @@ module Puppet::Parser::Functions
end
ensure
aug.close
+ tmpfile.unlink
end
end
end