fix pyinstaller detection for dir-mode, fixes #5897

"running under pyinstaller" detection is now as recommended by the pyinstaller docs.
This commit is contained in:
Thomas Waldmann 2021-07-10 22:35:48 +02:00
parent 7f97b0db99
commit 5a13416a80
1 changed files with 2 additions and 3 deletions

View File

@ -290,10 +290,9 @@ def prepare_subprocess_env(system, env=None):
# in the original env (in this case, the pyinstaller bootloader # in the original env (in this case, the pyinstaller bootloader
# does *not* put ..._ORIG into the env either). # does *not* put ..._ORIG into the env either).
# in this case, we must kill LDLP. # in this case, we must kill LDLP.
# The directory used by pyinstaller is created by mkdtemp("_MEIXXXXXX"), # We can recognize this via sys.frozen and sys._MEIPASS being set.
# we can use that to differentiate between the cases.
lp = env.get(lp_key) lp = env.get(lp_key)
if lp is not None and re.search(r'/_MEI......', lp): if lp is not None and getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
env.pop(lp_key) env.pop(lp_key)
# security: do not give secrets to subprocess # security: do not give secrets to subprocess
env.pop('BORG_PASSPHRASE', None) env.pop('BORG_PASSPHRASE', None)