Skip to content

Commit

Permalink
Set executable permissions when extracting packages
Browse files Browse the repository at this point in the history
Packages with .no-sublime-package may contain native executables or
shell scripts, but python's ZipFile implementation doesn't understand
executable permissions.

Fixes #1348
  • Loading branch information
BenjaminSchaaf committed Oct 23, 2023
1 parent cfaaeb5 commit 7d8961f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions package_control/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -54,6 +55,9 @@
])


ZIP_UNIX_SYSTEM = 3


class PackageManager():

"""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7d8961f

Please sign in to comment.