You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Brian Hirt <bh...@mobygames.com> on 2003/12/08 19:08:38 UTC

should we be using tempnam() ?

i think that libapreq shouldn't be using tempnam()    It frustraiting 
that you can't force tempnam to use a given directory via some sort of 
api.   this makes the TEMP_DIR argument to Apache::Request behave 
inconsistently depending on what environment variables may or may not 
be set.   If you tell an object to put temp files in a certain place, 
you expect it to behave that way.  Also, with the way the current 
ApacheRequest_tmpfile() code is written it's hard to figure out what 
went wrong, because you can't really print the returned name from 
tempnam() making it even harder to track down the fact that tempnam() 
returned a file name in a different one than you asked Apache::Request 
to put it.

tempnam isn't posix, and even the manpage on most linux systems say:

BUGS:
        The precise meaning of ‘appropriate’ is undefined;  it  is  
unspecified
        how  accessibility  of a directory is determined.  Never use 
this func-
        tion. Use mkstemp(3) instead.

I propose that we follow this good advice and use mkstemp instead.   
The change is fairly easy to do, and will certainly avoid headaches 
that i'm sure many of us have run into.

I see that somewhere between apreq1.1 and 1.3 the man page was updated 
to mention this, so i know i'm not the only one who's been bitten by 
this.

any objections if i send in a patch?

-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html