mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
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
This commit is contained in:
parent
484ab23924
commit
e0fdb69430
19 changed files with 632 additions and 52 deletions
46
lib/mkostemp.c
Normal file
46
lib/mkostemp.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2013 Free Software
|
||||
Foundation, Inc.
|
||||
This file is derived from the one in the GNU C Library.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#if !_LIBC
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !_LIBC
|
||||
# include "tempname.h"
|
||||
# define __gen_tempname gen_tempname
|
||||
# ifndef __GTFILE
|
||||
# define __GT_FILE GT_FILE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef __GT_FILE
|
||||
# define __GT_FILE 0
|
||||
#endif
|
||||
|
||||
/* Generate a unique temporary file name from XTEMPLATE.
|
||||
The last six characters of XTEMPLATE must be "XXXXXX";
|
||||
they are replaced with a string that makes the file name unique.
|
||||
Then open the file and return a fd. */
|
||||
int
|
||||
mkostemp (char *xtemplate, int flags)
|
||||
{
|
||||
return __gen_tempname (xtemplate, 0, flags, __GT_FILE);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue