]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
validate_augeas: Ensure tmpfile is closed and unlinked
authorRaphaël Pinson <raphael.pinson@camptocamp.com>
Fri, 18 Jan 2013 20:54:35 +0000 (21:54 +0100)
committerRaphaël Pinson <raphael.pinson@camptocamp.com>
Fri, 18 Jan 2013 21:02:13 +0000 (22:02 +0100)
lib/puppet/parser/functions/validate_augeas.rb

index 273b9548127bce53e7b2cd23a5ef48f3a5e08b0f..a40711835b49b1153e5b4ced8c1645206f197465 100644 (file)
@@ -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