diff options
| author | Paul Eggert | 2013-08-04 09:56:56 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-08-04 09:56:56 -0700 |
| commit | e0fdb6943066032db294720915c3bd644bf2bcd1 (patch) | |
| tree | 0aa420b81dc0187e2efec3ff4fe3cf046ad1c598 /src/callproc.c | |
| parent | 484ab23924d39b3e26d54074fd659633e1660ef4 (diff) | |
| download | emacs-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 'src/callproc.c')
| -rw-r--r-- | src/callproc.c | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/src/callproc.c b/src/callproc.c index 450fc57f929..54bc5cd9dc0 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1009,23 +1009,11 @@ create_temp_file (ptrdiff_t nargs, Lisp_Object *args) | |||
| 1009 | tempfile = SSDATA (filename_string); | 1009 | tempfile = SSDATA (filename_string); |
| 1010 | 1010 | ||
| 1011 | { | 1011 | { |
| 1012 | int fd; | 1012 | int fd = mkostemp (tempfile, O_CLOEXEC); |
| 1013 | |||
| 1014 | #ifdef HAVE_MKOSTEMP | ||
| 1015 | fd = mkostemp (tempfile, O_CLOEXEC); | ||
| 1016 | #elif defined HAVE_MKSTEMP | ||
| 1017 | fd = mkstemp (tempfile); | ||
| 1018 | #else | ||
| 1019 | errno = EEXIST; | ||
| 1020 | mktemp (tempfile); | ||
| 1021 | fd = *tempfile ? 0 : -1; | ||
| 1022 | #endif | ||
| 1023 | if (fd < 0) | 1013 | if (fd < 0) |
| 1024 | report_file_error ("Failed to open temporary file using pattern", | 1014 | report_file_error ("Failed to open temporary file using pattern", |
| 1025 | pattern); | 1015 | pattern); |
| 1026 | #if defined HAVE_MKOSTEMP || defined HAVE_MKSTEMP | ||
| 1027 | emacs_close (fd); | 1016 | emacs_close (fd); |
| 1028 | #endif | ||
| 1029 | } | 1017 | } |
| 1030 | 1018 | ||
| 1031 | record_unwind_protect (delete_temp_file, filename_string); | 1019 | record_unwind_protect (delete_temp_file, filename_string); |