Subject: bug#28023: fix make-temp-file race on local host

From: Eli Zaretskii <[email-masked]>
Date: Thu, 10 Aug 2017 18:35:05 +0300

> Cc: [email-masked]
> From: Paul Eggert <[email-masked]>
> Date: Wed, 9 Aug 2017 16:36:55 -0700
> 
> Eli Zaretskii wrote:
> > Perhaps you are right, and it will "just work".  I will have to try
> > (for now, I just looked at the sources and the changes, but didn't try
> > building).
> 
> It looks to me like it should just work.

Well, it's not that easy after all.  First, nt/gnulib-cfg.mk needs to
be fixed to remove the lines that disable building tempname.c and
mkostmp.c, and nt/mingw-cfg.site needs to remove the line which claims
that mkostmp is available.  Otherwise, tempname.c will not be
compiled.  This is easy to fix.

Then it turns out ms-w32.h only makes its redirections when compiling
with -Demacs, which is not what happens when Gnulib sources are
compiled.  I can fix this, but it will need a few changes in lib-src,
which currently doesn't expect 'open' to be redirected.

And finally, tempname.c calls mkdir with 2 arguments, whereas mkdir on
Windows accepts only one.  (This means Gnulib lacks a dependency,
since the tempname module should then depend on mkdir, which isn't in
lib/.)  Since we don't want the Gnulib replacement for mkdir, we will
have to change w32.c:sys_mkdir to accept 2 arguments to fix this,
unless you have a better idea.

How do you propose to proceed with this?

> You might also consider the second 
> attached patch: it removes the MS-Windows implementation of mkostemp, since the 
> generic code should just work as well.

Once the above problems are taken care of, the mkostemp part should be
easy.

Thanks.