Added a random suffex to the temporary file name and verify that
    the name is not in use (retry on collison).  No additional
    tests added as the lifetime of the temporary file is bound by
    the routine, making spec driven tests impraticable.

Signed-off-by: Markus Roberts <[email protected]>
---
 lib/puppet/type/file.rb |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 0fc2c96..66ca3b3 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -722,8 +722,11 @@ module Puppet
             remove_existing(:file)
 
             use_temporary_file = (content.length != 0)
-            path = self[:path]
-            path += ".puppettmp" if use_temporary_file
+            if use_temporary_file
+                path = "#{self[:path]}.puppettmp_#{rand(10000)}" until 
!File.exists?(path)
+              else
+                path = self[:path]
+              end
 
             mode = self.should(:mode) # might be nil
             umask = mode ? 000 : 022
-- 
1.6.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