mirror of
https://github.com/niess/python-appimage.git
synced 2026-03-14 04:10:15 +01:00
Secure the shebang patcher against binaries
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user