first bunch of patches with mkstemp()
Russ Allbery
rra at stanford.edu
Fri Apr 7 20:28:58 UTC 2000
Matus \"fantomas\" Uhlar <uhlar at fantomas.sk> writes:
> ok, I can rewrite those files, i can create function that returns opened
> temporary FILE; should I make new .c ?
The autoconf macro AC_REPLACE_FUNC() will check whether a host has a
particular function, and if not will add .c to the end of the name of the
function and set up the Makefiles to try to compile that file and add it
to libinn. So for autoconf to work nicely, any function that should be
compiled only if the host doesn't have it should be in its own .c file
named after the function.
Most hosts already have a function that returns a temporary FILE *, BTW
(namely tmpfile). I'd be inclined to use the native implementation if
it's there. I know OpenBSD's man page recommends to always use mkstemp
and not rely on tmpfile due to flaws in old implementations of tmpfile,
but on most modern operating systems tmpfile is equivalent in strength to
mkstemp (and often even implemented by using it under the hood). And by
using standard functions, we can take advantage of any security fixes to
the underlying operating system.
The difference between mkstemp and tmpfile, of course (besides the fact
that the first returns a file descriptor and the second a FILE *), is that
mkstemp leaves the file linked in so that it can be passed to other
processes, while tmpfile unlinks the file and makes it truly temporary.
I'm guessing that most of INN actually wants to use tmpfile, though. If
there are a lot of functions that need a FILE * and need it to stick
around, it may be worth writing a function that wraps mkstemp in an fdopen
call.
(I'm of course open to being persuaded if you think the above approach
isn't the best. :))
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
More information about the inn-patches
mailing list