validate_augeas: Ensure tmpfile is closed and unlinked

This commit is contained in:
Raphaël Pinson 2013-01-18 21:54:35 +01:00
parent 41bc722139
commit d568c4e0f7

View 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