summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-08-04 09:56:56 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-08-04 09:56:56 -0700
commite0fdb6943066032db294720915c3bd644bf2bcd1 (patch)
tree0aa420b81dc0187e2efec3ff4fe3cf046ad1c598 /m4
parent484ab23924d39b3e26d54074fd659633e1660ef4 (diff)
downloademacs-e0fdb6943066032db294720915c3bd644bf2bcd1.tar.gz
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 'm4')
-rw-r--r--m4/gnulib-comp.m444
-rw-r--r--m4/mkostemp.m423
-rw-r--r--m4/secure_getenv.m425
-rw-r--r--m4/tempname.m419
4 files changed, 111 insertions, 0 deletions
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index d7062e862de..af9a9ca3ae0 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -89,6 +89,7 @@ AC_DEFUN([gl_EARLY],
# Code from module lstat:
# Code from module manywarnings:
# Code from module memrchr:
+ # Code from module mkostemp:
# Code from module mktime:
# Code from module multiarch:
# Code from module nocrash:
@@ -102,6 +103,7 @@ AC_DEFUN([gl_EARLY],
# Code from module readlink:
# Code from module readlinkat:
# Code from module root-uid:
+ # Code from module secure_getenv:
# Code from module sig2str:
# Code from module signal-h:
# Code from module snippet/_Noreturn:
@@ -134,6 +136,7 @@ AC_DEFUN([gl_EARLY],
# Code from module sys_select:
# Code from module sys_stat:
# Code from module sys_time:
+ # Code from module tempname:
# Code from module time:
# Code from module time_r:
# Code from module timer-time:
@@ -274,6 +277,13 @@ AC_DEFUN([gl_INIT],
gl_PREREQ_MEMRCHR
fi
gl_STRING_MODULE_INDICATOR([memrchr])
+ gl_FUNC_MKOSTEMP
+ if test $HAVE_MKOSTEMP = 0; then
+ AC_LIBOBJ([mkostemp])
+ gl_PREREQ_MKOSTEMP
+ fi
+ gl_MODULE_INDICATOR([mkostemp])
+ gl_STDLIB_MODULE_INDICATOR([mkostemp])
gl_FUNC_MKTIME
if test $REPLACE_MKTIME = 1; then
AC_LIBOBJ([mktime])
@@ -381,9 +391,11 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false
gl_gnulib_enabled_pathmax=false
gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false
+ gl_gnulib_enabled_secure_getenv=false
gl_gnulib_enabled_stat=false
gl_gnulib_enabled_strtoll=false
gl_gnulib_enabled_strtoull=false
+ gl_gnulib_enabled_tempname=false
gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false
func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b ()
{
@@ -485,6 +497,18 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=true
fi
}
+ func_gl_gnulib_m4code_secure_getenv ()
+ {
+ if ! $gl_gnulib_enabled_secure_getenv; then
+ gl_FUNC_SECURE_GETENV
+ if test $HAVE_SECURE_GETENV = 0; then
+ AC_LIBOBJ([secure_getenv])
+ gl_PREREQ_SECURE_GETENV
+ fi
+ gl_STDLIB_MODULE_INDICATOR([secure_getenv])
+ gl_gnulib_enabled_secure_getenv=true
+ fi
+ }
func_gl_gnulib_m4code_stat ()
{
if ! $gl_gnulib_enabled_stat; then
@@ -527,6 +551,14 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_strtoull=true
fi
}
+ func_gl_gnulib_m4code_tempname ()
+ {
+ if ! $gl_gnulib_enabled_tempname; then
+ gl_FUNC_GEN_TEMPNAME
+ gl_gnulib_enabled_tempname=true
+ func_gl_gnulib_m4code_secure_getenv
+ fi
+ }
func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec ()
{
if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then
@@ -569,6 +601,9 @@ AC_DEFUN([gl_INIT],
if test $REPLACE_LSTAT = 1; then
func_gl_gnulib_m4code_stat
fi
+ if test $HAVE_MKOSTEMP = 0; then
+ func_gl_gnulib_m4code_tempname
+ fi
if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then
func_gl_gnulib_m4code_stat
fi
@@ -598,9 +633,11 @@ AC_DEFUN([gl_INIT],
AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7])
AM_CONDITIONAL([gl_GNULIB_ENABLED_pathmax], [$gl_gnulib_enabled_pathmax])
AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_secure_getenv], [$gl_gnulib_enabled_secure_getenv])
AM_CONDITIONAL([gl_GNULIB_ENABLED_stat], [$gl_gnulib_enabled_stat])
AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll])
AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoull], [$gl_gnulib_enabled_strtoull])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_tempname], [$gl_gnulib_enabled_tempname])
AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec])
# End of code from modules
m4_ifval(gl_LIBSOURCES_LIST, [
@@ -806,6 +843,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/md5.c
lib/md5.h
lib/memrchr.c
+ lib/mkostemp.c
lib/mktime-internal.h
lib/mktime.c
lib/openat-priv.h
@@ -821,6 +859,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/readlink.c
lib/readlinkat.c
lib/root-uid.h
+ lib/secure_getenv.c
lib/sha1.c
lib/sha1.h
lib/sha256.c
@@ -853,6 +892,8 @@ AC_DEFUN([gl_FILE_LIST], [
lib/sys_select.in.h
lib/sys_stat.in.h
lib/sys_time.in.h
+ lib/tempname.c
+ lib/tempname.h
lib/time.in.h
lib/time_r.c
lib/timespec-add.c
@@ -908,6 +949,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/manywarnings.m4
m4/md5.m4
m4/memrchr.m4
+ m4/mkostemp.m4
m4/mktime.m4
m4/multiarch.m4
m4/nocrash.m4
@@ -919,6 +961,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/putenv.m4
m4/readlink.m4
m4/readlinkat.m4
+ m4/secure_getenv.m4
m4/setenv.m4
m4/sha1.m4
m4/sha256.m4
@@ -948,6 +991,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/sys_socket_h.m4
m4/sys_stat_h.m4
m4/sys_time_h.m4
+ m4/tempname.m4
m4/time_h.m4
m4/time_r.m4
m4/timer_time.m4
diff --git a/m4/mkostemp.m4 b/m4/mkostemp.m4
new file mode 100644
index 00000000000..6d101eeda39
--- /dev/null
+++ b/m4/mkostemp.m4
@@ -0,0 +1,23 @@
+# mkostemp.m4 serial 2
+dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MKOSTEMP],
+[
+ AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+
+ dnl Persuade glibc <stdlib.h> to declare mkostemp().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_FUNCS_ONCE([mkostemp])
+ if test $ac_cv_func_mkostemp != yes; then
+ HAVE_MKOSTEMP=0
+ fi
+])
+
+# Prerequisites of lib/mkostemp.c.
+AC_DEFUN([gl_PREREQ_MKOSTEMP],
+[
+])
diff --git a/m4/secure_getenv.m4 b/m4/secure_getenv.m4
new file mode 100644
index 00000000000..5da5298f669
--- /dev/null
+++ b/m4/secure_getenv.m4
@@ -0,0 +1,25 @@
+# Look up an environment variable more securely.
+dnl Copyright 2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_SECURE_GETENV],
+[
+ dnl Persuade glibc <stdlib.h> to declare secure_getenv().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+ AC_CHECK_FUNCS_ONCE([secure_getenv])
+ if test $ac_cv_func_secure_getenv = no; then
+ HAVE_SECURE_GETENV=0
+ fi
+])
+
+# Prerequisites of lib/secure_getenv.c.
+AC_DEFUN([gl_PREREQ_SECURE_GETENV], [
+ AC_CHECK_FUNCS([__secure_getenv])
+ if test $ac_cv_func___secure_getenv = no; then
+ AC_CHECK_FUNCS([issetugid])
+ fi
+])
diff --git a/m4/tempname.m4 b/m4/tempname.m4
new file mode 100644
index 00000000000..a6e42dcea81
--- /dev/null
+++ b/m4/tempname.m4
@@ -0,0 +1,19 @@
+#serial 5
+
+# Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# glibc provides __gen_tempname as a wrapper for mk[ds]temp. Expose
+# it as a public API, and provide it on systems that are lacking.
+AC_DEFUN([gl_FUNC_GEN_TEMPNAME],
+[
+ gl_PREREQ_TEMPNAME
+])
+
+# Prerequisites of lib/tempname.c.
+AC_DEFUN([gl_PREREQ_TEMPNAME],
+[
+ :
+])