Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add O_TMPFILE to os module #62873

Closed
tiran opened this issue Aug 6, 2013 · 7 comments
Closed

Add O_TMPFILE to os module #62873

tiran opened this issue Aug 6, 2013 · 7 comments
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@tiran
Copy link
Member

tiran commented Aug 6, 2013

BPO 18673
Nosy @jcea, @pitrou, @vstinner, @tiran, @jwilk, @socketpair

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2013-08-16.12:56:28.826>
created_at = <Date 2013-08-06.19:43:40.136>
labels = ['easy', 'type-feature', 'library']
title = 'Add O_TMPFILE to os module'
updated_at = <Date 2015-10-19.21:18:27.991>
user = 'https://github.com/tiran'

bugs.python.org fields:

activity = <Date 2015-10-19.21:18:27.991>
actor = 'socketpair'
assignee = 'none'
closed = True
closed_date = <Date 2013-08-16.12:56:28.826>
closer = 'christian.heimes'
components = ['Library (Lib)']
creation = <Date 2013-08-06.19:43:40.136>
creator = 'christian.heimes'
dependencies = []
files = []
hgrepos = []
issue_num = 18673
keywords = ['easy']
message_count = 7.0
messages = ['194569', '194580', '194769', '195320', '195322', '213093', '253194']
nosy_count = 8.0
nosy_names = ['jcea', 'pitrou', 'vstinner', 'christian.heimes', 'jwilk', 'socketpair', 'tshepang', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue18673'
versions = ['Python 3.4']

@tiran
Copy link
Member Author

tiran commented Aug 6, 2013

Linux 3.11 gets a new flag for open():

Quote from http://lwn.net/Articles/557314/
---
The new O_TMPFILE option to the open() and openat() system calls allows filesystems to optimize the creation of temporary files — files which need not be visible in the filesystem. When O_TMPFILE is present, the provided pathname is only used to locate the containing directory (and thus the filesystem where the temporary file should be). So, among other things, programs using O_TMPFILE should have fewer concerns about vulnerabilities resulting from symbolic link attacks.
---

Tasks:

  • add O_TEMPFILE to posixmodule.c
  • use O_TEMPFILE in tempfile module when it's supported by the current kernel

@tiran tiran added extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Aug 6, 2013
@pitrou
Copy link
Member

pitrou commented Aug 6, 2013

  • use O_TEMPFILE in tempfile module when it's supported by the current
    kernel

I assume this would only be done in TemporaryFile()?

@pitrou pitrou added easy and removed extension-modules C modules in the Modules dir labels Aug 6, 2013
@vstinner
Copy link
Member

vstinner commented Aug 9, 2013

use O_TEMPFILE in tempfile module when it's supported by the current kernel

How do you detect that a kernel does not support the flag? Try to use the flag and handle the error?

@python-dev
Copy link
Mannequin

python-dev mannequin commented Aug 16, 2013

New changeset f6034602410c by Christian Heimes in branch 'default':
Issue bpo-18673: Add O_TMPFILE to os module. O_TMPFILE requires Linux kernel
http://hg.python.org/cpython/rev/f6034602410c

New changeset 815b7bb3b08d by Christian Heimes in branch 'default':
Issue bpo-18673: Add versionchanged to docs
http://hg.python.org/cpython/rev/815b7bb3b08d

@tiran
Copy link
Member Author

tiran commented Aug 16, 2013

I have added O_TMPFILE to the os module.

I like to hold off with the actual use of O_TMPFILE in tempfile until Python 3.5. The feature is too new and I don't have any way to test it. Some people have reported file system corruption in 3.11-rc4, too.

@tiran tiran closed this as completed Aug 16, 2013
@tiran tiran changed the title Add and use O_TMPFILE for Linux 3.11 Add O_TMPFILE to os module Aug 16, 2013
@python-dev
Copy link
Mannequin

python-dev mannequin commented Mar 10, 2014

New changeset 0525f7268067 by R David Murray in branch 'default':
whatsnew: os.open O_TMPFILE (bpo-18673).
http://hg.python.org/cpython/rev/0525f7268067

@socketpair
Copy link
Mannequin

socketpair mannequin commented Oct 19, 2015

Just for link. Issue bpo-21515 — tempfile use this functionality now.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants