From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 09 01:38:36 2017 Received: (at submit) by debbugs.gnu.org; 9 Aug 2017 05:38:37 +0000 Received: from localhost ([127.0.0.1]:52506 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfJhP-0002PJ-S7 for submit@debbugs.gnu.org; Wed, 09 Aug 2017 01:38:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:32801) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfJhN-0002P5-2U for submit@debbugs.gnu.org; Wed, 09 Aug 2017 01:38:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfJhF-0006Nc-0H for submit@debbugs.gnu.org; Wed, 09 Aug 2017 01:38:23 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57277) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfJhE-0006NC-Rg for submit@debbugs.gnu.org; Wed, 09 Aug 2017 01:38:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfJhB-0001cA-Db for bug-gnu-emacs@gnu.org; Wed, 09 Aug 2017 01:38:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfJh8-0006Kv-0y for bug-gnu-emacs@gnu.org; Wed, 09 Aug 2017 01:38:17 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47942) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfJh7-0006JM-JH for bug-gnu-emacs@gnu.org; Wed, 09 Aug 2017 01:38:13 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E68C5160736 for ; Tue, 8 Aug 2017 22:38:09 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id RFwn-vx_Pl8n for ; Tue, 8 Aug 2017 22:38:06 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3C2A816073B for ; Tue, 8 Aug 2017 22:38:06 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id g4PCQUMSjXAd for ; Tue, 8 Aug 2017 22:38:06 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 12653160736 for ; Tue, 8 Aug 2017 22:38:06 -0700 (PDT) To: Emacs bug reports and feature requests From: Paul Eggert Subject: fix make-temp-file race on local host Organization: UCLA Computer Science Department Message-ID: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> Date: Tue, 8 Aug 2017 22:38:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------A5C1402735518A92680D3BE1" Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) This is a multi-part message in MIME format. --------------A5C1402735518A92680D3BE1 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Tags: patch Severity: important I plan to install the attached patch in master soon, and am sending it fo= r=20 review to bug-gnu-emacs first in case there's some problem with it on=20 MS-Windows. Although this patch does not fix all instances of the race in= Gnu=20 Emacs (notably, Tramp access is still affected) it's a good start. --------------A5C1402735518A92680D3BE1 Content-Type: text/x-patch; name="0001-Fix-make-temp-file-race-on-local-files.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Fix-make-temp-file-race-on-local-files.patch" =46rom 0f536834ae618adc38883fc331f75a2847a8411c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 8 Aug 2017 22:22:48 -0700 Subject: [PATCH] Fix make-temp-file race on local files For the motivation behind this patch, please see: http://emacshorrors.com/posts/make-temp-name.html The race still exists for magic file names; fixing this will require Tramp surgery. * admin/merge-gnulib (GNULIB_MODULES): Add tempname, now that Emacs is using it directly. * configure.ac (AUTO_DEPEND): Remove AC_SYS_LONG_FILE_NAMES; no longer needed. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lisp/files.el (files--make-magic-temp-file): Rename from make-temp-file. Add comment describing race bug. (make-temp-file): Use fileio--make-temp-file for non-magic files names. * src/fileio.c: Include tempname.h. (make_temp_name_tbl, make_temp_name_count) (make_temp_name_count_initialized_p, make_temp_name): Remove. (Ffileio__make_temp_file): New function. (Fmake_temp_name): Use it. * src/filelock.c (get_boot_time): Use Ffileio__make_temp_file instead of make_temp_name; this avoids a race. --- admin/CPP-DEFINES | 1 - admin/merge-gnulib | 4 +- configure.ac | 3 - lib/gnulib.mk.in | 8 +-- lisp/files.el | 15 +++++ m4/gnulib-comp.m4 | 34 +++-------- src/buffer.c | 1 - src/fileio.c | 170 ++++++++++++++---------------------------------= ------ src/filelock.c | 11 ++-- src/lisp.h | 1 - 10 files changed, 75 insertions(+), 173 deletions(-) diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index cead305aee..10b558d1ad 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -205,7 +205,6 @@ HAVE_LIBXML2 HAVE_LIBXMU HAVE_LOCALTIME_R HAVE_LOCAL_SOCKETS -HAVE_LONG_FILE_NAMES HAVE_LONG_LONG_INT HAVE_LRAND48 HAVE_LSTAT diff --git a/admin/merge-gnulib b/admin/merge-gnulib index c23e8a40ea..c7a7a1d7c9 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -39,8 +39,8 @@ GNULIB_MODULES=3D manywarnings memrchr minmax mkostemp mktime nstrftime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio - stpcpy strtoimax symlink sys_stat - sys_time time time_r time_rz timegm timer-time timespec-add timespec-s= ub + stpcpy strtoimax symlink sys_stat sys_time + tempname time time_r time_rz timegm timer-time timespec-add timespec-s= ub update-copyright unlocked-io utimens vla warnings ' diff --git a/configure.ac b/configure.ac index 9f80620a80..86d5b3e94f 100644 --- a/configure.ac +++ b/configure.ac @@ -1779,9 +1779,6 @@ AC_DEFUN fi AC_SUBST(AUTO_DEPEND) =20 -dnl checks for operating system services -AC_SYS_LONG_FILE_NAMES - #### Choose a window system. =20 ## We leave window_system equal to none if diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index a385c8c838..8b34ee6354 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --lib=3Dlibgnu --source-base=3Dlib = --m4-base=3Dm4 --doc-base=3Ddoc --tests-base=3Dtests --aux-dir=3Dbuild-au= x --avoid=3Dclose --avoid=3Ddup --avoid=3Dfchdir --avoid=3Dfstat --avoid=3D= malloc-posix --avoid=3Dmsvc-inval --avoid=3Dmsvc-nothrow --avoid=3Dopen -= -avoid=3Dopenat-die --avoid=3Dopendir --avoid=3Draise --avoid=3Dsave-cwd = --avoid=3Dselect --avoid=3Dsetenv --avoid=3Dsigprocmask --avoid=3Dstat --= avoid=3Dstdarg --avoid=3Dstdbool --avoid=3Dthreadlib --avoid=3Dtzset --av= oid=3Dunsetenv --avoid=3Dutime --avoid=3Dutime-h --gnu-make --makefile-na= me=3Dgnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=3D= gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadli= nkat close-stream count-leading-zeros count-one-bits count-trailing-zeros= crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 d-type diffseq dtoast= r dtotimespec dup2 environ execinfo explicit_bzero faccessat fcntl fcntl-= h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloa= davg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value int= props largefile lstat manywarnings memrchr minmax mkostemp mktime nstrfti= me pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig= 2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strtoimax s= ymlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-a= dd timespec-sub unlocked-io update-copyright utimens vla warnings +# Reproduce by: gnulib-tool --import --lib=3Dlibgnu --source-base=3Dlib = --m4-base=3Dm4 --doc-base=3Ddoc --tests-base=3Dtests --aux-dir=3Dbuild-au= x --avoid=3Dclose --avoid=3Ddup --avoid=3Dfchdir --avoid=3Dfstat --avoid=3D= malloc-posix --avoid=3Dmsvc-inval --avoid=3Dmsvc-nothrow --avoid=3Dopen -= -avoid=3Dopenat-die --avoid=3Dopendir --avoid=3Draise --avoid=3Dsave-cwd = --avoid=3Dselect --avoid=3Dsetenv --avoid=3Dsigprocmask --avoid=3Dstat --= avoid=3Dstdarg --avoid=3Dstdbool --avoid=3Dthreadlib --avoid=3Dtzset --av= oid=3Dunsetenv --avoid=3Dutime --avoid=3Dutime-h --gnu-make --makefile-na= me=3Dgnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=3D= gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadli= nkat close-stream count-leading-zeros count-one-bits count-trailing-zeros= crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 d-type diffseq dtoast= r dtotimespec dup2 environ execinfo explicit_bzero faccessat fcntl fcntl-= h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloa= davg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value int= props largefile lstat manywarnings memrchr minmax mkostemp mktime nstrfti= me pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig= 2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strtoimax s= ymlink sys_stat sys_time tempname time time_r time_rz timegm timer-time t= imespec-add timespec-sub unlocked-io update-copyright utimens vla warning= s =20 =20 MOSTLYCLEANFILES +=3D core *.stackdump @@ -903,9 +903,7 @@ gl_GNULIB_ENABLED_dosname =3D @gl_GNULIB_ENABLED_dosn= ame@ gl_GNULIB_ENABLED_euidaccess =3D @gl_GNULIB_ENABLED_euidaccess@ gl_GNULIB_ENABLED_getdtablesize =3D @gl_GNULIB_ENABLED_getdtablesize@ gl_GNULIB_ENABLED_getgroups =3D @gl_GNULIB_ENABLED_getgroups@ -gl_GNULIB_ENABLED_secure_getenv =3D @gl_GNULIB_ENABLED_secure_getenv@ gl_GNULIB_ENABLED_strtoll =3D @gl_GNULIB_ENABLED_strtoll@ -gl_GNULIB_ENABLED_tempname =3D @gl_GNULIB_ENABLED_tempname@ gl_LIBOBJS =3D @gl_LIBOBJS@ gl_LTLIBOBJS =3D @gl_LTLIBOBJS@ gltests_LIBOBJS =3D @gltests_LIBOBJS@ @@ -1915,9 +1913,7 @@ endif ## begin gnulib module secure_getenv ifeq (,$(OMIT_GNULIB_MODULE_secure_getenv)) =20 -ifneq (,$(gl_GNULIB_ENABLED_secure_getenv)) =20 -endif EXTRA_DIST +=3D secure_getenv.c =20 EXTRA_libgnu_a_SOURCES +=3D secure_getenv.c @@ -2715,10 +2711,8 @@ endif ## begin gnulib module tempname ifeq (,$(OMIT_GNULIB_MODULE_tempname)) =20 -ifneq (,$(gl_GNULIB_ENABLED_tempname)) libgnu_a_SOURCES +=3D tempname.c =20 -endif EXTRA_DIST +=3D tempname.h =20 endif diff --git a/lisp/files.el b/lisp/files.el index f2758ab18c..3ed36d24db 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1417,6 +1417,19 @@ make-temp-file If DIR-FLAG is non-nil, create a new empty directory instead of a file. =20 If SUFFIX is non-nil, add that at the end of the file name." + (let ((absolute-prefix (expand-file-name prefix temporary-file-directo= ry))) + ;; FIXME: Establish make-temp-file file name handlers, + ;; to create temporary files and directories without races. + ;; For now, if the prefix is magic, fall back on the traditional, + ;; insecure way to create temporary files. + (if (find-file-name-handler absolute-prefix 'write-region) + (files--make-magic-temp-file prefix dir-flag suffix) + (fileio--make-temp-file absolute-prefix + (if dir-flag t) (or suffix ""))))) + +(defun files--make-magic-temp-file (prefix &optional dir-flag suffix) + "Implement (make-temp-file PREFIX DIR-FLAG SUFFIX), +even if the result is a magic file name." ;; Create temp files with strict access rights. It's easy to ;; loosen them later, whereas it's impossible to close the ;; time-window of loose permissions otherwise. @@ -1435,6 +1448,8 @@ make-temp-file (setq file (concat file suffix))) (if dir-flag (make-directory file) + ;; FIXME: The 'excl is only aspirational; it is + ;; actually a no-op if FILE is a magic file name. (write-region "" nil file nil 'silent nil 'excl)) nil) (file-already-exists t)) diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 188c116c85..fc86237ee9 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -347,6 +347,12 @@ AC_DEFUN AC_LIBOBJ([readlinkat]) fi gl_UNISTD_MODULE_INDICATOR([readlinkat]) + gl_FUNC_SECURE_GETENV + if test $HAVE_SECURE_GETENV =3D 0; then + AC_LIBOBJ([secure_getenv]) + gl_PREREQ_SECURE_GETENV + fi + gl_STDLIB_MODULE_INDICATOR([secure_getenv]) gl_FUNC_SIG2STR if test $ac_cv_func_sig2str =3D no; then AC_LIBOBJ([sig2str]) @@ -388,6 +394,7 @@ AC_DEFUN AC_PROG_MKDIR_P gl_SYS_TYPES_H AC_PROG_MKDIR_P + gl_FUNC_GEN_TEMPNAME gl_HEADER_TIME_H gl_TIME_R if test $HAVE_LOCALTIME_R =3D 0 || test $REPLACE_LOCALTIME_R =3D 1; th= en @@ -424,9 +431,7 @@ AC_DEFUN gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=3Dfalse gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=3Dfalse gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=3Dfalse - gl_gnulib_enabled_secure_getenv=3Dfalse gl_gnulib_enabled_strtoll=3Dfalse - gl_gnulib_enabled_tempname=3Dfalse gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=3Dfalse func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () { @@ -550,18 +555,6 @@ AC_DEFUN gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=3Dtrue fi } - func_gl_gnulib_m4code_secure_getenv () - { - if ! $gl_gnulib_enabled_secure_getenv; then - gl_FUNC_SECURE_GETENV - if test $HAVE_SECURE_GETENV =3D 0; then - AC_LIBOBJ([secure_getenv]) - gl_PREREQ_SECURE_GETENV - fi - gl_STDLIB_MODULE_INDICATOR([secure_getenv]) - gl_gnulib_enabled_secure_getenv=3Dtrue - fi - } func_gl_gnulib_m4code_strtoll () { if ! $gl_gnulib_enabled_strtoll; then @@ -574,14 +567,6 @@ AC_DEFUN gl_gnulib_enabled_strtoll=3Dtrue fi } - func_gl_gnulib_m4code_tempname () - { - if ! $gl_gnulib_enabled_tempname; then - gl_FUNC_GEN_TEMPNAME - gl_gnulib_enabled_tempname=3Dtrue - func_gl_gnulib_m4code_secure_getenv - fi - } func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () { if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then @@ -627,9 +612,6 @@ AC_DEFUN if test $REPLACE_LSTAT =3D 1; then func_gl_gnulib_m4code_dosname fi - if test $HAVE_MKOSTEMP =3D 0; then - func_gl_gnulib_m4code_tempname - fi if test $HAVE_READLINKAT =3D 0; then func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b fi @@ -658,9 +640,7 @@ AC_DEFUN AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [= $gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [= $gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) 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_strtoll], [$gl_gnulib_enabled_strtol= l]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_tempname], [$gl_gnulib_enabled_tempn= ame]) AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [= $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) # End of code from modules m4_ifval(gl_LIBSOURCES_LIST, [ diff --git a/src/buffer.c b/src/buffer.c index 0d0f43e937..2d508f35cf 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1085,7 +1085,6 @@ is first appended to NAME, to speed up finding a no= n-existent buffer. */) genbase =3D name; else { - /* Note fileio.c:make_temp_name does random differently. */ char number[sizeof "-999999"]; int i =3D XFASTINT (Frandom (make_number (999999))); AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%d", i))= ; diff --git a/src/fileio.c b/src/fileio.c index 15845e3914..1ef9bfa82b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -97,6 +97,7 @@ along with GNU Emacs. If not, see . */ #include #include #include +#include =20 #include =20 @@ -623,149 +624,67 @@ In Unix-syntax, this function just removes the fin= al slash. */) return val; } =20 -static const char make_temp_name_tbl[64] =3D -{ - 'A','B','C','D','E','F','G','H', - 'I','J','K','L','M','N','O','P', - 'Q','R','S','T','U','V','W','X', - 'Y','Z','a','b','c','d','e','f', - 'g','h','i','j','k','l','m','n', - 'o','p','q','r','s','t','u','v', - 'w','x','y','z','0','1','2','3', - '4','5','6','7','8','9','-','_' -}; - -static unsigned make_temp_name_count, make_temp_name_count_initialized_p= ; - -/* Value is a temporary file name starting with PREFIX, a string. +DEFUN ("fileio--make-temp-file", Ffileio__make_temp_file, + Sfileio__make_temp_file, 3, 3, 0, + doc: /* Generate a new file whose name starts with PREFIX, a stri= ng. +Return the name of the generated file. If DIR-FLAG is zero, do not +create the file, just its name. Otherwise, if DIR-FLAG is non-nil, +create an empty directory. The file name should end in SUFFIX. =20 - The Emacs process number forms part of the result, so there is - no danger of generating a name being used by another process. - In addition, this function makes an attempt to choose a name - which has no existing file. To make this work, PREFIX should be - an absolute file name. +Signal an error if the file could not be created. =20 - BASE64_P means add the pid as 3 characters in base64 - encoding. In this case, 6 characters will be added to PREFIX to - form the file name. Otherwise, if Emacs is running on a system - with long file names, add the pid as a decimal number. - - This function signals an error if no unique file name could be - generated. */ - -Lisp_Object -make_temp_name (Lisp_Object prefix, bool base64_p) +This function does not grok magic file names. */) + (Lisp_Object prefix, Lisp_Object dir_flag, Lisp_Object suffix) { - Lisp_Object val, encoded_prefix; - ptrdiff_t len; - printmax_t pid; - char *p, *data; - char pidbuf[INT_BUFSIZE_BOUND (printmax_t)]; - int pidlen; - - CHECK_STRING (prefix); - - /* VAL is created by adding 6 characters to PREFIX. The first - three are the PID of this process, in base 64, and the second - three are incremented if the file already exists. This ensures - 262144 unique file names per PID per PREFIX. */ - - pid =3D getpid (); - - if (base64_p) - { - pidbuf[0] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidbuf[1] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidbuf[2] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidlen =3D 3; - } - else + bool make_temp_name =3D EQ (dir_flag, make_number (0)); + CHECK_STRING (suffix); + if (!make_temp_name) + prefix =3D Fexpand_file_name (prefix, Vtemporary_file_directory); + + Lisp_Object encoded_prefix =3D ENCODE_FILE (prefix); + Lisp_Object encoded_suffix =3D ENCODE_FILE (suffix); + ptrdiff_t prefix_len =3D SBYTES (encoded_prefix); + ptrdiff_t suffix_len =3D SBYTES (encoded_suffix); + if (INT_MAX < suffix_len) + args_out_of_range (prefix, suffix); + int nX =3D 6; + Lisp_Object val =3D make_uninit_string (prefix_len + nX + suffix_len);= + char *data =3D SSDATA (val); + memcpy (data, SSDATA (encoded_prefix), prefix_len); + memset (data + prefix_len, 'X', nX); + memcpy (data + prefix_len + nX, SSDATA (encoded_suffix), suffix_len); + int kind =3D (NILP (dir_flag) ? GT_FILE + : make_temp_name ? GT_NOCREATE + : GT_DIR); + int fd =3D gen_tempname (data, suffix_len, O_BINARY | O_CLOEXEC, kind)= ; + if (fd < 0 || (NILP (dir_flag) && emacs_close (fd) !=3D 0)) { -#ifdef HAVE_LONG_FILE_NAMES - pidlen =3D sprintf (pidbuf, "%"pMd, pid); -#else - pidbuf[0] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidbuf[1] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidbuf[2] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidlen =3D 3; -#endif - } - - encoded_prefix =3D ENCODE_FILE (prefix); - len =3D SBYTES (encoded_prefix); - val =3D make_uninit_string (len + 3 + pidlen); - data =3D SSDATA (val); - memcpy (data, SSDATA (encoded_prefix), len); - p =3D data + len; - - memcpy (p, pidbuf, pidlen); - p +=3D pidlen; - - /* Here we try to minimize useless stat'ing when this function is - invoked many times successively with the same PREFIX. We achieve - this by initializing count to a random value, and incrementing it - afterwards. - - We don't want make-temp-name to be called while dumping, - because then make_temp_name_count_initialized_p would get set - and then make_temp_name_count would not be set when Emacs starts. = */ - - if (!make_temp_name_count_initialized_p) - { - make_temp_name_count =3D time (NULL); - make_temp_name_count_initialized_p =3D 1; - } - - while (1) - { - unsigned num =3D make_temp_name_count; - - p[0] =3D make_temp_name_tbl[num & 63], num >>=3D 6; - p[1] =3D make_temp_name_tbl[num & 63], num >>=3D 6; - p[2] =3D make_temp_name_tbl[num & 63], num >>=3D 6; - - /* Poor man's congruential RN generator. Replace with - ++make_temp_name_count for debugging. */ - make_temp_name_count +=3D 25229; - make_temp_name_count %=3D 225307; - - if (!check_existing (data)) + static char const kind_message[][32] =3D { - /* We want to return only if errno is ENOENT. */ - if (errno =3D=3D ENOENT) - return DECODE_FILE (val); - else - /* The error here is dubious, but there is little else we - can do. The alternatives are to return nil, which is - as bad as (and in many cases worse than) throwing the - error, or to ignore the error, which will likely result - in looping through 225307 stat's, which is not only - dog-slow, but also useless since eventually nil would - have to be returned anyway. */ - report_file_error ("Cannot create temporary name for prefix", - prefix); - /* not reached */ - } + [GT_FILE] =3D "Creating file with prefix", + [GT_DIR] =3D "Creating directory with prefix", + [GT_NOCREATE] =3D "Creating file name with prefix" + }; + report_file_error (kind_message[kind], prefix); } + return DECODE_FILE (val); } =20 =20 DEFUN ("make-temp-name", Fmake_temp_name, Smake_temp_name, 1, 1, 0, doc: /* Generate temporary file name (string) starting with PREFI= X (a string). -The Emacs process number forms part of the result, so there is no -danger of generating a name being used by another Emacs process -\(so long as only a single host can access the containing directory...).= =20 This function tries to choose a name that has no existing file. For this to work, PREFIX should be an absolute file name, and PREFIX and the returned string should both be non-magic. =20 -There is a race condition between calling `make-temp-name' and creating = the -file, which opens all kinds of security holes. For that reason, you sho= uld -normally use `make-temp-file' instead. */) +There is a race condition between calling `make-temp-name' and +later creating the file, which opens all kinds of security holes. +For that reason, you should normally use `make-temp-file' instead. */) (Lisp_Object prefix) { - return make_temp_name (prefix, 0); + return Ffileio__make_temp_file (prefix, make_number (0), + empty_unibyte_string); } =20 DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0= , @@ -6167,6 +6086,7 @@ This includes interactive calls to `delete-file' an= d defsubr (&Sunhandled_file_name_directory); defsubr (&Sfile_name_as_directory); defsubr (&Sdirectory_file_name); + defsubr (&Sfileio__make_temp_file); defsubr (&Smake_temp_name); defsubr (&Sexpand_file_name); defsubr (&Ssubstitute_in_file_name); diff --git a/src/filelock.c b/src/filelock.c index dd8cb28c42..de0ca01052 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -206,14 +206,13 @@ get_boot_time (void) WTMP_FILE, counter); if (! NILP (Ffile_exists_p (tempname))) { - /* The utmp functions on mescaline.gnu.org accept only - file names up to 8 characters long. Choose a 2 - character long prefix, and call make_temp_file with - second arg non-zero, so that it will add not more - than 6 characters to the prefix. */ + /* The utmp functions on older systems accept only file + names up to 8 bytes long. Choose a 2 byte prefix, so + the 6-byte suffix does not make the name too long. */ filename =3D Fexpand_file_name (build_string ("wt"), Vtemporary_file_directory); - filename =3D make_temp_name (filename, 1); + filename =3D Ffileio__make_temp_file (filename, Qnil, + empty_unibyte_string); CALLN (Fcall_process, build_string ("gzip"), Qnil, list2 (QCfile, filename), Qnil, build_string ("-cd"), tempname); diff --git a/src/lisp.h b/src/lisp.h index 4de6fc85ec..a65cc9684a 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4013,7 +4013,6 @@ extern bool file_directory_p (const char *); extern bool file_accessible_directory_p (Lisp_Object); extern void init_fileio (void); extern void syms_of_fileio (void); -extern Lisp_Object make_temp_name (Lisp_Object, bool); =20 /* Defined in search.c. */ extern void shrink_regexp_cache (void); --=20 2.13.3 --------------A5C1402735518A92680D3BE1-- From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 09 02:51:48 2017 Received: (at 28023) by debbugs.gnu.org; 9 Aug 2017 06:51:48 +0000 Received: from localhost ([127.0.0.1]:52528 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfKqJ-0004GA-PG for submit@debbugs.gnu.org; Wed, 09 Aug 2017 02:51:47 -0400 Received: from mout.gmx.net ([212.227.15.18]:50404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfKqI-0004Fx-1f for 28023@debbugs.gnu.org; Wed, 09 Aug 2017 02:51:46 -0400 Received: from detlef.gmx.de ([212.91.243.217]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0Lhwgc-1dIbCW44eI-00nBp9; Wed, 09 Aug 2017 08:51:27 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> Date: Wed, 09 Aug 2017 08:51:25 +0200 In-Reply-To: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> (Paul Eggert's message of "Tue, 8 Aug 2017 22:38:05 -0700") Message-ID: <87shh18c9e.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:wgU7rmwsnAFMrwIDazzZ/5T5o6IkiCLTl6j+rwFmwknHcYbvQAg 6kj+edwYCRRUDLbHuoKUtY5FNpS/vbu2p9dTdQEIATQ1pQOXbj/Z/U7MAb16uRIkbh0CkZD nZXV+EdP8t5EU21sGXP98XCJv8D8m7bG+kQu+aWOm7lI7F3X51374b0IqSANYtFZXB9r/WV /QSBF6vBuEd5hHVICNraw== X-UI-Out-Filterresults: notjunk:1;V01:K0:7BpNjAMuelQ=:YOX6M0uYsGr+CKuNnclB8e GMZsotnMMS6+wmqFT8CCUqMQUp0GHt4ue2s7DyN1z/IyUZ/d0zY+CLM1usyNaryXMyk5R8Rn8 JvMfTkdWLX2ZV6Pdjms3kikhMg3CkOGwjis0azdn8BF0YGN+G3cq2Y0M+RYDnvNpY6fmqtv9y gFp+Q1rguC2XbbCaWJZBs4YT/iCetuaWDYctp5UgRc9w0kHpXQ8rLLQD5uWsE+ubCwyqmTXMw gsD7wH+Zul0BMyX66JSEEQI643b9hjy8qla51xCYYpRKUqqJgIlEyGMHdhlpqrh/m6JXH/uoY K8rqZykTPR31ZLIgG8IUttbk4nIBWDNEJTyfuv2edmy9+fm52xcm5oTPExSBCSWsbjgiDHPDP ep5/2aGod7i2N/LsiHRyUKtUk1vHfYUHsRnl1IPbJgAjhb6XDToljwCVA3wbnuyiRyWx/nKA+ foBYGENgOfnpi/ToVnRQNKjCTqt2ZOZUiofecUZ/fOmoGt96LIIlLcAiifADNHkTKQe4Eb9+6 2NYaX+YYnPdXB1hzcdUQ+2QkzZ8HoS4KDy1ncBAdcuGm9nUJ8tBMLU1Bg7+3gmO3Ivl7HA5Kr IGrxW4qX4Mn/ecnjXNqjIP6/9YubSbGhtCAM9f54vIAl22vlZxMc3cGQAyisrxRBvyQ3K1tmr D0Umd2SegsA6PK96CPxCc2bmYpr/paYpkZR0DiUK50zJ1Bkgwlf1il4s8OV4UhBuCuCubX6Ef ViAMQ641mp/IfzvmopT+vYU5PwdOP8EaycRXr2GixpA/lElWDdDk9ssFgC6FB4GRPqoDw4XeA LanpLRwp3FTCEHD4qC7U/PXPgtKoEWRdXkmNI1/yklJ1KSboPA= X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.0 (---) Paul Eggert writes: Hi Paul, > I plan to install the attached patch in master soon, and am sending it > for review to bug-gnu-emacs first in case there's some problem with it > on MS-Windows. Although this patch does not fix all instances of the > race in Gnu Emacs (notably, Tramp access is still affected) it's a > good start. I haven't followed the whole thread, sorry. Could you pls elaborate, what you do expect from Tramp? Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 09 05:22:46 2017 Received: (at 28023) by debbugs.gnu.org; 9 Aug 2017 09:22:46 +0000 Received: from localhost ([127.0.0.1]:52659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfNCP-0001HP-RI for submit@debbugs.gnu.org; Wed, 09 Aug 2017 05:22:46 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:34106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfNCO-0001HB-MF for 28023@debbugs.gnu.org; Wed, 09 Aug 2017 05:22:45 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B4CA916073B; Wed, 9 Aug 2017 02:22:38 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id zqVotmqJJ_Av; Wed, 9 Aug 2017 02:22:38 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0E8BE160804; Wed, 9 Aug 2017 02:22:38 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Hqdqi2cDmSn4; Wed, 9 Aug 2017 02:22:37 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E53BE16073B; Wed, 9 Aug 2017 02:22:37 -0700 (PDT) Subject: Re: bug#28023: fix make-temp-file race on local host To: Michael Albinus References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Wed, 9 Aug 2017 02:22:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <87shh18c9e.fsf@detlef> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Michael Albinus wrote: > what you do expect from Tramp? Tramp needs to support a new method make-temp-file that creates a file (or directory) atomically, as make-temp-file does locally now. Tramp also needs to support the excl flag of write-region (currently it ignores that flag). I was planning to write this up as a bug report after the patch goes in. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 09 07:21:48 2017 Received: (at 28023) by debbugs.gnu.org; 9 Aug 2017 11:21:48 +0000 Received: from localhost ([127.0.0.1]:52708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfP3c-00043r-F1 for submit@debbugs.gnu.org; Wed, 09 Aug 2017 07:21:48 -0400 Received: from mout.gmx.net ([212.227.17.20]:53438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfP3a-00043e-Pq for 28023@debbugs.gnu.org; Wed, 09 Aug 2017 07:21:47 -0400 Received: from detlef.gmx.de ([212.91.243.217]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MIyCj-1ddUJ926Kf-002ZZi; Wed, 09 Aug 2017 13:21:30 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> Date: Wed, 09 Aug 2017 13:21:28 +0200 In-Reply-To: (Paul Eggert's message of "Wed, 9 Aug 2017 02:22:37 -0700") Message-ID: <87k22d7zrb.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:1WSAtVqZu5VioSWcZg7/tm1/xPNqupmwgWFEo7y2xC2xUXdlnSk HttBGvvfg8ldVRIf6Yb9lyLEVhfVPOfK7vnRg8M6dAdDPkYZ1xLQ31wr4owVnxP4tqezFBe 0HkCg6tW91eMJ0+1M8F5Y2K61n2/O2n/wAEoy+C1Op04DJA3s3bEjQzZCPKefB6duB2VFcQ YQvdt2UDvetRrEyltTmmw== X-UI-Out-Filterresults: notjunk:1;V01:K0:s+vaPKCG6y0=:BlsXnQ0ee+Y4m2lzDbfael 8XR55NLZHRCmahFPI7EfQMlts0pfFHzwwUAp+mjaM5B3Z+U7f1pUz56c3Jlrvs9+kkBXJieK2 LW7cpj1hW/9B+cnHjfHDCBRlju3Tw3iIgfGh+wl0L8OwBQ8O48+dO0MmYLSFPULk/zwFD0HZo xrE1tPN2FX2mf6ZhKwJhLeMuQYO+DcesCP6WRkyPRXDdJAtIOIroVWH2kVyyyltufBSluvfnt mBFROcwJDHoHNOBlVYBDimk1CfctfNs8ova7UMuQWb+4OOGx+cAABY+TVgIVj9VmqaPdm/3j1 qI6ff8uZO5Z+nELZXiaWMlx2MY4K/lA64rF73jWWus4R9n6lgSs61riqGvt+b+4mp8ocQWrVs QbtVAViRRQbD8GrYthpV7ba33vig+PiQWxi10D/0K46THPBFfWVryHprXOPkJrnglBTNbgBg4 OI6e58q4HXCny5Ho+VRW7dMQ8GYbzVlDdSBVbxtWPs93HP6lINSd3/zBPGJvA5EySqfGPnQIc qa8W6CFjjsjd7J4uMKoSJiR1td6E4eK1rNZAPecphhsGiknt77LiS3T6h5a+166oLKDmIjc3h 0rnO9nlAd9HjPe0Smew/SphjWAnjHR3CxK3kJamv4l4dWSrh46C0l36jB834ihh1IepSDYBgu K3ZZYYzJMc1ajn7cWzNNuzyKjnVA441fWTwyKQttRBUXiYwAcJWKFWLn7dWAd5fyE9h/x1ryR A3LMZm1QxrWzwrKjig4ek5zweRm1iFfsr3yP4jRcfwe2K3rKDZaddm9nazWJRV/ZzxLvHDGcI L4/UB3TNXOKuLH86tOsHaVGVVcvU/OJ+I0dA6RnPN6LIHG9ISM= X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.0 (---) Paul Eggert writes: > Tramp needs to support a new method make-temp-file that creates a file > (or directory) atomically, as make-temp-file does locally now. That means, make-temp-file shall be converted into a magic file name operation. I'll do my best, but I don't know whether we could get an implementation for all Tramp methods w/o a race condition. > Tramp also needs to support the excl flag of write-region (currently > it ignores that flag). This sounds trivial. And yes, it will help. > I was planning to write this up as a bug report after the patch goes > in. Pls do. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 09 12:05:44 2017 Received: (at 28023) by debbugs.gnu.org; 9 Aug 2017 16:05:44 +0000 Received: from localhost ([127.0.0.1]:53486 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfTUN-0006Bd-RR for submit@debbugs.gnu.org; Wed, 09 Aug 2017 12:05:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfTUM-0006BR-Nw for 28023@debbugs.gnu.org; Wed, 09 Aug 2017 12:05:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfTUE-0000cS-Hc for 28023@debbugs.gnu.org; Wed, 09 Aug 2017 12:05:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:35977) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfTUE-0000c8-8O; Wed, 09 Aug 2017 12:05:34 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1944 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dfTUD-0002s3-Ds; Wed, 09 Aug 2017 12:05:34 -0400 Date: Wed, 09 Aug 2017 19:05:16 +0300 Message-Id: <83poc4sp4z.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> (message from Paul Eggert on Tue, 8 Aug 2017 22:38:05 -0700) Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Paul Eggert > Date: Tue, 8 Aug 2017 22:38:05 -0700 > > I plan to install the attached patch in master soon, and am sending it for > review to bug-gnu-emacs first in case there's some problem with it on > MS-Windows. Thanks for the heads-up. Unfortunately, it isn't as simple as we'd like it to be, because Gnulib doesn't support file names encoded in UTF-8 (or any other encoding except the current system codepage) on MS-Windows, while Emacs does. We could resolve this problem by providing a way for the Windows build to specify its own replacements for 'open', 'mkdir', and 'lstat' (Emacs already have such replacements in w32.c), which tempname.c calls, but that would require minor changes in Gnulib's tempname.c. Or we could steal the relevant code from tempname.c into a Windows-specific implementation in w32.c, and refrain from using the Gnulib version on Windows. Which way would you prefer to go? Or maybe you have yet another idea? > @@ -1915,9 +1913,7 @@ endif > ## begin gnulib module secure_getenv > ifeq (,$(OMIT_GNULIB_MODULE_secure_getenv)) > > -ifneq (,$(gl_GNULIB_ENABLED_secure_getenv)) > > -endif > EXTRA_DIST += secure_getenv.c This seems to say that we will sometimes use secure_getenv, but the relevant code in tempname.c is conditioned on _LIBC, which AFAIU is only true when building glibc, so why do we need that? Or did I miss something? From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 09 14:47:48 2017 Received: (at 28023) by debbugs.gnu.org; 9 Aug 2017 18:47:48 +0000 Received: from localhost ([127.0.0.1]:53605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfW1D-0001ZI-8c for submit@debbugs.gnu.org; Wed, 09 Aug 2017 14:47:47 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:57886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfW1A-0001Z2-PW for 28023@debbugs.gnu.org; Wed, 09 Aug 2017 14:47:45 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 82D6716073B; Wed, 9 Aug 2017 11:47:38 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id j9EHZt8yMH2k; Wed, 9 Aug 2017 11:47:36 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9240B16074C; Wed, 9 Aug 2017 11:47:36 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id I1lnNHdYKmi4; Wed, 9 Aug 2017 11:47:36 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 7108816073B; Wed, 9 Aug 2017 11:47:36 -0700 (PDT) Subject: Re: bug#28023: fix make-temp-file race on local host To: Eli Zaretskii References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <83poc4sp4z.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> Date: Wed, 9 Aug 2017 11:47:36 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83poc4sp4z.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------0138FBDD491196BADD4C909E" Content-Language: en-US X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) This is a multi-part message in MIME format. --------------0138FBDD491196BADD4C909E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 08/09/2017 09:05 AM, Eli Zaretskii wrote: > We could resolve this problem by providing a way for the Windows build > to specify its own replacements for 'open', 'mkdir', and 'lstat' > (Emacs already have such replacements in w32.c), which tempname.c > calls, but that would require minor changes in Gnulib's tempname.c. This sounds like a better way to go. What minor changes would be needed? tempname.c already includes config.h, which includes ms-w32.h, which redefines open, mkdir, and lstat, so I thought it would work as-is. > This seems to say that we will sometimes use secure_getenv, but the > relevant code in tempname.c is conditioned on _LIBC, which AFAIU is > only true when building glibc, so why do we need that? Or did I miss > something? No, good catch, Emacs never needs secure_getenv. I fixed Gnulib, installed the attached patch to propagate that fix, and will adjust the proposed make-temp-file patch accordingly. --------------0138FBDD491196BADD4C909E Content-Type: text/x-patch; name="0001-Merge-from-gnulib.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Merge-from-gnulib.patch" >From 8daab9f4a0ff6dbcfbd0c6f9262e41753de3484b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 9 Aug 2017 11:38:04 -0700 Subject: [PATCH] Merge from gnulib This incorporates: 2017-08-09 tempname: do not depend on secure_getenv 2017-08-08 extensions: add _OPENBSD_SOURCE 2017-08-06 manywarnings: Add support for C++ 2017-08-06 warnings, manywarnings: Add support for multiple languages * admin/merge-gnulib: Don't use m4/manywarnings-c++.m4. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/secure_getenv.c, m4/secure_getenv.m4: Remove. * lib/tempname.c, m4/extensions.m4, m4/manywarnings.m4, m4/warnings.m4: Copy from gnulib. --- admin/merge-gnulib | 1 + lib/gnulib.mk.in | 14 -------------- lib/secure_getenv.c | 54 ----------------------------------------------------- lib/tempname.c | 1 - m4/extensions.m4 | 7 ++++++- m4/gnulib-comp.m4 | 19 +------------------ m4/manywarnings.m4 | 18 +++++++++++++++++- m4/secure_getenv.m4 | 26 -------------------------- m4/warnings.m4 | 47 +++++++++++++++++++++++++++++++++++----------- 9 files changed, 61 insertions(+), 126 deletions(-) delete mode 100644 lib/secure_getenv.c delete mode 100644 m4/secure_getenv.m4 diff --git a/admin/merge-gnulib b/admin/merge-gnulib index c23e8a40ea..a16d7fa53e 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -106,6 +106,7 @@ avoided_flags= rm -- "$src"lib/gl_openssl.h "$src"m4/fcntl-o.m4 \ "$src"m4/gl-openssl.m4 \ "$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \ + "$src"m4/manywarnings-c++.m4 \ "$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 && cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc && cp -- "$gnulib_srcdir"/build-aux/config.guess \ diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index a385c8c838..c5df3f42e4 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -903,7 +903,6 @@ gl_GNULIB_ENABLED_dosname = @gl_GNULIB_ENABLED_dosname@ gl_GNULIB_ENABLED_euidaccess = @gl_GNULIB_ENABLED_euidaccess@ gl_GNULIB_ENABLED_getdtablesize = @gl_GNULIB_ENABLED_getdtablesize@ gl_GNULIB_ENABLED_getgroups = @gl_GNULIB_ENABLED_getgroups@ -gl_GNULIB_ENABLED_secure_getenv = @gl_GNULIB_ENABLED_secure_getenv@ gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@ gl_GNULIB_ENABLED_tempname = @gl_GNULIB_ENABLED_tempname@ gl_LIBOBJS = @gl_LIBOBJS@ @@ -1912,19 +1911,6 @@ EXTRA_DIST += root-uid.h endif ## end gnulib module root-uid -## begin gnulib module secure_getenv -ifeq (,$(OMIT_GNULIB_MODULE_secure_getenv)) - -ifneq (,$(gl_GNULIB_ENABLED_secure_getenv)) - -endif -EXTRA_DIST += secure_getenv.c - -EXTRA_libgnu_a_SOURCES += secure_getenv.c - -endif -## end gnulib module secure_getenv - ## begin gnulib module sig2str ifeq (,$(OMIT_GNULIB_MODULE_sig2str)) diff --git a/lib/secure_getenv.c b/lib/secure_getenv.c deleted file mode 100644 index df53dea0b2..0000000000 --- a/lib/secure_getenv.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Look up an environment variable, returning NULL in insecure situations. - - Copyright 2013-2017 Free Software Foundation, Inc. - - 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 . */ - -#include - -#include - -#if !HAVE___SECURE_GETENV -# if HAVE_ISSETUGID || (HAVE_GETUID && HAVE_GETEUID && HAVE_GETGID && HAVE_GETEGID) -# include -# endif -#endif - -char * -secure_getenv (char const *name) -{ -#if HAVE___SECURE_GETENV /* glibc */ - return __secure_getenv (name); -#elif HAVE_ISSETUGID /* OS X, FreeBSD, NetBSD, OpenBSD */ - if (issetugid ()) - return NULL; - return getenv (name); -#elif HAVE_GETUID && HAVE_GETEUID && HAVE_GETGID && HAVE_GETEGID /* other Unix */ - if (geteuid () != getuid () || getegid () != getgid ()) - return NULL; - return getenv (name); -#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* native Windows */ - /* On native Windows, there is no such concept as setuid or setgid binaries. - - Programs launched as system services have high privileges, but they don't - inherit environment variables from a user. - - Programs launched by a user with "Run as Administrator" have high - privileges and use the environment variables, but the user has been asked - whether he agrees. - - Programs launched by a user without "Run as Administrator" cannot gain - high privileges, therefore there is no risk. */ - return getenv (name); -#else - return NULL; -#endif -} diff --git a/lib/tempname.c b/lib/tempname.c index 9c4a3c2a54..c274b8dd4e 100644 --- a/lib/tempname.c +++ b/lib/tempname.c @@ -69,7 +69,6 @@ # define __mkdir mkdir # define __open open # define __lxstat64(version, file, buf) lstat (file, buf) -# define __secure_getenv secure_getenv #endif #ifdef _LIBC diff --git a/m4/extensions.m4 b/m4/extensions.m4 index c60f537db1..0c16bb832f 100644 --- a/m4/extensions.m4 +++ b/m4/extensions.m4 @@ -1,4 +1,4 @@ -# serial 15 -*- Autoconf -*- +# serial 16 -*- Autoconf -*- # Enable extensions on systems that normally disable them. # Copyright (C) 2003, 2006-2017 Free Software Foundation, Inc. @@ -68,6 +68,10 @@ AC_DEFUN_ONCE #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif +/* Enable OpenBSD extensions on NetBSD. */ +#ifndef _OPENBSD_SOURCE +# undef _OPENBSD_SOURCE +#endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS @@ -128,6 +132,7 @@ AC_DEFUN_ONCE AC_DEFINE([_ALL_SOURCE]) AC_DEFINE([_DARWIN_C_SOURCE]) AC_DEFINE([_GNU_SOURCE]) + AC_DEFINE([_OPENBSD_SOURCE]) AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__]) AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__]) diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 188c116c85..69d77229bf 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -124,7 +124,6 @@ AC_DEFUN # 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: @@ -424,7 +423,6 @@ AC_DEFUN gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false - gl_gnulib_enabled_secure_getenv=false gl_gnulib_enabled_strtoll=false gl_gnulib_enabled_tempname=false gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false @@ -550,18 +548,6 @@ AC_DEFUN 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_strtoll () { if ! $gl_gnulib_enabled_strtoll; then @@ -579,7 +565,6 @@ AC_DEFUN 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 () @@ -658,7 +643,6 @@ AC_DEFUN AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) 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_strtoll], [$gl_gnulib_enabled_strtoll]) AM_CONDITIONAL([gl_GNULIB_ENABLED_tempname], [$gl_gnulib_enabled_tempname]) AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) @@ -907,7 +891,6 @@ AC_DEFUN lib/readlink.c lib/readlinkat.c lib/root-uid.h - lib/secure_getenv.c lib/set-permissions.c lib/sha1.c lib/sha1.h @@ -1008,6 +991,7 @@ AC_DEFUN m4/localtime-buffer.m4 m4/longlong.m4 m4/lstat.m4 + m4/manywarnings-c++.m4 m4/manywarnings.m4 m4/md5.m4 m4/memrchr.m4 @@ -1024,7 +1008,6 @@ AC_DEFUN m4/putenv.m4 m4/readlink.m4 m4/readlinkat.m4 - m4/secure_getenv.m4 m4/sha1.m4 m4/sha256.m4 m4/sha512.m4 diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4 index 6a8939b2c1..a3d255a940 100644 --- a/m4/manywarnings.m4 +++ b/m4/manywarnings.m4 @@ -1,4 +1,4 @@ -# manywarnings.m4 serial 10 +# manywarnings.m4 serial 11 dnl Copyright (C) 2008-2017 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -33,8 +33,16 @@ AC_DEFUN # Add all documented GCC warning parameters to variable VARIABLE. # Note that you need to test them using gl_WARN_ADD if you want to # make sure your gcc understands it. +# +# The effects of this macro depend on the current language (_AC_LANG). AC_DEFUN([gl_MANYWARN_ALL_GCC], +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + +# Specialization for _AC_LANG = C. +AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], [ + AC_LANG_PUSH([C]) + dnl First, check for some issues that only occur when combining multiple dnl gcc warning categories. AC_REQUIRE([AC_PROG_CC]) @@ -303,4 +311,12 @@ AC_DEFUN fi $1=$gl_manywarn_set + + AC_LANG_POP([C]) +]) + +# Specialization for _AC_LANG = C++. +AC_DEFUN([gl_MANYWARN_ALL_GCC(C++)], +[ + gl_MANYWARN_ALL_GCC_CXX_IMPL([$1]) ]) diff --git a/m4/secure_getenv.m4 b/m4/secure_getenv.m4 deleted file mode 100644 index 6bd4afd9c1..0000000000 --- a/m4/secure_getenv.m4 +++ /dev/null @@ -1,26 +0,0 @@ -# Look up an environment variable more securely. -dnl Copyright 2013-2017 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 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 - AC_CHECK_FUNCS_ONCE([getuid geteuid getgid getegid]) -]) diff --git a/m4/warnings.m4 b/m4/warnings.m4 index e697174edd..aa2735b77f 100644 --- a/m4/warnings.m4 +++ b/m4/warnings.m4 @@ -1,4 +1,4 @@ -# warnings.m4 serial 11 +# warnings.m4 serial 12 dnl Copyright (C) 2008-2017 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -20,10 +20,12 @@ # ----------------------------------------------------------------- # Check if the compiler supports OPTION when compiling PROGRAM. # -# FIXME: gl_Warn must be used unquoted until we can assume Autoconf -# 2.64 or newer. +# The effects of this macro depend on the current language (_AC_LANG). AC_DEFUN([gl_COMPILER_OPTION_IF], -[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl +[ +dnl FIXME: gl_Warn must be used unquoted until we can assume Autoconf +dnl 2.64 or newer. +AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl AS_LITERAL_IF([$1], [m4_pushdef([gl_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))], @@ -51,27 +53,50 @@ AC_DEFUN # ------------------------------ # Clang doesn't complain about unknown warning options unless one also # specifies -Wunknown-warning-option -Werror. Detect this. +# +# The effects of this macro depend on the current language (_AC_LANG). AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS], +[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) + +# Specialization for _AC_LANG = C. This macro can be AC_REQUIREd. +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C)], +[ + AC_LANG_PUSH([C]) + gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL + AC_LANG_POP([C]) +]) + +# Specialization for _AC_LANG = C++. This macro can be AC_REQUIREd. +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C++)], +[ + AC_LANG_PUSH([C++]) + gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL + AC_LANG_POP([C++]) +]) + +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL], [gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option], [gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'], [gl_unknown_warnings_are_errors=])]) -# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS], +# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS/WARN_CXXFLAGS], # [PROGRAM = AC_LANG_PROGRAM()]) -# --------------------------------------------- -# Adds parameter to WARN_CFLAGS if the compiler supports it when -# compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]). +# ----------------------------------------------------------- +# Adds parameter to WARN_CFLAGS/WARN_CXXFLAGS if the compiler supports it +# when compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]). # # If VARIABLE is a variable name, AC_SUBST it. +# +# The effects of this macro depend on the current language (_AC_LANG). AC_DEFUN([gl_WARN_ADD], -[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS]) +[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS(]_AC_LANG[)]) gl_COMPILER_OPTION_IF([$1], - [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])], + [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_]_AC_LANG_PREFIX[FLAGS]], [[$2]]), [" $1"])], [], [$3]) m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])])], - [AC_SUBST([WARN_CFLAGS])])dnl + [AC_SUBST([WARN_]_AC_LANG_PREFIX[FLAGS])])dnl ]) # Local Variables: -- 2.13.4 --------------0138FBDD491196BADD4C909E-- From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 09 15:10:53 2017 Received: (at 28023) by debbugs.gnu.org; 9 Aug 2017 19:10:53 +0000 Received: from localhost ([127.0.0.1]:53631 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfWNY-00026G-6M for submit@debbugs.gnu.org; Wed, 09 Aug 2017 15:10:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58950) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfWNU-000261-Be for 28023@debbugs.gnu.org; Wed, 09 Aug 2017 15:10:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfWNM-0005T9-9P for 28023@debbugs.gnu.org; Wed, 09 Aug 2017 15:10:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43307) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfWNM-0005Sr-5m; Wed, 09 Aug 2017 15:10:40 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2506 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dfWNC-0005bd-KC; Wed, 09 Aug 2017 15:10:39 -0400 Date: Wed, 09 Aug 2017 22:09:41 +0300 Message-Id: <83lgmssglm.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> (message from Paul Eggert on Wed, 9 Aug 2017 11:47:36 -0700) Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <83poc4sp4z.fsf@gnu.org> <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: 28023@debbugs.gnu.org > From: Paul Eggert > Date: Wed, 9 Aug 2017 11:47:36 -0700 > > On 08/09/2017 09:05 AM, Eli Zaretskii wrote: > > We could resolve this problem by providing a way for the Windows build > > to specify its own replacements for 'open', 'mkdir', and 'lstat' > > (Emacs already have such replacements in w32.c), which tempname.c > > calls, but that would require minor changes in Gnulib's tempname.c. > > This sounds like a better way to go. What minor changes would be needed? > tempname.c already includes config.h, which includes ms-w32.h, which > redefines open, mkdir, and lstat, so I thought it would work as-is. 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). > > This seems to say that we will sometimes use secure_getenv, but the > > relevant code in tempname.c is conditioned on _LIBC, which AFAIU is > > only true when building glibc, so why do we need that? Or did I miss > > something? > No, good catch, Emacs never needs secure_getenv. I fixed Gnulib, > installed the attached patch to propagate that fix, and will adjust the > proposed make-temp-file patch accordingly. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 09 19:37:13 2017 Received: (at 28023) by debbugs.gnu.org; 9 Aug 2017 23:37:13 +0000 Received: from localhost ([127.0.0.1]:53823 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfaXI-0003mx-GN for submit@debbugs.gnu.org; Wed, 09 Aug 2017 19:37:13 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:40696) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfaXC-0003mO-3i for 28023@debbugs.gnu.org; Wed, 09 Aug 2017 19:37:09 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 192E216080A; Wed, 9 Aug 2017 16:37:00 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id yTj8gsKvQGVO; Wed, 9 Aug 2017 16:36:56 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1EB4716080B; Wed, 9 Aug 2017 16:36:56 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ZJpKX70tOZtr; Wed, 9 Aug 2017 16:36:55 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E324B1607C5; Wed, 9 Aug 2017 16:36:55 -0700 (PDT) Subject: Re: bug#28023: fix make-temp-file race on local host To: Eli Zaretskii References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <83poc4sp4z.fsf@gnu.org> <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> <83lgmssglm.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <704c73b8-54f1-f7ac-821b-6d715a21a8a2@cs.ucla.edu> Date: Wed, 9 Aug 2017 16:36:55 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83lgmssglm.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------CBA433A108EAB7759352E77E" Content-Language: en-US X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) This is a multi-part message in MIME format. --------------CBA433A108EAB7759352E77E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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. 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. I've tested only the first attached patch, though: it is basically the same as before except it's rebased to current master. --------------CBA433A108EAB7759352E77E Content-Type: text/x-patch; name="0001-Fix-make-temp-file-race-on-local-files.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Fix-make-temp-file-race-on-local-files.patch" =46rom 7fe4062aebf56a7de1ae389907098cd461f8d485 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 9 Aug 2017 16:34:40 -0700 Subject: [PATCH 1/2] Fix make-temp-file race on local files For the motivation behind this patch, please see Bug#28023 and: http://emacshorrors.com/posts/make-temp-name.html The race still exists for magic file names; fixing this will require Tramp surgery. * admin/merge-gnulib (GNULIB_MODULES): Add tempname, now that Emacs is using it directly. * configure.ac (AUTO_DEPEND): Remove AC_SYS_LONG_FILE_NAMES; no longer needed. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lisp/files.el (files--make-magic-temp-file): Rename from make-temp-file. Add comment describing race bug. (make-temp-file): Use fileio--make-temp-file for non-magic files names. * src/fileio.c: Include tempname.h. (make_temp_name_tbl, make_temp_name_count) (make_temp_name_count_initialized_p, make_temp_name): Remove. (Ffileio__make_temp_file): New function. (Fmake_temp_name): Use it. * src/filelock.c (get_boot_time): Use Ffileio__make_temp_file instead of make_temp_name; this avoids a race. --- admin/CPP-DEFINES | 1 - admin/merge-gnulib | 4 +- configure.ac | 3 - lib/gnulib.mk.in | 5 +- lisp/files.el | 15 +++++ m4/gnulib-comp.m4 | 13 +--- src/buffer.c | 1 - src/fileio.c | 170 ++++++++++++++---------------------------------= ------ src/filelock.c | 13 ++-- src/lisp.h | 1 - 10 files changed, 69 insertions(+), 157 deletions(-) diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index cead305aee..10b558d1ad 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -205,7 +205,6 @@ HAVE_LIBXML2 HAVE_LIBXMU HAVE_LOCALTIME_R HAVE_LOCAL_SOCKETS -HAVE_LONG_FILE_NAMES HAVE_LONG_LONG_INT HAVE_LRAND48 HAVE_LSTAT diff --git a/admin/merge-gnulib b/admin/merge-gnulib index a16d7fa53e..7eca64305d 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -39,8 +39,8 @@ GNULIB_MODULES=3D manywarnings memrchr minmax mkostemp mktime nstrftime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio - stpcpy strtoimax symlink sys_stat - sys_time time time_r time_rz timegm timer-time timespec-add timespec-s= ub + stpcpy strtoimax symlink sys_stat sys_time + tempname time time_r time_rz timegm timer-time timespec-add timespec-s= ub update-copyright unlocked-io utimens vla warnings ' diff --git a/configure.ac b/configure.ac index 9f80620a80..86d5b3e94f 100644 --- a/configure.ac +++ b/configure.ac @@ -1779,9 +1779,6 @@ AC_DEFUN fi AC_SUBST(AUTO_DEPEND) =20 -dnl checks for operating system services -AC_SYS_LONG_FILE_NAMES - #### Choose a window system. =20 ## We leave window_system equal to none if diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index c5df3f42e4..30986b4ed7 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --lib=3Dlibgnu --source-base=3Dlib = --m4-base=3Dm4 --doc-base=3Ddoc --tests-base=3Dtests --aux-dir=3Dbuild-au= x --avoid=3Dclose --avoid=3Ddup --avoid=3Dfchdir --avoid=3Dfstat --avoid=3D= malloc-posix --avoid=3Dmsvc-inval --avoid=3Dmsvc-nothrow --avoid=3Dopen -= -avoid=3Dopenat-die --avoid=3Dopendir --avoid=3Draise --avoid=3Dsave-cwd = --avoid=3Dselect --avoid=3Dsetenv --avoid=3Dsigprocmask --avoid=3Dstat --= avoid=3Dstdarg --avoid=3Dstdbool --avoid=3Dthreadlib --avoid=3Dtzset --av= oid=3Dunsetenv --avoid=3Dutime --avoid=3Dutime-h --gnu-make --makefile-na= me=3Dgnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=3D= gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadli= nkat close-stream count-leading-zeros count-one-bits count-trailing-zeros= crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 d-type diffseq dtoast= r dtotimespec dup2 environ execinfo explicit_bzero faccessat fcntl fcntl-= h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloa= davg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value int= props largefile lstat manywarnings memrchr minmax mkostemp mktime nstrfti= me pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig= 2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strtoimax s= ymlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-a= dd timespec-sub unlocked-io update-copyright utimens vla warnings +# Reproduce by: gnulib-tool --import --lib=3Dlibgnu --source-base=3Dlib = --m4-base=3Dm4 --doc-base=3Ddoc --tests-base=3Dtests --aux-dir=3Dbuild-au= x --avoid=3Dclose --avoid=3Ddup --avoid=3Dfchdir --avoid=3Dfstat --avoid=3D= malloc-posix --avoid=3Dmsvc-inval --avoid=3Dmsvc-nothrow --avoid=3Dopen -= -avoid=3Dopenat-die --avoid=3Dopendir --avoid=3Draise --avoid=3Dsave-cwd = --avoid=3Dselect --avoid=3Dsetenv --avoid=3Dsigprocmask --avoid=3Dstat --= avoid=3Dstdarg --avoid=3Dstdbool --avoid=3Dthreadlib --avoid=3Dtzset --av= oid=3Dunsetenv --avoid=3Dutime --avoid=3Dutime-h --gnu-make --makefile-na= me=3Dgnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=3D= gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadli= nkat close-stream count-leading-zeros count-one-bits count-trailing-zeros= crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 d-type diffseq dtoast= r dtotimespec dup2 environ execinfo explicit_bzero faccessat fcntl fcntl-= h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloa= davg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value int= props largefile lstat manywarnings memrchr minmax mkostemp mktime nstrfti= me pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig= 2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strtoimax s= ymlink sys_stat sys_time tempname time time_r time_rz timegm timer-time t= imespec-add timespec-sub unlocked-io update-copyright utimens vla warning= s =20 =20 MOSTLYCLEANFILES +=3D core *.stackdump @@ -904,7 +904,6 @@ gl_GNULIB_ENABLED_euidaccess =3D @gl_GNULIB_ENABLED_e= uidaccess@ gl_GNULIB_ENABLED_getdtablesize =3D @gl_GNULIB_ENABLED_getdtablesize@ gl_GNULIB_ENABLED_getgroups =3D @gl_GNULIB_ENABLED_getgroups@ gl_GNULIB_ENABLED_strtoll =3D @gl_GNULIB_ENABLED_strtoll@ -gl_GNULIB_ENABLED_tempname =3D @gl_GNULIB_ENABLED_tempname@ gl_LIBOBJS =3D @gl_LIBOBJS@ gl_LTLIBOBJS =3D @gl_LTLIBOBJS@ gltests_LIBOBJS =3D @gltests_LIBOBJS@ @@ -2701,10 +2700,8 @@ endif ## begin gnulib module tempname ifeq (,$(OMIT_GNULIB_MODULE_tempname)) =20 -ifneq (,$(gl_GNULIB_ENABLED_tempname)) libgnu_a_SOURCES +=3D tempname.c =20 -endif EXTRA_DIST +=3D tempname.h =20 endif diff --git a/lisp/files.el b/lisp/files.el index f2758ab18c..3ed36d24db 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1417,6 +1417,19 @@ make-temp-file If DIR-FLAG is non-nil, create a new empty directory instead of a file. =20 If SUFFIX is non-nil, add that at the end of the file name." + (let ((absolute-prefix (expand-file-name prefix temporary-file-directo= ry))) + ;; FIXME: Establish make-temp-file file name handlers, + ;; to create temporary files and directories without races. + ;; For now, if the prefix is magic, fall back on the traditional, + ;; insecure way to create temporary files. + (if (find-file-name-handler absolute-prefix 'write-region) + (files--make-magic-temp-file prefix dir-flag suffix) + (fileio--make-temp-file absolute-prefix + (if dir-flag t) (or suffix ""))))) + +(defun files--make-magic-temp-file (prefix &optional dir-flag suffix) + "Implement (make-temp-file PREFIX DIR-FLAG SUFFIX), +even if the result is a magic file name." ;; Create temp files with strict access rights. It's easy to ;; loosen them later, whereas it's impossible to close the ;; time-window of loose permissions otherwise. @@ -1435,6 +1448,8 @@ make-temp-file (setq file (concat file suffix))) (if dir-flag (make-directory file) + ;; FIXME: The 'excl is only aspirational; it is + ;; actually a no-op if FILE is a magic file name. (write-region "" nil file nil 'silent nil 'excl)) nil) (file-already-exists t)) diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 69d77229bf..d1089860e1 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -387,6 +387,7 @@ AC_DEFUN AC_PROG_MKDIR_P gl_SYS_TYPES_H AC_PROG_MKDIR_P + gl_FUNC_GEN_TEMPNAME gl_HEADER_TIME_H gl_TIME_R if test $HAVE_LOCALTIME_R =3D 0 || test $REPLACE_LOCALTIME_R =3D 1; th= en @@ -424,7 +425,6 @@ AC_DEFUN gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=3Dfalse gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=3Dfalse gl_gnulib_enabled_strtoll=3Dfalse - gl_gnulib_enabled_tempname=3Dfalse gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=3Dfalse func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () { @@ -560,13 +560,6 @@ AC_DEFUN gl_gnulib_enabled_strtoll=3Dtrue fi } - func_gl_gnulib_m4code_tempname () - { - if ! $gl_gnulib_enabled_tempname; then - gl_FUNC_GEN_TEMPNAME - gl_gnulib_enabled_tempname=3Dtrue - fi - } func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () { if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then @@ -612,9 +605,6 @@ AC_DEFUN if test $REPLACE_LSTAT =3D 1; then func_gl_gnulib_m4code_dosname fi - if test $HAVE_MKOSTEMP =3D 0; then - func_gl_gnulib_m4code_tempname - fi if test $HAVE_READLINKAT =3D 0; then func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b fi @@ -644,7 +634,6 @@ AC_DEFUN AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [= $gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [= $gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtol= l]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_tempname], [$gl_gnulib_enabled_tempn= ame]) AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [= $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) # End of code from modules m4_ifval(gl_LIBSOURCES_LIST, [ diff --git a/src/buffer.c b/src/buffer.c index 0d0f43e937..2d508f35cf 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1085,7 +1085,6 @@ is first appended to NAME, to speed up finding a no= n-existent buffer. */) genbase =3D name; else { - /* Note fileio.c:make_temp_name does random differently. */ char number[sizeof "-999999"]; int i =3D XFASTINT (Frandom (make_number (999999))); AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%d", i))= ; diff --git a/src/fileio.c b/src/fileio.c index 15845e3914..1ef9bfa82b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -97,6 +97,7 @@ along with GNU Emacs. If not, see . */ #include #include #include +#include =20 #include =20 @@ -623,149 +624,67 @@ In Unix-syntax, this function just removes the fin= al slash. */) return val; } =20 -static const char make_temp_name_tbl[64] =3D -{ - 'A','B','C','D','E','F','G','H', - 'I','J','K','L','M','N','O','P', - 'Q','R','S','T','U','V','W','X', - 'Y','Z','a','b','c','d','e','f', - 'g','h','i','j','k','l','m','n', - 'o','p','q','r','s','t','u','v', - 'w','x','y','z','0','1','2','3', - '4','5','6','7','8','9','-','_' -}; - -static unsigned make_temp_name_count, make_temp_name_count_initialized_p= ; - -/* Value is a temporary file name starting with PREFIX, a string. +DEFUN ("fileio--make-temp-file", Ffileio__make_temp_file, + Sfileio__make_temp_file, 3, 3, 0, + doc: /* Generate a new file whose name starts with PREFIX, a stri= ng. +Return the name of the generated file. If DIR-FLAG is zero, do not +create the file, just its name. Otherwise, if DIR-FLAG is non-nil, +create an empty directory. The file name should end in SUFFIX. =20 - The Emacs process number forms part of the result, so there is - no danger of generating a name being used by another process. - In addition, this function makes an attempt to choose a name - which has no existing file. To make this work, PREFIX should be - an absolute file name. +Signal an error if the file could not be created. =20 - BASE64_P means add the pid as 3 characters in base64 - encoding. In this case, 6 characters will be added to PREFIX to - form the file name. Otherwise, if Emacs is running on a system - with long file names, add the pid as a decimal number. - - This function signals an error if no unique file name could be - generated. */ - -Lisp_Object -make_temp_name (Lisp_Object prefix, bool base64_p) +This function does not grok magic file names. */) + (Lisp_Object prefix, Lisp_Object dir_flag, Lisp_Object suffix) { - Lisp_Object val, encoded_prefix; - ptrdiff_t len; - printmax_t pid; - char *p, *data; - char pidbuf[INT_BUFSIZE_BOUND (printmax_t)]; - int pidlen; - - CHECK_STRING (prefix); - - /* VAL is created by adding 6 characters to PREFIX. The first - three are the PID of this process, in base 64, and the second - three are incremented if the file already exists. This ensures - 262144 unique file names per PID per PREFIX. */ - - pid =3D getpid (); - - if (base64_p) - { - pidbuf[0] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidbuf[1] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidbuf[2] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidlen =3D 3; - } - else + bool make_temp_name =3D EQ (dir_flag, make_number (0)); + CHECK_STRING (suffix); + if (!make_temp_name) + prefix =3D Fexpand_file_name (prefix, Vtemporary_file_directory); + + Lisp_Object encoded_prefix =3D ENCODE_FILE (prefix); + Lisp_Object encoded_suffix =3D ENCODE_FILE (suffix); + ptrdiff_t prefix_len =3D SBYTES (encoded_prefix); + ptrdiff_t suffix_len =3D SBYTES (encoded_suffix); + if (INT_MAX < suffix_len) + args_out_of_range (prefix, suffix); + int nX =3D 6; + Lisp_Object val =3D make_uninit_string (prefix_len + nX + suffix_len);= + char *data =3D SSDATA (val); + memcpy (data, SSDATA (encoded_prefix), prefix_len); + memset (data + prefix_len, 'X', nX); + memcpy (data + prefix_len + nX, SSDATA (encoded_suffix), suffix_len); + int kind =3D (NILP (dir_flag) ? GT_FILE + : make_temp_name ? GT_NOCREATE + : GT_DIR); + int fd =3D gen_tempname (data, suffix_len, O_BINARY | O_CLOEXEC, kind)= ; + if (fd < 0 || (NILP (dir_flag) && emacs_close (fd) !=3D 0)) { -#ifdef HAVE_LONG_FILE_NAMES - pidlen =3D sprintf (pidbuf, "%"pMd, pid); -#else - pidbuf[0] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidbuf[1] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidbuf[2] =3D make_temp_name_tbl[pid & 63], pid >>=3D 6; - pidlen =3D 3; -#endif - } - - encoded_prefix =3D ENCODE_FILE (prefix); - len =3D SBYTES (encoded_prefix); - val =3D make_uninit_string (len + 3 + pidlen); - data =3D SSDATA (val); - memcpy (data, SSDATA (encoded_prefix), len); - p =3D data + len; - - memcpy (p, pidbuf, pidlen); - p +=3D pidlen; - - /* Here we try to minimize useless stat'ing when this function is - invoked many times successively with the same PREFIX. We achieve - this by initializing count to a random value, and incrementing it - afterwards. - - We don't want make-temp-name to be called while dumping, - because then make_temp_name_count_initialized_p would get set - and then make_temp_name_count would not be set when Emacs starts. = */ - - if (!make_temp_name_count_initialized_p) - { - make_temp_name_count =3D time (NULL); - make_temp_name_count_initialized_p =3D 1; - } - - while (1) - { - unsigned num =3D make_temp_name_count; - - p[0] =3D make_temp_name_tbl[num & 63], num >>=3D 6; - p[1] =3D make_temp_name_tbl[num & 63], num >>=3D 6; - p[2] =3D make_temp_name_tbl[num & 63], num >>=3D 6; - - /* Poor man's congruential RN generator. Replace with - ++make_temp_name_count for debugging. */ - make_temp_name_count +=3D 25229; - make_temp_name_count %=3D 225307; - - if (!check_existing (data)) + static char const kind_message[][32] =3D { - /* We want to return only if errno is ENOENT. */ - if (errno =3D=3D ENOENT) - return DECODE_FILE (val); - else - /* The error here is dubious, but there is little else we - can do. The alternatives are to return nil, which is - as bad as (and in many cases worse than) throwing the - error, or to ignore the error, which will likely result - in looping through 225307 stat's, which is not only - dog-slow, but also useless since eventually nil would - have to be returned anyway. */ - report_file_error ("Cannot create temporary name for prefix", - prefix); - /* not reached */ - } + [GT_FILE] =3D "Creating file with prefix", + [GT_DIR] =3D "Creating directory with prefix", + [GT_NOCREATE] =3D "Creating file name with prefix" + }; + report_file_error (kind_message[kind], prefix); } + return DECODE_FILE (val); } =20 =20 DEFUN ("make-temp-name", Fmake_temp_name, Smake_temp_name, 1, 1, 0, doc: /* Generate temporary file name (string) starting with PREFI= X (a string). -The Emacs process number forms part of the result, so there is no -danger of generating a name being used by another Emacs process -\(so long as only a single host can access the containing directory...).= =20 This function tries to choose a name that has no existing file. For this to work, PREFIX should be an absolute file name, and PREFIX and the returned string should both be non-magic. =20 -There is a race condition between calling `make-temp-name' and creating = the -file, which opens all kinds of security holes. For that reason, you sho= uld -normally use `make-temp-file' instead. */) +There is a race condition between calling `make-temp-name' and +later creating the file, which opens all kinds of security holes. +For that reason, you should normally use `make-temp-file' instead. */) (Lisp_Object prefix) { - return make_temp_name (prefix, 0); + return Ffileio__make_temp_file (prefix, make_number (0), + empty_unibyte_string); } =20 DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0= , @@ -6167,6 +6086,7 @@ This includes interactive calls to `delete-file' an= d defsubr (&Sunhandled_file_name_directory); defsubr (&Sfile_name_as_directory); defsubr (&Sdirectory_file_name); + defsubr (&Sfileio__make_temp_file); defsubr (&Smake_temp_name); defsubr (&Sexpand_file_name); defsubr (&Ssubstitute_in_file_name); diff --git a/src/filelock.c b/src/filelock.c index dd8cb28c42..5614657985 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -206,14 +206,11 @@ get_boot_time (void) WTMP_FILE, counter); if (! NILP (Ffile_exists_p (tempname))) { - /* The utmp functions on mescaline.gnu.org accept only - file names up to 8 characters long. Choose a 2 - character long prefix, and call make_temp_file with - second arg non-zero, so that it will add not more - than 6 characters to the prefix. */ - filename =3D Fexpand_file_name (build_string ("wt"), - Vtemporary_file_directory); - filename =3D make_temp_name (filename, 1); + /* The utmp functions on older systems accept only file + names up to 8 bytes long. Choose a 2 byte prefix, so + the 6-byte suffix does not make the name too long. */ + filename =3D Ffileio__make_temp_file (build_string ("wt"), Qnil, + empty_unibyte_string); CALLN (Fcall_process, build_string ("gzip"), Qnil, list2 (QCfile, filename), Qnil, build_string ("-cd"), tempname); diff --git a/src/lisp.h b/src/lisp.h index 4de6fc85ec..a65cc9684a 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4013,7 +4013,6 @@ extern bool file_directory_p (const char *); extern bool file_accessible_directory_p (Lisp_Object); extern void init_fileio (void); extern void syms_of_fileio (void); -extern Lisp_Object make_temp_name (Lisp_Object, bool); =20 /* Defined in search.c. */ extern void shrink_regexp_cache (void); --=20 2.13.4 --------------CBA433A108EAB7759352E77E Content-Type: text/x-patch; name="0002-Remove-ms-w32-mkostemp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Remove-ms-w32-mkostemp.patch" >From 130f81bd123de154be5247d3237610d1eeab5dca Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 9 Aug 2017 16:34:40 -0700 Subject: [PATCH 2/2] Remove ms-w32 mkostemp * lib-src/ntlib.c, nt/inc/ms-w32.h, src/w32.c (mkostemp): * nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_mkostemp): * nt/mingw-cfg.site (ac_cv_func_mkostemp): Remove, since the generic mkostemp should work on MS-Windows. --- lib-src/ntlib.c | 56 ------------------------------------------------------- nt/gnulib-cfg.mk | 1 - nt/inc/ms-w32.h | 2 -- nt/mingw-cfg.site | 1 - src/w32.c | 55 ------------------------------------------------------ 5 files changed, 115 deletions(-) diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c index 78ba9061f6..078a43e79c 100644 --- a/lib-src/ntlib.c +++ b/lib-src/ntlib.c @@ -37,7 +37,6 @@ along with GNU Emacs. If not, see . */ char *sys_ctime (const time_t *); FILE *sys_fopen (const char *, const char *); int sys_chdir (const char *); -int mkostemp (char *, int); int sys_rename (const char *, const char *); /* MinGW64 defines _TIMEZONE_DEFINED and defines 'struct timespec' in @@ -396,61 +395,6 @@ lstat (const char * path, struct stat * buf) return stat (path, buf); } -/* Implementation of mkostemp for MS-Windows, to avoid race conditions - when using mktemp. Copied from w32.c. - - This is used only in update-game-score.c. It is overkill for that - use case, since update-game-score renames the temporary file into - the game score file, which isn't atomic on MS-Windows anyway, when - the game score already existed before running the program, which it - almost always does. But using a simpler implementation just to - make a point is uneconomical... */ - -int -mkostemp (char * template, int flags) -{ - char * p; - int i, fd = -1; - unsigned uid = GetCurrentThreadId (); - int save_errno = errno; - static char first_char[] = "abcdefghijklmnopqrstuvwyz0123456789!%-_@#"; - - errno = EINVAL; - if (template == NULL) - return -1; - - p = template + strlen (template); - i = 5; - /* replace up to the last 5 X's with uid in decimal */ - while (--p >= template && p[0] == 'X' && --i >= 0) - { - p[0] = '0' + uid % 10; - uid /= 10; - } - - if (i < 0 && p[0] == 'X') - { - i = 0; - do - { - p[0] = first_char[i]; - if ((fd = open (template, - flags | _O_CREAT | _O_EXCL | _O_RDWR, - S_IRUSR | S_IWUSR)) >= 0 - || errno != EEXIST) - { - if (fd >= 0) - errno = save_errno; - return fd; - } - } - while (++i < sizeof (first_char)); - } - - /* Template is badly formed or else we can't generate a unique name. */ - return -1; -} - /* On Windows, you cannot rename into an existing file. */ int sys_rename (const char *from, const char *to) diff --git a/nt/gnulib-cfg.mk b/nt/gnulib-cfg.mk index 175329fb9e..ad798bbe37 100644 --- a/nt/gnulib-cfg.mk +++ b/nt/gnulib-cfg.mk @@ -50,7 +50,6 @@ OMIT_GNULIB_MODULE_dirfd = OMIT_GNULIB_MODULE_fcntl = true OMIT_GNULIB_MODULE_fcntl-h = true OMIT_GNULIB_MODULE_inttypes-incomplete = true -OMIT_GNULIB_MODULE_mkostemp = true OMIT_GNULIB_MODULE_pipe2 = true OMIT_GNULIB_MODULE_secure_getenv = true OMIT_GNULIB_MODULE_signal-h = true diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h index 957d8c6bdb..6cbbb9f869 100644 --- a/nt/inc/ms-w32.h +++ b/nt/inc/ms-w32.h @@ -518,8 +518,6 @@ extern int getpagesize (void); extern void * memrchr (void const *, int, size_t); -extern int mkostemp (char *, int); - #if defined (__MINGW32__) diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site index a106717979..d9a824008c 100644 --- a/nt/mingw-cfg.site +++ b/nt/mingw-cfg.site @@ -79,7 +79,6 @@ ac_cv_func_getaddrinfo=yes # Implemented as an inline function in ws2tcpip.h ac_cv_func_gai_strerror=yes # Implemented in w32.c -ac_cv_func_mkostemp=yes ac_cv_func_readlink=yes ac_cv_func_symlink=yes # Avoid run-time tests of readlink and symlink, which will fail diff --git a/src/w32.c b/src/w32.c index fa3cbe183f..1c58f92d57 100644 --- a/src/w32.c +++ b/src/w32.c @@ -4397,61 +4397,6 @@ sys_open (const char * path, int oflag, int mode) return res; } -/* Implementation of mkostemp for MS-Windows, to avoid race conditions - when using mktemp. - - Standard algorithm for generating a temporary file name seems to be - use pid or tid with a letter on the front (in place of the 6 X's) - and cycle through the letters to find a unique name. We extend - that to allow any reasonable character as the first of the 6 X's, - so that the number of simultaneously used temporary files will be - greater. */ - -int -mkostemp (char * template, int flags) -{ - char * p; - int i, fd = -1; - unsigned uid = GetCurrentThreadId (); - int save_errno = errno; - static char first_char[] = "abcdefghijklmnopqrstuvwyz0123456789!%-_@#"; - - errno = EINVAL; - if (template == NULL) - return -1; - - p = template + strlen (template); - i = 5; - /* replace up to the last 5 X's with uid in decimal */ - while (--p >= template && p[0] == 'X' && --i >= 0) - { - p[0] = '0' + uid % 10; - uid /= 10; - } - - if (i < 0 && p[0] == 'X') - { - i = 0; - do - { - p[0] = first_char[i]; - if ((fd = sys_open (template, - flags | _O_CREAT | _O_EXCL | _O_RDWR, - S_IRUSR | S_IWUSR)) >= 0 - || errno != EEXIST) - { - if (fd >= 0) - errno = save_errno; - return fd; - } - } - while (++i < sizeof (first_char)); - } - - /* Template is badly formed or else we can't generate a unique name. */ - return -1; -} - int fchmod (int fd, mode_t mode) { -- 2.13.4 --------------CBA433A108EAB7759352E77E-- From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 10 11:35:36 2017 Received: (at 28023) by debbugs.gnu.org; 10 Aug 2017 15:35:36 +0000 Received: from localhost ([127.0.0.1]:54644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfpUl-0004ak-QY for submit@debbugs.gnu.org; Thu, 10 Aug 2017 11:35:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44341) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfpUj-0004aX-U0 for 28023@debbugs.gnu.org; Thu, 10 Aug 2017 11:35:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfpUb-0003RC-Fb for 28023@debbugs.gnu.org; Thu, 10 Aug 2017 11:35:28 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfpUb-0003R8-CI; Thu, 10 Aug 2017 11:35:25 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3417 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dfpUZ-0001Re-TN; Thu, 10 Aug 2017 11:35:25 -0400 Date: Thu, 10 Aug 2017 18:35:05 +0300 Message-Id: <83d183safq.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <704c73b8-54f1-f7ac-821b-6d715a21a8a2@cs.ucla.edu> (message from Paul Eggert on Wed, 9 Aug 2017 16:36:55 -0700) Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <83poc4sp4z.fsf@gnu.org> <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> <83lgmssglm.fsf@gnu.org> <704c73b8-54f1-f7ac-821b-6d715a21a8a2@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: 28023@debbugs.gnu.org > From: Paul Eggert > 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. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 10 18:24:23 2017 Received: (at 28023) by debbugs.gnu.org; 10 Aug 2017 22:24:23 +0000 Received: from localhost ([127.0.0.1]:54820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfvsM-0005ie-IU for submit@debbugs.gnu.org; Thu, 10 Aug 2017 18:24:23 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:44386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfvsK-0005iO-S6 for 28023@debbugs.gnu.org; Thu, 10 Aug 2017 18:24:21 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 30F7E160736; Thu, 10 Aug 2017 15:24:14 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 8O_nYWHIQW9r; Thu, 10 Aug 2017 15:24:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 8788316074E; Thu, 10 Aug 2017 15:24:13 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id CqJy-J53RWB0; Thu, 10 Aug 2017 15:24:13 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 667D2160736; Thu, 10 Aug 2017 15:24:13 -0700 (PDT) Subject: Re: bug#28023: fix make-temp-file race on local host To: Eli Zaretskii References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <83poc4sp4z.fsf@gnu.org> <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> <83lgmssglm.fsf@gnu.org> <704c73b8-54f1-f7ac-821b-6d715a21a8a2@cs.ucla.edu> <83d183safq.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Thu, 10 Aug 2017 15:24:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83d183safq.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Eli Zaretskii wrote: > 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. No, your ideas all sound good. It's simpler for the generic code, if the = mkdir=20 replacement acts like POSIX mkdir. From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 11 02:22:04 2017 Received: (at 28023) by debbugs.gnu.org; 11 Aug 2017 06:22:04 +0000 Received: from localhost ([127.0.0.1]:55040 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg3Ke-00034c-5h for submit@debbugs.gnu.org; Fri, 11 Aug 2017 02:22:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49960) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg3Kb-000344-VG for 28023@debbugs.gnu.org; Fri, 11 Aug 2017 02:22:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dg3KT-0007Jl-NL for 28023@debbugs.gnu.org; Fri, 11 Aug 2017 02:21:56 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dg3KT-0007Jf-Jo; Fri, 11 Aug 2017 02:21:53 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4119 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dg3KS-0006m9-Un; Fri, 11 Aug 2017 02:21:53 -0400 Date: Fri, 11 Aug 2017 09:21:42 +0300 Message-Id: <838tiqsjyh.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: (message from Paul Eggert on Thu, 10 Aug 2017 15:24:13 -0700) Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <83poc4sp4z.fsf@gnu.org> <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> <83lgmssglm.fsf@gnu.org> <704c73b8-54f1-f7ac-821b-6d715a21a8a2@cs.ucla.edu> <83d183safq.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: 28023@debbugs.gnu.org > From: Paul Eggert > Date: Thu, 10 Aug 2017 15:24:13 -0700 > > No, your ideas all sound good. It's simpler for the generic code, if the mkdir > replacement acts like POSIX mkdir. So how to proceed? Do you want to wait until I make all those changes on master? Or push a branch with the changes? Something else? From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 11 03:44:48 2017 Received: (at 28023) by debbugs.gnu.org; 11 Aug 2017 07:44:48 +0000 Received: from localhost ([127.0.0.1]:55083 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg4ch-00059E-Sk for submit@debbugs.gnu.org; Fri, 11 Aug 2017 03:44:48 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg4cf-00058x-4n for 28023@debbugs.gnu.org; Fri, 11 Aug 2017 03:44:45 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B4B6816081F; Fri, 11 Aug 2017 00:44:37 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id jZahpx4FVlfD; Fri, 11 Aug 2017 00:44:37 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 126FF160821; Fri, 11 Aug 2017 00:44:37 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fiSJXhRSJOjT; Fri, 11 Aug 2017 00:44:36 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E768616081F; Fri, 11 Aug 2017 00:44:36 -0700 (PDT) Subject: Re: bug#28023: fix make-temp-file race on local host To: Eli Zaretskii References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <83poc4sp4z.fsf@gnu.org> <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> <83lgmssglm.fsf@gnu.org> <704c73b8-54f1-f7ac-821b-6d715a21a8a2@cs.ucla.edu> <83d183safq.fsf@gnu.org> <838tiqsjyh.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <909c277f-ff64-7827-6f8d-27b81f0064c7@cs.ucla.edu> Date: Fri, 11 Aug 2017 00:44:36 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <838tiqsjyh.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Eli Zaretskii wrote: > So how to proceed? Do you want to wait until I make all those changes > on master? Or push a branch with the changes? Something else? I'd rather not mess with a branch. If it's easy to make those changes to master please do so. If not, I can modify the patch to keep the current algorithm for DOS_NT, though this will be ugly. From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 11 04:03:28 2017 Received: (at 28023) by debbugs.gnu.org; 11 Aug 2017 08:03:29 +0000 Received: from localhost ([127.0.0.1]:55097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg4um-0005aH-M3 for submit@debbugs.gnu.org; Fri, 11 Aug 2017 04:03:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg4uk-0005a4-TO for 28023@debbugs.gnu.org; Fri, 11 Aug 2017 04:03:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dg4ub-0002uA-Ar for 28023@debbugs.gnu.org; Fri, 11 Aug 2017 04:03:21 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:53334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dg4ub-0002u6-7m; Fri, 11 Aug 2017 04:03:17 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4175 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dg4uZ-0002AW-FJ; Fri, 11 Aug 2017 04:03:16 -0400 Date: Fri, 11 Aug 2017 11:03:04 +0300 Message-Id: <83zib6r0p3.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <909c277f-ff64-7827-6f8d-27b81f0064c7@cs.ucla.edu> (message from Paul Eggert on Fri, 11 Aug 2017 00:44:36 -0700) Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <83poc4sp4z.fsf@gnu.org> <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> <83lgmssglm.fsf@gnu.org> <704c73b8-54f1-f7ac-821b-6d715a21a8a2@cs.ucla.edu> <83d183safq.fsf@gnu.org> <838tiqsjyh.fsf@gnu.org> <909c277f-ff64-7827-6f8d-27b81f0064c7@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: 28023@debbugs.gnu.org > From: Paul Eggert > Date: Fri, 11 Aug 2017 00:44:36 -0700 > > If it's easy to make those changes to master please do so. OK, will do. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 12 04:32:14 2017 Received: (at 28023) by debbugs.gnu.org; 12 Aug 2017 08:32:14 +0000 Received: from localhost ([127.0.0.1]:56276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgRqA-0002Td-41 for submit@debbugs.gnu.org; Sat, 12 Aug 2017 04:32:14 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59102) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgRq8-0002TX-MC for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 04:32:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgRpy-0006Kn-R7 for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 04:32:07 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:38541) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgRpy-0006KY-Ol; Sat, 12 Aug 2017 04:32:02 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1530 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dgRpy-0003Bv-BC; Sat, 12 Aug 2017 04:32:02 -0400 Date: Sat, 12 Aug 2017 11:31:52 +0300 Message-Id: <83a835jifb.fsf@gnu.org> From: Eli Zaretskii To: eggert@cs.ucla.edu In-reply-to: <83zib6r0p3.fsf@gnu.org> (message from Eli Zaretskii on Fri, 11 Aug 2017 11:03:04 +0300) Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <83poc4sp4z.fsf@gnu.org> <2ca18723-8d62-11f7-86d8-3e0fc044ac57@cs.ucla.edu> <83lgmssglm.fsf@gnu.org> <704c73b8-54f1-f7ac-821b-6d715a21a8a2@cs.ucla.edu> <83d183safq.fsf@gnu.org> <838tiqsjyh.fsf@gnu.org> <909c277f-ff64-7827-6f8d-27b81f0064c7@cs.ucla.edu> <83zib6r0p3.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Fri, 11 Aug 2017 11:03:04 +0300 > From: Eli Zaretskii > Cc: 28023@debbugs.gnu.org > > > Cc: 28023@debbugs.gnu.org > > From: Paul Eggert > > Date: Fri, 11 Aug 2017 00:44:36 -0700 > > > > If it's easy to make those changes to master please do so. > > OK, will do. Done. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 12 06:35:48 2017 Received: (at 28023) by debbugs.gnu.org; 12 Aug 2017 10:35:48 +0000 Received: from localhost ([127.0.0.1]:56293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgTlk-0003Re-Bn for submit@debbugs.gnu.org; Sat, 12 Aug 2017 06:35:48 -0400 Received: from mout.gmx.net ([212.227.15.15]:64313) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgTlh-0003RW-WA for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 06:35:46 -0400 Received: from detlef.gmx.de ([213.220.146.233]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M0y47-1dL5xu0t3v-00v3k8; Sat, 12 Aug 2017 12:35:29 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> Date: Sat, 12 Aug 2017 12:35:26 +0200 In-Reply-To: (Paul Eggert's message of "Wed, 9 Aug 2017 02:22:37 -0700") Message-ID: <877ey9dqfl.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:4Hcm1GTqYnJMnwx1gaYcME9VHHa2mL529ni4dtzSFEbGhD/PbiO qLPjZaajpbvwevRHhcQzS8dHZ9zFWmxEmk3UBxbPWS34AS8qcRYr+s+J4cjdOMhJnNFIf3T wG7adzvuGWR+58VDdprYpFFldpys0eWwzkpzprZlcUVwN+O5UKkPo2G5DFOV5rrJmpn1wx7 qpdz42ncptnXG9usx+IwQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:Wvtf5SCrZv4=:lFRR4u482rxKvesi6O4VnK T8LGI0ml3zUPW1KPukeEl35klMOxUQMoGNzT9IIDrdW+VD7Lr8pzX0liDMOkNcDIh0qtrFG1s 4Mr8ssF1y5k0Z5XK3OBlV0iy90oNNbUnY05A2FhdGdn5R9YhUHBOx00Ke5zScMa8W/eSey4r3 v0+NoOAy3BZVx8ocTn28mxNF9cZaIx26k6jlU2UZ0vk5TjEFO+1s/+r/yWRu890No94Ly4/ce G6HW2EzHHY+idjqrA70viYAme7+jkSrJTYpstTxPHJebpDc4RlsjEZiQClDaa6hLDF2B9y3FM wme/lljQD81awTW4vpJRO3nxx1H9n5VGKOJizI32yYRlgO21ZrjrdDEnl+E7Oowsww8Eiwvsz XsrmcoXl5ST3kEqTmi47yA4ijxEREIckfveYxwSzbU+ZhPgY2xHHBTS2Qh4lU6eQ2FN55TWUr BEid5beoNqpfI6ayN9qllVxRA8xRjczm919cS47amtT7GiDKrcR0VGT5eBPaoOXB4FImiIort Tts/SkSMqLSfR2NuvzoDaYUUF1oWu7SggPkx+1AbHWTWCOU5iAwG6QFpJtnvtZfzxYpKO6KzD Sl/bMQHN+quXgwLbNZDGMld1+huog171xOGYVFz3JMi+PzC94P07CSQZ0YHiTW7ElVe3eVEgK /NWu7ZgmCPXOb4hQquyQtny1FBxzPVd7mYcnJmNcKL8yl5yuO43P1lEg067bj1JMTL+/kqxma KyeeGJwZPkbluWb1c2tg4lRNou4/5K7dUQCx6GfJYgSujTOgJiAPIsBKRYk/MB4pRtvLPtsQf Wtx9A37B09Lg0A2cFNjtRmKok7C7+oqqYZtx8q872Svo3P72pw= X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.5 (---) Paul Eggert writes: Hi Paul, > Tramp also needs to support the excl flag of write-region (currently > it ignores that flag). I've implemented this, commit ec5cfaa456. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 12 11:55:41 2017 Received: (at 28023) by debbugs.gnu.org; 12 Aug 2017 15:55:41 +0000 Received: from localhost ([127.0.0.1]:56906 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgYlJ-0002vT-5X for submit@debbugs.gnu.org; Sat, 12 Aug 2017 11:55:41 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:51622) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgYlG-0002vI-PO for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 11:55:39 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9901B16084A; Sat, 12 Aug 2017 08:55:32 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id rT3dGQm28E45; Sat, 12 Aug 2017 08:55:31 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C234E16084C; Sat, 12 Aug 2017 08:55:31 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id E59mEt9DpFlI; Sat, 12 Aug 2017 08:55:31 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 8A9CB16080C; Sat, 12 Aug 2017 08:55:31 -0700 (PDT) Subject: Re: bug#28023: fix make-temp-file race on local host To: Michael Albinus References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> <877ey9dqfl.fsf@detlef> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sat, 12 Aug 2017 08:55:31 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <877ey9dqfl.fsf@detlef> Content-Type: multipart/mixed; boundary="------------92ADF72C7F2DDD70D62B4805" Content-Language: en-US X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) This is a multi-part message in MIME format. --------------92ADF72C7F2DDD70D62B4805 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Michael Albinus wrote: > I've implemented this, commit ec5cfaa456. Thanks. Unfortunately this caused "make check" to fail on Fedora 26. I in= stalled=20 the attached patch, which causes the test to pass. Can you please look ov= er it=20 to see whether it makes sense, and look for similar problems elsewhere? (= I'm not=20 that familiar with Tramp.) Thanks. --------------92ADF72C7F2DDD70D62B4805 Content-Type: text/x-patch; name="0001-Adjust-jka-compr-to-recent-Tramp-changes.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Adjust-jka-compr-to-recent-Tramp-changes.patch" =46rom bbf52c142afbb9e10bf2ae20b3c77993fda26b43 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 12 Aug 2017 08:52:25 -0700 Subject: [PATCH] Adjust jka-compr to recent Tramp changes. * lisp/jka-compr.el (jka-compr-write-region): Two new args LOCKNAME and MUSTBENEW. --- lisp/jka-compr.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el index 26a7cf5..9e780f8 100644 --- a/lisp/jka-compr.el +++ b/lisp/jka-compr.el @@ -252,7 +252,8 @@ jka-compr-make-temp-name "This routine will return the name of a new file." (make-temp-file jka-compr-temp-name-template)) =20 -(defun jka-compr-write-region (start end file &optional append visit) +(defun jka-compr-write-region (start end file &optional + append visit lockname mustbenew) (let* ((filename (expand-file-name file)) (visit-file (if (stringp visit) (expand-file-name visit) filename)) (info (jka-compr-get-compression-info visit-file)) @@ -334,7 +335,8 @@ jka-compr-write-region (jka-compr-run-real-handler 'write-region (list (point-min) (point-max) filename - (and append can-append) 'dont)) + (and append can-append) 'dont + lockname mustbenew)) (erase-buffer)) ) =20 (delete-file temp-file) @@ -365,7 +367,8 @@ jka-compr-write-region nil) =20 (jka-compr-run-real-handler 'write-region - (list start end filename append visit))))) + (list start end filename append visit + lockname mustbenew))))) =20 =20 (defun jka-compr-insert-file-contents (file &optional visit beg end repl= ace) --=20 2.7.4 --------------92ADF72C7F2DDD70D62B4805-- From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 12 12:10:02 2017 Received: (at 28023) by debbugs.gnu.org; 12 Aug 2017 16:10:02 +0000 Received: from localhost ([127.0.0.1]:56961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgYzC-00032t-GL for submit@debbugs.gnu.org; Sat, 12 Aug 2017 12:10:02 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60027) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgYzB-00032S-1w for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 12:10:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgYz1-0007Xv-7g for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 12:09:55 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50100) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgYz1-0007Xb-5D; Sat, 12 Aug 2017 12:09:51 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2345 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dgYz0-0004Wn-K4; Sat, 12 Aug 2017 12:09:51 -0400 Date: Sat, 12 Aug 2017 19:09:41 +0300 Message-Id: <83poc0ix8a.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: (message from Paul Eggert on Sat, 12 Aug 2017 08:55:31 -0700) Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> <877ey9dqfl.fsf@detlef> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org, michael.albinus@gmx.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Paul, Looking back at your original patch, I think the function you are adding should be named make-temp-file-internal, as we do with other functions whose low-level parts are implemented in C. fileio--SOMETHING sounds like something we never had, so I think it's better to a void a new prefix. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 12 12:25:53 2017 Received: (at 28023) by debbugs.gnu.org; 12 Aug 2017 16:25:53 +0000 Received: from localhost ([127.0.0.1]:57041 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgZEW-0003CF-UK for submit@debbugs.gnu.org; Sat, 12 Aug 2017 12:25:53 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:53760) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgZEU-0003C8-NM for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 12:25:50 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 499FF1607CE; Sat, 12 Aug 2017 09:25:44 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 7c0b8hrB1YtE; Sat, 12 Aug 2017 09:25:40 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 85E6416080B; Sat, 12 Aug 2017 09:25:38 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id z7lBtNVkwju8; Sat, 12 Aug 2017 09:25:38 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 47D691607CE; Sat, 12 Aug 2017 09:25:38 -0700 (PDT) Subject: Re: bug#28023: fix make-temp-file race on local host To: Eli Zaretskii References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> <877ey9dqfl.fsf@detlef> <83poc0ix8a.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <269e192f-15d8-4625-bbf0-ca11fb66edcc@cs.ucla.edu> Date: Sat, 12 Aug 2017 09:25:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83poc0ix8a.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org, michael.albinus@gmx.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Eli Zaretskii wrote: > I think the function you are > adding should be named make-temp-file-internal, as we do with other > functions whose low-level parts are implemented in C. I was following the lead of names like lread--substitute-command-keys,=20 print--preprocess, and thread--blocker, all low-level C functions whose f= irst=20 part identifies which C module they're in. Although I see that the "-inte= rnal"=20 suffix is more popular for this sort of thing, isn't that a revenant of t= he old=20 days, before we instituted the convention of using PREFIX--NAME for priva= te=20 names? Or is the "-internal" suffix a separate naming convention, used by= both=20 Lisp and C code, that has a different semantics from PREFIX--NAME? If so,= it=20 would be nice to have advice somewhere as to when to use the -internal su= ffix vs=20 when to use PREFIX--NAME. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 12 12:53:05 2017 Received: (at 28023) by debbugs.gnu.org; 12 Aug 2017 16:53:05 +0000 Received: from localhost ([127.0.0.1]:57158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgZer-0003QU-Kn for submit@debbugs.gnu.org; Sat, 12 Aug 2017 12:53:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48596) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgZep-0003Q5-Sq for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 12:53:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgZeh-0002gC-Db for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 12:52:58 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51537) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgZeh-0002g8-AP; Sat, 12 Aug 2017 12:52:55 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2438 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dgZeg-0006qp-P9; Sat, 12 Aug 2017 12:52:55 -0400 Date: Sat, 12 Aug 2017 19:52:46 +0300 Message-Id: <83mv74iv8h.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <269e192f-15d8-4625-bbf0-ca11fb66edcc@cs.ucla.edu> (message from Paul Eggert on Sat, 12 Aug 2017 09:25:37 -0700) Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> <877ey9dqfl.fsf@detlef> <83poc0ix8a.fsf@gnu.org> <269e192f-15d8-4625-bbf0-ca11fb66edcc@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org, michael.albinus@gmx.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: michael.albinus@gmx.de, 28023@debbugs.gnu.org > From: Paul Eggert > Date: Sat, 12 Aug 2017 09:25:37 -0700 > > I was following the lead of names like lread--substitute-command-keys, > print--preprocess, and thread--blocker, all low-level C functions whose first > part identifies which C module they're in. Although I see that the "-internal" > suffix is more popular for this sort of thing, isn't that a revenant of the old > days, before we instituted the convention of using PREFIX--NAME for private > names? Or is the "-internal" suffix a separate naming convention, used by both > Lisp and C code, that has a different semantics from PREFIX--NAME? If so, it > would be nice to have advice somewhere as to when to use the -internal suffix vs > when to use PREFIX--NAME. I think the prefix that comes from the file where the function is defined is more of a Lisp convention, and the -internal convention is more for C implementations. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 12 13:51:34 2017 Received: (at 28023) by debbugs.gnu.org; 12 Aug 2017 17:51:34 +0000 Received: from localhost ([127.0.0.1]:57433 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgaZS-0004MW-46 for submit@debbugs.gnu.org; Sat, 12 Aug 2017 13:51:34 -0400 Received: from mout.gmx.net ([212.227.17.20]:52455) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgaZP-0004MQ-NG for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 13:51:32 -0400 Received: from detlef.gmx.de ([213.220.146.233]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0Mchyv-1dxqT51QrB-00HsQ6; Sat, 12 Aug 2017 19:51:14 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> <877ey9dqfl.fsf@detlef> Date: Sat, 12 Aug 2017 19:51:12 +0200 In-Reply-To: (Paul Eggert's message of "Sat, 12 Aug 2017 08:55:31 -0700") Message-ID: <87y3qou12n.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:Lihax4pZNmkc+phGWHEJL5a+gRNmwF0iGnAbTDwIZ1h5xtNPtWd vWFKcOBmLgjHm6a+rsWdZ9b8oHXfeGbI8vFozU0NB6qB9Ljh86hxzJ9zLSn42ECvQNtK2Qe GMTbGDskYa0VBH5BIkhLhPYbrSr+0Ucu4ogIHPTGwndPNZrysOHtOjztFTvg6JgcYZSLhC1 oyfyBzoXqZH4+SMpAGgCg== X-UI-Out-Filterresults: notjunk:1;V01:K0:AliFNVi9YGQ=:KQF2QZ0LKaEYkzwRIQ9nF3 etzWi6gSbEuSw7KbtQ4rC+Soa0rQD848N7YCi+9rYhw2+oOm9pk6HF3aUBJxQh5Osn8/gJ6D4 lW8OVhk9DwtMMlYSoK7BWYdh9ShrPrrjXlZWzK7hyWW83Y+0mUpJe9Y5V46NLbALfNEjJmTkV vrWQTlbYhAbLxnUiQm/11N4rHzFamjzH/UeGIYZKgdg4AphBaXAioJ797Fv66wJZleSTf/4iu PYfdTCXacAm+1bjhvrWi3+MsxEi+qMPXWpvaUXQTAcKfwrgwbTaKQ1lsD6UOLYHKI9e4xUC4O mAurGb4J8zFw1jYsZRx7YEmTyngBNLVEU5t4nidNY9KnaiJvByNdpTGb5r/plhunOWh892OyF BDAgxNhtyAVTFU1aAvf6IUhpNtegVRxOd4mY6XWHIOHxSGGJh3IarLKIVZ1BVCQ6zGwt1UVpd S1wZuTxATboLAInhQgdqAddYQia8ejW3Y0dQnOdGkOKNu36go/jm7V7MoTVvVxtVZFFPwa3o3 3aq35qPQ5N65Fvfs1bDseBaNTSBo0jmOKcRDwD2S4yNEfMfzbYxl5EHNvUiBSpapt6TyEmP/d AlGmflFOYNDovLpKZ2RMB0lrkyYVvMej1j6E2afWagNTZS7qRXLn94mzpyfH7XA75i0lIK8I+ IcsIKFR2AfBSu6cuW0cYrfo0n91to88g+K7ZpOGmLAPoHE3IrJRZcT2fwU5QlkpBycmLKmVrZ qvgWBfZzgw5HohWQMUVODiMkdwAMfRIMulog9GEbSVEy2eIkVW6JoFxMwia3569qt2izn90db VNUUsaKpzjuJR4reDldF6n02uu3XOLhWgbV2j2SYYQVbfWDW5U= X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.0 (---) Paul Eggert writes: Hi Paul, > Thanks. Unfortunately this caused "make check" to fail on Fedora 26. I > installed the attached patch, which causes the test to pass. Can you > please look over it to see whether it makes sense, and look for > similar problems elsewhere? (I'm not that familiar with Tramp.) The patch is OK. Sorry for the trouble, I've searched for "-write-region" in the whole lisp directory for such cases, but I must have missed jka-compr.el. > Thanks. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 12 13:57:36 2017 Received: (at 28023) by debbugs.gnu.org; 12 Aug 2017 17:57:36 +0000 Received: from localhost ([127.0.0.1]:57468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgafI-0004Pr-8K for submit@debbugs.gnu.org; Sat, 12 Aug 2017 13:57:36 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59794) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgafG-0004Pj-8v for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 13:57:35 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 12491160850; Sat, 12 Aug 2017 10:57:28 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id hStoQth2ezsY; Sat, 12 Aug 2017 10:57:27 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1F134160857; Sat, 12 Aug 2017 10:57:27 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UON1xBfJN8ep; Sat, 12 Aug 2017 10:57:26 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C70E816080F; Sat, 12 Aug 2017 10:57:26 -0700 (PDT) Subject: Re: bug#28023: fix make-temp-file race on local host To: Eli Zaretskii References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> <877ey9dqfl.fsf@detlef> <83poc0ix8a.fsf@gnu.org> <269e192f-15d8-4625-bbf0-ca11fb66edcc@cs.ucla.edu> <83mv74iv8h.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sat, 12 Aug 2017 10:57:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83mv74iv8h.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------EA2919F2A98A69D54B68CFE3" Content-Language: en-US X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org, michael.albinus@gmx.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) This is a multi-part message in MIME format. --------------EA2919F2A98A69D54B68CFE3 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Eli Zaretskii wrote: > I think the prefix that comes from the file where the function is > defined is more of a Lisp convention, and the -internal convention is > more for C implementations. I see lots of exceptions to these conventions, presumably either because=20 developers don't know the intent or because the code was written before t= he=20 conventions were established. Still, it's better to document the intent s= o I=20 installed the attached patch to do that. I'll adjust the make-temp-file p= atch=20 accordingly. --------------EA2919F2A98A69D54B68CFE3 Content-Type: text/x-patch; name="0001-Document-internal-use-naming-conventions.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Document-internal-use-naming-conventions.patch" =46rom 57c2de6fce73b77081e59d0527b12f158bac758a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 12 Aug 2017 10:54:32 -0700 Subject: [PATCH] Document internal-use naming conventions * doc/lispref/functions.texi (Function Names): * doc/lispref/variables.texi (Tips for Defining): Document naming conventions for internal-use functions and vars. See Bug#28023#59. --- doc/lispref/functions.texi | 9 +++++++++ doc/lispref/variables.texi | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 283f74f..06de2e2 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -544,6 +544,15 @@ Function Names conflict. (This is not the case in some dialects of Lisp, like Scheme.) =20 + By convention, if a function's symbol consists of two names +separated by @samp{--}, the function is intended for internal use and +the first part names the file defining the function. For example, a +function named @code{vc-git--rev-parse} is an internal function +defined in @file{vc-git.el}. Internal-use functions written in C have +names ending in @samp{-internal}, e.g., @code{bury-buffer-internal}. +Emacs code contributed before 2018 may follow other internal-use +naming conventions, which are being phased out. + @node Defining Functions @section Defining Functions @cindex defining a function diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index 2818ea0..7650ed4 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -574,6 +574,16 @@ Tips for Defining =20 @item @dots{}-switches The value specifies options for a command. + +@item @var{prefix}--@dots{} +The variable is intended for internal use and is defined in the file +@file{@var{prefix}.el}. (Emacs code contributed before 2018 may +follow other conventions, which are being phased out.) + +@item @dots{}-internal +The variable is intended for internal use and is defined in C code. +(Emacs code contributed before 2018 may follow other conventions, +which are being phased out.) @end table =20 When you define a variable, always consider whether you should mark --=20 2.7.4 --------------EA2919F2A98A69D54B68CFE3-- From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 12 14:08:03 2017 Received: (at 28023) by debbugs.gnu.org; 12 Aug 2017 18:08:03 +0000 Received: from localhost ([127.0.0.1]:57519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgapO-0004Vi-SN for submit@debbugs.gnu.org; Sat, 12 Aug 2017 14:08:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40993) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgapN-0004VL-7m for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 14:08:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgapD-000897-Ro for 28023@debbugs.gnu.org; Sat, 12 Aug 2017 14:07:55 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:53499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgapD-000891-O3; Sat, 12 Aug 2017 14:07:51 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2639 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dgap3-00008u-Pe; Sat, 12 Aug 2017 14:07:51 -0400 Date: Sat, 12 Aug 2017 21:07:20 +0300 Message-Id: <83fucwirs7.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: (message from Paul Eggert on Sat, 12 Aug 2017 10:57:26 -0700) Subject: Re: bug#28023: fix make-temp-file race on local host References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> <877ey9dqfl.fsf@detlef> <83poc0ix8a.fsf@gnu.org> <269e192f-15d8-4625-bbf0-ca11fb66edcc@cs.ucla.edu> <83mv74iv8h.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28023 Cc: 28023@debbugs.gnu.org, michael.albinus@gmx.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: michael.albinus@gmx.de, 28023@debbugs.gnu.org > From: Paul Eggert > Date: Sat, 12 Aug 2017 10:57:26 -0700 > > I see lots of exceptions to these conventions, presumably either because > developers don't know the intent or because the code was written before the > conventions were established. Still, it's better to document the intent so I > installed the attached patch to do that. Thanks, I agree this should be documented. > I'll adjust the make-temp-file patch accordingly. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 13 03:21:11 2017 Received: (at 28023-done) by debbugs.gnu.org; 13 Aug 2017 07:21:12 +0000 Received: from localhost ([127.0.0.1]:59120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgnCx-0005L9-MA for submit@debbugs.gnu.org; Sun, 13 Aug 2017 03:21:11 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:44974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgnCw-0005L3-5m for 28023-done@debbugs.gnu.org; Sun, 13 Aug 2017 03:21:10 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3CDAD160759; Sun, 13 Aug 2017 00:21:04 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id wifVLBJk16N8; Sun, 13 Aug 2017 00:21:03 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 679D8160861; Sun, 13 Aug 2017 00:21:03 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4-t6FI65Ftja; Sun, 13 Aug 2017 00:21:03 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 39551160759; Sun, 13 Aug 2017 00:21:03 -0700 (PDT) Subject: Re: bug#28023: fix make-temp-file race on local host To: Michael Albinus References: <8c2c16ff-94ec-a691-57b1-bab8f5b39dfb@cs.ucla.edu> <87shh18c9e.fsf@detlef> <87k22d7zrb.fsf@detlef> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <2ad20ed4-97aa-0823-81af-5757bf0f3033@cs.ucla.edu> Date: Sun, 13 Aug 2017 00:21:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <87k22d7zrb.fsf@detlef> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28023-done Cc: 28023-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Michael Albinus wrote: > Paul Eggert writes: >=20 >> Tramp needs to support a new method make-temp-file that creates a file >> (or directory) atomically, as make-temp-file does locally now. > That means, make-temp-file shall be converted into a magic file name > operation. I'll do my best, but I don't know whether we could get an > implementation for all Tramp methods w/o a race condition. >=20 >> Tramp also needs to support the excl flag of write-region (currently >> it ignores that flag). > This sounds trivial. And yes, it will help. Thanks for doing that. Because of that, I'm no longer seeing a race in=20 make-temp-file, even for Tramp files. That is, although my proposed patch= is=20 still a performance win on local files, I don't see how it is a correctne= ss win=20 any more. It's still worth installing for the performance reasons, though= , so I=20 did that and I am marking this bug as done. >> I was planning to write this up as a bug report after the patch goes >> in. > Pls do. To some extent this is moot now, if I understand things correctly. That i= s, the=20 only reason to write this up now would be for performance reasons, not a = race=20 condition. There is still a race involving destination directories, for both Tramp a= nd=20 non-Tramp versions. I plan to take a look at that next. From unknown Sun Jun 15 08:38:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 10 Sep 2017 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator