Previously this hand-coded replacing the .k5login file, which could result in
the file content getting lost if an ill-timed crash happened.  Replacing that
with the standard API resolves that, and ensures the update is atomic as far
as the user can see.
---
 lib/puppet/type/k5login.rb |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/puppet/type/k5login.rb b/lib/puppet/type/k5login.rb
index 5526fda..5174e62 100644
--- a/lib/puppet/type/k5login.rb
+++ b/lib/puppet/type/k5login.rb
@@ -2,6 +2,8 @@
 #
 # Plug-in type for handling k5login files
 
+require 'puppet/util'
+
 Puppet::Type.newtype(:k5login) do
     @doc = "Manage the .k5login file for a user.  Specify the full path to
         the .k5login file as the name and an array of principals as the
@@ -81,7 +83,9 @@ Puppet::Type.newtype(:k5login) do
 
         private
         def write(value)
-            File.open(@resource[:name], "w") { |f| f.puts value.join("\n") }
+            Puppet::Util.replace_file(@resource[:name], @mode) {
+                |f| f.puts f.puts value.join("\n")
+            }
         end
     end
 end
-- 
1.7.0.4

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to