Author neologix
Recipients alexey-smirnov, amaury.forgeotdarc, christian.heimes, neologix, pitrou, rosslagerwall, sbt, vstinner
Date 2013-01-04.14:17:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAH_1eM3YX_h3EyyS0ZWDt97nUyxR-0F5f38Yvkdf2QXEQHh-UA@mail.gmail.com>
In-reply-to <1357307182.97.0.451140043086.issue16850@psf.upfronthosting.co.za>
Content
> O_CLOEXEC solves for example a race condition in tempfile._mkstemp_inner():
>
>             fd = _os.open(file, flags, 0o600)
>             _set_cloexec(fd)

Hum...
"""
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -57,6 +57,8 @@
 _allocate_lock = _thread.allocate_lock

 _text_openflags = _os.O_RDWR | _os.O_CREAT | _os.O_EXCL
+if hasattr(_os, 'O_CLOEXEC'):
+    _text_openflags |= _os.O_CLOEXEC
 if hasattr(_os, 'O_NOINHERIT'):
     _text_openflags |= _os.O_NOINHERIT
 if hasattr(_os, 'O_NOFOLLOW'):
"""

We should probably add this to 3.3 and default (IIRC O_CLOEXEC was
added to the os module in 3.3).
Also, I think O_NOFOLLOW is useless: if the file is created
(O_EXCL|O_CREAT), then by definition it's not a symlink (juste check
glibc's mkstemp() implementation, and it only passes O_CREAT|O_EXCL).
History
Date User Action Args
2013-01-04 14:17:25neologixsetrecipients: + neologix, amaury.forgeotdarc, pitrou, vstinner, christian.heimes, rosslagerwall, sbt, alexey-smirnov
2013-01-04 14:17:25neologixlinkissue16850 messages
2013-01-04 14:17:25neologixcreate