Re: Creating temporary files
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Creating temporary files

From: Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at>
Date: Tue Dec 20 2005 - 13:29:06 CET

opaquay@gillam-fei.be <opaquay@gillam-fei.be> wrote:
> file_${my_server_socket}1
> file_${my_server_socket}2
> ...
> file_${my_server_socket}16
> and assume that temporary file names for 2 concurent apps won't clash ?

The server-socket's name is surely unsafe: it won't reflect
the actual source-port (that would at least *seem* ok), but
sock3, sock4, ... thus will be roughly the same for
all processes.

If you change that to actually extract the source-port,
this is probably still unsafe, because source-ports
can principially be non-unique as long as the target
is unique. If $server_ip and port are not constant
across all processes, you're not safe that way.

Depending on your context, the safest choice might be to
pass a unique parameter to each process, and use that as
part of the filename.
If the files only exist while the program is running,
you can of course also use [pid].

Whatever per-process data you end up using, if it can
possibly end with a number, you should really add another
underscore before the final number you append, to
prevent rare-but-possible clashes:
like: file_xyx421_6 and file_xyx42_16
Received on Fri Dec 23 19:02:29 2005