Skip to content

gh-59999: zipfile: restore Unix permissions after extraction - #150061

Open
Aniketsy wants to merge 4 commits into
python:mainfrom
Aniketsy:fix-149839
Open

Aniketsy wants to merge 4 commits into
python:mainfrom
Aniketsy:fix-149839

Conversation

@Aniketsy

@Aniketsy Aniketsy commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

fixes #149839

  • When extracting a zip file, stored Unix permissions were ignored and files always got default permissions instead.
  • Fixed by applying the stored permissions with os.chmod after extraction.

@serhiy-storchaka serhiy-storchaka changed the title gh-149839: zipfile: restore Unix permissions after extraction gh-59999: zipfile: restore Unix permissions after extraction May 19, 2026
@Aniketsy

Aniketsy commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

As this pr is linked to quite old issue, i'm really excited and looking forward to fix. waiting for members to review and give suggestion for this if we need improvements. Thanks!

@Aniketsy

Copy link
Copy Markdown
Contributor Author

@vstinner gentle ping, please have a look in this when you get chance . Thanks!

@benkeil

benkeil commented Sep 23, 2026

Copy link
Copy Markdown

what's the status of this?

opcode81 pushed a commit to oraios/serena that referenced this pull request Sep 23, 2026
* Restore Unix executable bits when extracting zip archives

- SafeZipExtractor._extract_member now chmods each extracted file with the
  Unix mode stored in ZipInfo.external_attr (POSIX only, no-op when the
  archive carries no Unix attributes, e.g. Windows-authored zips).
- stdlib zipfile never restores permission bits itself; a fix is tracked
  upstream at python/cpython#150061.
- Fixes archives with more than one executable losing their exec bit after
  extraction, e.g. the bundled JBR inside the Kotlin Language Server
  distribution (jbr/bin/java and native libs), which previously only had
  its single top-level launcher script chmod'd by the language-server code.

Fixes #2100

---------

Co-authored-by: Copilot <[email protected]>
@Aniketsy

Copy link
Copy Markdown
Contributor Author

what's the status of this?

this needs review

@ambv ambv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aniketsy at this point we can't change the default. See #32289 for a better approach:

  • the default stays the same;
  • there's an option to preserve only safe permissions;
  • there's an option to preserve all permissions.

@bedevere-app

bedevere-app Bot commented Oct 20, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Nov 2, 2026
@Aniketsy
Aniketsy marked this pull request as draft November 2, 2026 14:22
@Aniketsy

Aniketsy commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

sorry, didn't mean to create noise ( i merged main to resolve conflict :(

@Aniketsy

Aniketsy commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@ambv thanks! for the review, I've updated with changes, but i want to go through these once again, so marking in draft for now... also i'll update with news entry

@read-the-docs-community

read-the-docs-community Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35718844 | 📁 Comparing 572d884 against main (fc083ad)

  🔍 Preview build  

108 files changed · ± 108 modified

± Modified

@danny0838

Copy link
Copy Markdown
Contributor

Another approach gh-154704 that prevents several issues and provides more flexibility.

@Aniketsy
Aniketsy marked this pull request as ready for review November 7, 2026 13:29
@Aniketsy

Aniketsy commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-app

bedevere-app Bot commented Nov 7, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@ambv: please review the changes made to this pull request.

@bedevere-app
bedevere-app Bot requested a review from ambv November 7, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting change review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zipfile.extractall never restores stored Unix permissions

4 participants