Skip to content

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

Closed

Description

@ray-sit
mannequin
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']

    Activity

    1. ray-sit commented on Sep 29, 2020

      ray-sitmannequin
      MannequinAuthor

      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)

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Sep 29, 2020
    3. serhiy-storchaka commented on Sep 29, 2020

      @serhiy-storchaka
      Member

      You can change permissions after creating the directory.

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

    4. transferred this issue fromon Apr 10, 2022
    5. CharlesReinhardt commented on Jan 9, 2025

      @CharlesReinhardt

      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

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions