AFAIK the file shouldn't stay past the existence of the process itself - it just needs to persist after the user is done editing it.

We can certainly use Tempfile or whatever instead. Keep in mind that ralsh has seen very few updates since its first days as a proof of concept.

On Apr 8, 2010, at 7:38 AM, Markus Roberts wrote:

I'm unsure of the use-case here, but a non-TOCTOU way of replacing
extant files (while assuring that they aren't symlinks) would, if
possible, maintain the old semantics more closely.  Conversely, if we
don't need persistence past this run, or external access, a tempfile
might be better.  Does anyone know _why_ we want these to linger?  Or
even if?

On Thu, Apr 8, 2010 at 7:06 AM, Daniel Pittman <[email protected]> wrote:
ralsh in edit mode generates a highly predictable filename; since we actually want it to linger at the end of the process, we only take care that the file
didn't exist before we tried to create it.
---
 lib/puppet/application/ralsh.rb |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/puppet/application/ralsh.rb b/lib/puppet/ application/ralsh.rb
index b9f7a58..51c3daa 100644
--- a/lib/puppet/application/ralsh.rb
+++ b/lib/puppet/application/ralsh.rb
@@ -1,6 +1,7 @@
 require 'puppet'
 require 'puppet/application'
 require 'facter'
+require 'tempfile'

 Puppet::Application.new(:ralsh) do

@@ -121,7 +122,7 @@ Puppet::Application.new(:ralsh) do
        if options[:edit]
            file = "/tmp/x2puppet-#{Process.pid}.pp"
            begin
-                File.open(file, "w") do |f|
+ File.open(file, File::WRONLY|File::CREAT| File::EXCL) do |f|
                    f.puts text
                end
                ENV["EDITOR"] ||= "vi"
--
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 .





--
-----------------------------------------------------------
The power of accurate observation is
commonly called cynicism by those
who have not got it.  ~George Bernard Shaw
------------------------------------------------------------

--
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 .



--
You don't learn anything the second time you're kicked by a mule.
    -- Anonymous Texan
---------------------------------------------------------------------
Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199

--
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