From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#15015: Fix some minor races in hosts lacking mkostemp Date: Sat, 03 Aug 2013 11:38:03 +0300 Message-ID: <83mwozxj84.fsf@gnu.org> References: <51FCB3D5.7070704@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1375519155 3868 80.91.229.3 (3 Aug 2013 08:39:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 Aug 2013 08:39:15 +0000 (UTC) Cc: 15015@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 03 10:39:16 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V5XMq-0004zN-Ae for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Aug 2013 10:39:16 +0200 Original-Received: from localhost ([::1]:38776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5XMp-0007cv-Ps for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Aug 2013 04:39:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5XMi-0007cB-9t for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2013 04:39:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V5XMc-0008B2-3o for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2013 04:39:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43329) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5XMc-0008Ay-0p for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2013 04:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1V5XMb-0001vJ-R8 for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2013 04:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Aug 2013 08:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15015 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13755191207353 (code B ref -1); Sat, 03 Aug 2013 08:39:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Aug 2013 08:38:40 +0000 Original-Received: from localhost ([127.0.0.1]:37645 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V5XMG-0001uV-88 for submit@debbugs.gnu.org; Sat, 03 Aug 2013 04:38:40 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46558) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V5XMD-0001u4-DR for submit@debbugs.gnu.org; Sat, 03 Aug 2013 04:38:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V5XM3-0007zT-0U for submit@debbugs.gnu.org; Sat, 03 Aug 2013 04:38:32 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:38093) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5XM2-0007zO-UV for submit@debbugs.gnu.org; Sat, 03 Aug 2013 04:38:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5XLx-0007XG-TN for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2013 04:38:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V5XLs-0007vw-KJ for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2013 04:38:21 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:63089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5XLs-0007uP-C2 for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2013 04:38:16 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0MQY0020058JY100@a-mtaout20.012.net.il> for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2013 11:38:01 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MQY002BY5BDWA20@a-mtaout20.012.net.il>; Sat, 03 Aug 2013 11:38:01 +0300 (IDT) In-reply-to: <51FCB3D5.7070704@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:76920 Archived-At: > Date: Sat, 03 Aug 2013 00:40:05 -0700 > From: Paul Eggert > CC: Eli Zaretskii > > Here's a proposed patch to fix some minor races in hosts lacking mkostemp. > I've tested this on Fedora 17 and Solaris 9. Eli recently wrote that he > didn't think it was feasible to close the races on Microsoft platforms, > so I'm posting this on bug-gnu-emacs first (with a CC: to Eli to give him > a heads-up). It looks to me like it may close the races on Microsoft platforms, > at least if they support O_EXCL, and at any rate I hope it doesn't hurt > on those platforms. > > Most of this patch consists of code copied automatically from Gnulib. > The meat of the patch is in src/callproc.c and src/filelock.c. Thanks. However, I'm reluctant to use the gnulib mkostemp module, because it relies on quite a few functions that are redefined in Emacs, and I have no idea what will this do to the gnulib implementation. Also, since we still didn't remove the support for MS-Windows builds that use nt/configure.bat and the makefile-w32.in files, the uses of mktemp in the Emacs sources should be left alone for now, if we go this route. I thought of a far easier solution: use the same code as sys_mktemp does, but use 'open' or '_sopen' instead of faccessat. I think this will solve the problem much more locally and with much smaller impact. If you agree, I will work on providing 'mkostemp' for w32. In any case, we cannot just remove the other alternatives; at least for the MSDOS build we need to keep the HAVE_MKSTEMP version.