aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/movemail.c
diff options
context:
space:
mode:
authorPaul Eggert2013-08-04 09:56:56 -0700
committerPaul Eggert2013-08-04 09:56:56 -0700
commite0fdb6943066032db294720915c3bd644bf2bcd1 (patch)
tree0aa420b81dc0187e2efec3ff4fe3cf046ad1c598 /lib-src/movemail.c
parent484ab23924d39b3e26d54074fd659633e1660ef4 (diff)
downloademacs-e0fdb6943066032db294720915c3bd644bf2bcd1.tar.gz
emacs-e0fdb6943066032db294720915c3bd644bf2bcd1.zip
Fix some minor races in hosts lacking mkostemp.
Gnulib's emulation of mkostemp doesn't have races that Emacs's does. * configure.ac (mkostemp): Remove check for this function; gnulib does the check now. (mkstemp): Remove check for this no-longer-used function. * lib/mkostemp.c, lib/secure_getenv.c, lib/tempname.c, lib/tempname.h: * m4/mkostemp.m4, m4/secure_getenv.m4, m4/tempname.m4: New files, copied from Gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * admin/merge-gnulib (GNULIB_MODULES): Add mkostemp. * lib-src/movemail.c (main): * lib-src/update-game-score.c (write_scores): Use mkostemp (which now works on all platforms, due to changes in the portability layer) rather than mktemp (which has a race) or mkstemp (which we no longer bother with). * src/callproc.c (create_temp_file): * src/filelock.c (create_lock_file): Assume mkostemp, since it's now provided by Gnulib. Fixes: debbugs:15015
Diffstat (limited to 'lib-src/movemail.c')
-rw-r--r--lib-src/movemail.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index 81ac8aa187c..9434782cb17 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -304,24 +304,13 @@ main (int argc, char **argv)
304 304
305 memcpy (tempname, inname, inname_dirlen); 305 memcpy (tempname, inname, inname_dirlen);
306 strcpy (tempname + inname_dirlen, "EXXXXXX"); 306 strcpy (tempname + inname_dirlen, "EXXXXXX");
307#ifdef HAVE_MKSTEMP 307 desc = mkostemp (tempname, 0);
308 desc = mkstemp (tempname);
309#else
310 mktemp (tempname);
311 if (!*tempname)
312 desc = -1;
313 else
314 {
315 unlink (tempname);
316 desc = open (tempname, O_WRONLY | O_CREAT | O_EXCL, 0600);
317 }
318#endif
319 if (desc < 0) 308 if (desc < 0)
320 { 309 {
321 int mkstemp_errno = errno; 310 int mkostemp_errno = errno;
322 error ("error while creating what would become the lock file", 311 error ("error while creating what would become the lock file",
323 0, 0); 312 0, 0);
324 errno = mkstemp_errno; 313 errno = mkostemp_errno;
325 pfatal_with_name (tempname); 314 pfatal_with_name (tempname);
326 } 315 }
327 close (desc); 316 close (desc);