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

tempfile.py TemporaryDirectory/mkdtemp defaults to mode 0o700, propose to add mode argument #86050

Closed
ray-sit mannequin opened this issue Sep 29, 2020 · 3 comments
Closed
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@ray-sit
Copy link
Mannequin

ray-sit mannequin commented Sep 29, 2020

BPO 41884
Nosy @serhiy-storchaka, @ray-sit
PRs
  • bpo-41884: Added optional mode argument for mkdtemp/TemporaryDirectory in tempfile #22451
  • Files
  • tempfile.py
  • 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 2020-12-31.04:23:39.571>
    created_at = <Date 2020-09-29.12:56:02.473>
    labels = ['type-feature', 'library', '3.10']
    title = 'tempfile.py TemporaryDirectory/mkdtemp defaults to mode 0o700, propose to add mode argument'
    updated_at = <Date 2020-12-31.04:23:39.570>
    user = 'https://github.com/ray-sit'

    bugs.python.org fields:

    activity = <Date 2020-12-31.04:23:39.570>
    actor = 'ray-sit'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-31.04:23:39.571>
    closer = 'ray-sit'
    components = ['Library (Lib)']
    creation = <Date 2020-09-29.12:56:02.473>
    creator = 'ray-sit'
    dependencies = []
    files = ['49477']
    hgrepos = []
    issue_num = 41884
    keywords = []
    message_count = 2.0
    messages = ['377667', '377668']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'ray-sit']
    pr_nums = ['22451']
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue41884'
    versions = ['Python 3.10']

    @ray-sit
    Copy link
    Mannequin Author

    ray-sit mannequin commented Sep 29, 2020

    tempfile.TemporaryDirectory always creates the directory with 0o700 permissions. So other applications which could run as a different user (i.e. root) cannot access the directory.

    To improve the usability I would like to add the option to set the permissions of the directory.

    Proposed Change is in the PR linked (#22451)

    @ray-sit ray-sit mannequin added 3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Sep 29, 2020
    @serhiy-storchaka
    Copy link
    Member

    You can change permissions after creating the directory.

    The C function mkdtemp() creates the directory with permissions 0o700.

    @ray-sit ray-sit mannequin closed this as completed Dec 31, 2020
    @ray-sit ray-sit mannequin closed this as completed Dec 31, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @CharlesReinhardt
    Copy link

    A recent issue in the aws-cli (aws/aws-cli#9114) would benefit from having a mode argument in TemporaryDirectory/mkdtemp, but it seems this change is not being considered. Commenting to link the issue to other relevant threads. We will find a different workaround for the aws-cli issue.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants