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

[4.0] Only restore executable permissions on extracted files #1655

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions package_control/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from concurrent import futures
from io import BytesIO
from stat import S_IXUSR
from threading import RLock
from urllib.parse import urlencode

Expand Down Expand Up @@ -54,6 +55,8 @@
'https://sublime.wbond.net/repositories.json'
])

ZIP_UNIX_SYSTEM = 3


class PackageManager:

Expand Down Expand Up @@ -1053,8 +1056,10 @@ def _extract_zip(self, name, zf, src_dir, dest_dir, extracted_files=None):
with zf.open(info) as fsrc, open(dest, 'wb') as fdst:
shutil.copyfileobj(fsrc, fdst)

# restore file mode
os.chmod(dest, info.external_attr >> 16)
# Restore executable permissions
if (info.create_system == ZIP_UNIX_SYSTEM
and (info.external_attr >> 16) & S_IXUSR):
os.chmod(dest, os.stat(dest).st_mode | S_IXUSR)

except OSError as e:
if e.errno == 5 or e.errno == 13: # permission denied
Expand Down