Skip to content

os.chmod() does not follow symlinks on Windows #59616

Description

@atsuoishimoto
BPO 15411
Nosy @atsuoishimoto, @tjguk, @asvetlov, @zware
Files
  • chmod_symlink_win32.patch
  • chmod_symlink_win32_2.patch
  • 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 = None
    created_at = <Date 2012-07-21.08:31:23.124>
    labels = ['type-feature', 'library', 'OS-windows']
    title = 'os.chmod() does not follow symlinks on Windows'
    updated_at = <Date 2019-04-26.19:53:54.688>
    user = 'https://github.com/atsuoishimoto'

    bugs.python.org fields:

    activity = <Date 2019-04-26.19:53:54.688>
    actor = 'BreamoreBoy'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2012-07-21.08:31:23.124>
    creator = 'ishimoto'
    dependencies = []
    files = ['26462', '26464']
    hgrepos = []
    issue_num = 15411
    keywords = ['patch']
    message_count = 3.0
    messages = ['165996', '166003', '223300']
    nosy_count = 4.0
    nosy_names = ['ishimoto', 'tim.golden', 'asvetlov', 'zach.ware']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue15411'
    versions = ['Python 3.5']

    Linked PRs

    Activity

    1. atsuoishimoto commented on Jul 21, 2012

      atsuoishimotomannequin
      MannequinAuthor

      os.chmod() should check symlinks if followsymlinks option is True on Windows.

      This is a cause of failure of test case

      test.test_shutil.TestShutil.test_copymode_follow_symlinks

      (bpo-13837)

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Jul 21, 2012
    3. atsuoishimoto commented on Jul 21, 2012

      atsuoishimotomannequin
      MannequinAuthor

      Patch updated. Check symlinks only if supported by platform.

    4. BreamoreBoy commented on Jul 16, 2014

      BreamoreBoymannequin
      Mannequin

      Can we have a patch review on this please as it's holding up bpo-13837.

    5. transferred this issue fromon Apr 10, 2022
    6. added 2 commits that reference this issue on Dec 13, 2023
    7. serhiy-storchaka commented on Dec 13, 2023

      @serhiy-storchaka
      Member

      Unfortunately, the patch by @atsuoishimoto is too old and cannot be applied to the current code. The difference is so larger, that it is easier to write a new code from scratch than try to resolve conflicts iteratively.

      Which I did. My PR uses a different approach. Instead of resolving the symlink path, it opens a handle and changes file attributes by the handle (it is the recommended way). In future it may be possible to implement also os.fchmod().

    8. added a commit that references this issue on Dec 14, 2023
    9. serhiy-storchaka commented on Dec 14, 2023

      @serhiy-storchaka
      Member

      Now os.chmod() supports follow_symlinks=True on Windows. But by default it does not follow symlinks. Few versions later (in 3.15 or later) we can change the default. It will allow users to use os.lchmod() or os.chmod(follow_symlinks=False) if they need the old behavior, and it will work in several versions.

    10. added a commit that references this issue on Dec 15, 2023
    11. added a commit that references this issue on Feb 11, 2024
    12. added a commit that references this issue on Sep 2, 2024
    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

      OS-windowsstdlibStandard 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