[issue43604] Fix tempfile.mktemp()

2021-03-23 Thread David Lukeš
David Lukeš added the comment: > You can use TemporaryDirectory. That was actually the first approach I tried :) I even thought this could be used to make `mktemp` safe -- just create the name in a `TemporaryDirectory`. However, after reading through the mailing list thread, I realized this

[issue43604] Fix tempfile.mktemp()

2021-03-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: You can use TemporaryDirectory. with tempfile.TemporaryDirectory() as dir: fifo_path = os.path.join(dir, "fifo") os.mkfifo(fifo_path, 0o600) ... -- nosy: +serhiy.storchaka ___ Python tracker

[issue43604] Fix tempfile.mktemp()

2021-03-23 Thread David Lukeš
David Lukeš added the comment: > A secure `mktemp` could be as simple as ... Though in practice, I'd rather be inclined to make the change in `tempfile._RandomNameSequence`, so as to get the same behavior across the entire module, instead of special-casing `mktemp`. As Guido van Rossum

[issue43604] Fix tempfile.mktemp()

2021-03-23 Thread David Lukeš
New submission from David Lukeš : I recently came across a non-testing use case for `tempfile.mktemp()` where I struggle to find a viable alternative -- temporary named pipes (FIFOs): ``` import os import tempfile import subprocess as sp fifo_path = tempfile.mktemp() os.mkfifo(fifo_path,