From: Raphaƫl Pinson Date: Fri, 18 Jan 2013 20:54:35 +0000 (+0100) Subject: validate_augeas: Ensure tmpfile is closed and unlinked X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=d568c4e0f7a6323cf462045159e8203b4715e196;p=puppet-stdlib.git validate_augeas: Ensure tmpfile is closed and unlinked --- 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