From: Robert Klemme Date: 2010-03-04T06:50:20+09:00 Subject: Re: A gem for handling temporary file(s)? On 03/03/2010 08:35 PM, Caleb Clausen wrote: > On 3/2/10, Albert Schlef wrote: >> Paul Harrington wrote: >>> ri Tempfile >>> >>> that'll get you started >> Thanks! I didn't know about Tempfile. >> >> Though I have a little problem: Tempfile let me *open* a new temporary >> file. But I just need to generate a temporary file *name*, which I'll >> pass to a shell command. > > I'm not expert enough to be certain about this, but by doing this > you'll be creating a tempfile race condition security hole in your > program. I think the same goes for Robert's suggestion as well. Do you mean there is a robustness issue or a security issue? I don't see a security issue here. Robustness would only be at risk if the file name generation algorithm is bad. What else am I missing? > There > may be a way to do it securely... but it's probably tricky. One > advantage of Tempfile (and similar facilities in other languages) is > that it avoids this subtle and nassty security hole. But you have to > use it the way it wants to be used, otherwise you defeat the security. > This is why you're better off rewriting this external command in ruby, > if that's possible. Or rewriting your ruby script to make it an > integral part of the external program. > > None of this may actually matter in your case... but you're the only > one with enough information to make that judgment. Albert still did not disclose what the external program should do with the temporary file. We do not even know whether it is an option to rewrite the external program. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/