From 7d8961f9dee3e394d799f9beb44d6d36e2628e6b Mon Sep 17 00:00:00 2001 From: Benjamin Schaaf Date: Tue, 10 Oct 2023 11:51:48 +1100 Subject: [PATCH] Set executable permissions when extracting packages Packages with .no-sublime-package may contain native executables or shell scripts, but python's ZipFile implementation doesn't understand executable permissions. Fixes https://github.com/wbond/package_control/issues/1348 --- package_control/package_manager.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package_control/package_manager.py b/package_control/package_manager.py index 61efb297..674b56b3 100644 --- a/package_control/package_manager.py +++ b/package_control/package_manager.py @@ -9,6 +9,7 @@ import tempfile # To prevent import errors in thread with datetime import locale # noqa +from stat import S_IXUSR try: # Python 3 @@ -54,6 +55,9 @@ ]) +ZIP_UNIX_SYSTEM = 3 + + class PackageManager(): """ @@ -1393,6 +1397,11 @@ def add_extracted_dirs(dir_): ''', package_name ) + else: + # Apply 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) package_zip.close() package_zip = None