Procházet zdrojové kódy

Secure the shebang patcher against binaries

Valentin Niess před 5 roky
rodič
revize
27ad66b8af
1 změnil soubory, kde provedl 10 přidání a 6 odebrání
  1. 10 6
      python_appimage/data/sitecustomize.py

+ 10 - 6
python_appimage/data/sitecustomize.py

@@ -37,14 +37,18 @@ def patch_pip_install():
             path = os.path.join(sys.prefix, 'bin', exe)
 
             if (not os.path.isfile(path)) or (not os.access(path, os.X_OK)) or \
-               exe.startswith('python') or os.path.islink(path):
+               exe.startswith('python') or os.path.islink(path) or             \
+               exe.endswith('.pyc') or exe.endswith('.pyo'):
                 continue
 
-            with open(path, 'r') as f:
-                header = f.read(2)
-                if header != '#!':
-                    continue
-                content = f.read()
+            try:
+                with open(path, 'r') as f:
+                    header = f.read(2)
+                    if header != '#!':
+                        continue
+                    content = f.read()
+            except:
+                continue
 
             shebang, body = content.split(os.linesep, 1)
             shebang = shebang.split()