store the temp files used for testing with visudo at '/tmp'
authorDan Bode <bodepd@gmail.com>
Tue, 2 Nov 2010 14:50:23 +0000 (09:50 -0500)
committerDan Bode <bodepd@gmail.com>
Tue, 2 Nov 2010 14:50:23 +0000 (09:50 -0500)
if the visuo check fails, keep the old files around.

lib/puppet/provider/sudoers/parsed.rb

index 46afa93..750d009 100644 (file)
@@ -241,7 +241,7 @@ Puppet::Type.type(:sudoers).provide(
   #
   def self.verify_sudo_line(line)
     # path is currently hardcoded, needs to be fixed
-    base = '/etc/sudoers
+    base = '/tmp/
     # find a tmp file that does not exist
     # this should be built into Ruby?
     path = "#{base}.puppettmp_#{rand(10000)}"
@@ -253,9 +253,8 @@ Puppet::Type.type(:sudoers).provide(
       visudo("-cf", path)
     rescue => detail
       raise Puppet::Error, "visudo failed for line: #{line}, #{detail}"
-    ensure 
-      File.unlink(path) if FileTest.exists?(path)
     end
+    File.unlink(path) if FileTest.exists?(path)
   end
 
   # convert arrays into to , joined lists