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: Sun, 04 Aug 2013 18:44:24 +0300 Message-ID: <837gg1xxyf.fsf@gnu.org> References: <51FCB3D5.7070704@cs.ucla.edu> <83mwozxj84.fsf@gnu.org> <83k3k3xi36.fsf@gnu.org> <51FD1663.6040501@cs.ucla.edu> <83d2puygbs.fsf@gnu.org> <51FD757C.401@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1375631118 9161 80.91.229.3 (4 Aug 2013 15:45:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 4 Aug 2013 15:45:18 +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 Sun Aug 04 17:45:18 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 1V60Uf-0007Nm-Op for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Aug 2013 17:45:17 +0200 Original-Received: from localhost ([::1]:55965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V60Uf-0007sk-Dc for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Aug 2013 11:45:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V60UX-0007lC-5V for bug-gnu-emacs@gnu.org; Sun, 04 Aug 2013 11:45:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V60UQ-0005O7-TK for bug-gnu-emacs@gnu.org; Sun, 04 Aug 2013 11:45:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45513) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V60UQ-0005Nq-Qy for bug-gnu-emacs@gnu.org; Sun, 04 Aug 2013 11:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1V60UP-0005Cu-NM for bug-gnu-emacs@gnu.org; Sun, 04 Aug 2013 11:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Aug 2013 15:45: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 Original-Received: via spool by 15015-submit@debbugs.gnu.org id=B15015.137563107119963 (code B ref 15015); Sun, 04 Aug 2013 15:45:01 +0000 Original-Received: (at 15015) by debbugs.gnu.org; 4 Aug 2013 15:44:31 +0000 Original-Received: from localhost ([127.0.0.1]:39829 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V60Tu-0005Bu-IO for submit@debbugs.gnu.org; Sun, 04 Aug 2013 11:44:30 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:45356) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V60Tq-0005Bd-HU for 15015@debbugs.gnu.org; Sun, 04 Aug 2013 11:44:28 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MR000B00JLQCF00@a-mtaout22.012.net.il> for 15015@debbugs.gnu.org; Sun, 04 Aug 2013 18:44:19 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MR000A25JPVC5F0@a-mtaout22.012.net.il>; Sun, 04 Aug 2013 18:44:19 +0300 (IDT) In-reply-to: <51FD757C.401@cs.ucla.edu> X-012-Sender: halo1@inter.net.il 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:76948 Archived-At: > Date: Sat, 03 Aug 2013 14:26:20 -0700 > From: Paul Eggert > CC: 15015@debbugs.gnu.org > > On 08/03/2013 07:55 AM, Eli Zaretskii wrote: > > > gettimeofday, open, and lstat are implemented by Emacs in w32.c. At > > lest the last 2 are not equivalent to what gnulib uses. > > The lack of equivalence shouldn't matter. The lstat call > (though it is compiled) won't be used by Emacs's use of the > mkostemp module on Microsoft platforms, so it's OK. > mkostemp always calls 'open' with O_CREAT | O_EXCL; in that > case sys_open is just a simple wrapper around _open, so that > should be OK too. And gettimeofday, as you mentioned, isn't > a problem. I think sys_open also sets the no-inherit flag, so it's not just a wrapper. In any case, even if you are right (and I don't have enough resources at the moment to verify that), reusing most of the code of sys_mktemp to implement mkostemp seems like a safer bet, since that code is already well tested by years of usage. This also has the nice benefit of not breaking the old configure.bat build. So I went ahead and implemented mkostemp for MS-Windows (trunk revision 113687). I also removed sys_mktemp, as it is no longer needed. > >> Presumably nt/configure.bat and makefile-w32.in could be updated > >> to compile the new files. This sort of thing should be routine, > >> if that avenue is still supported. > > > > This "support" needs volunteers, which didn't yet show up. > > If nobody's supporting it, then it's not really supported. That's true, but I'd like to avoid breaking it for as long as is feasible, to let people adapt. > > We can always install the gnulib stuff for those other platforms > > Yes, that's a given. We need to do that, to fix the race > condition bugs in OS X, Solaris, etc. Please go ahead. > > and work around it on Windows. > > I'm trying to help save work in the Windows port, by having > Windows Emacs use Gnulib mkostemp (which will be in the > source code anyway) the same way it's being used on OS X etc. > If this approach is feasible, it should save us all some > work; if not, it should be easy for a Windows expert to work > around any problems in w32.c and/or msdos.c. This approach is generally feasible, and I appreciate your efforts. It's just that in this case having a Windows-specific implementation was easy. (Don't worry about msdos.c, I will fix that when I have time. There can be no race conditions on MSDOS anyway...) Thanks.