On 07.10.2024, at 17:59, Andrew Piskorski <a...@piskorski.com> wrote: > > On Mon, Oct 07, 2024 at 12:54:32PM +0200, Gustaf Neumann (sslmail) wrote: > >> However, there are many cases, where existing programs use "ns_mkstemp", >> which cannot be replaced easily. When looking at OpenACS, I see 33 cases like >> >> - the temporary name is passed to an external program (e.g. "tar", "zip", >> image creation), or >> - the temporary name is passed to a Tcl function expecting a filename (e.g. >> "file copy"). > > Interesting. It sounds like are no 100% good solutions for this, and > in fact there CAN'T be.
This is right in the sense of “there can’t be a solution free of possible race conditions unless the code is refactored” (e.g. let the NaviServer application write to the temp file rather than the external program) > > I'd lean towards turning ns_mktemp into a wrapper around Tcl's "file > tempfile". That calls TclUnixOpenTemporaryFile() and thus mkstemp() > or mkstemps(), but it looks like Tcl has already done the necessary > work What speaks against using the Tcl scripted approach is that so far, we support NaviServer with tcl8.5. “file tempfile” was introduced in Tcl 8.6. Furthermore, TclUnixOpenTemporaryFile() is just for Unix, and not part of the public API (starting with “Tcl_”). But providing this support is not a big thing, since we have in NaviServer since a while support for mkstemp() also for windows (named ns_mkstemp)), since we use this call internally on several places. I’ll cook something up which is most version and platform independent, backward compatible, providing depreciation messages, which can be turned off for “hopeless cases” when admins get annoyed about to many depreciation messages. all the best -g _______________________________________________ naviserver-devel mailing list naviserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/naviserver-devel