mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-22 06:01:54 +00:00
Merge pull request #3079 from ThomasWaldmann/fix-subprocess-env-1.1
fix LDLP restoration for subprocesses, fixes #3077
This commit is contained in:
commit
ed3abcfe6f
1 changed files with 15 additions and 2 deletions
|
@ -2330,14 +2330,27 @@ def prepare_subprocess_env(system, env=None):
|
||||||
"""
|
"""
|
||||||
env = dict(env if env is not None else os.environ)
|
env = dict(env if env is not None else os.environ)
|
||||||
if system:
|
if system:
|
||||||
# a pyinstaller binary's bootloader modifies LD_LIBRARY_PATH=/tmp/_ME...,
|
# a pyinstaller binary's bootloader modifies LD_LIBRARY_PATH=/tmp/_MEIXXXXXX,
|
||||||
# but we do not want that system binaries (like ssh or other) pick up
|
# but we do not want that system binaries (like ssh or other) pick up
|
||||||
# (non-matching) libraries from there.
|
# (non-matching) libraries from there.
|
||||||
# thus we install the original LDLP, before pyinstaller has modified it:
|
# thus we install the original LDLP, before pyinstaller has modified it:
|
||||||
lp_key = 'LD_LIBRARY_PATH'
|
lp_key = 'LD_LIBRARY_PATH'
|
||||||
lp_orig = env.get(lp_key + '_ORIG') # pyinstaller >= 20160820 has this
|
lp_orig = env.get(lp_key + '_ORIG') # pyinstaller >= 20160820 / v3.2.1 has this
|
||||||
if lp_orig is not None:
|
if lp_orig is not None:
|
||||||
env[lp_key] = lp_orig
|
env[lp_key] = lp_orig
|
||||||
|
else:
|
||||||
|
# We get here in 2 cases:
|
||||||
|
# 1. when not running a pyinstaller-made binary.
|
||||||
|
# in this case, we must not kill LDLP.
|
||||||
|
# 2. when running a pyinstaller-made binary and there was no LDLP
|
||||||
|
# in the original env (in this case, the pyinstaller bootloader
|
||||||
|
# does *not* put ..._ORIG into the env either).
|
||||||
|
# in this case, we must kill LDLP.
|
||||||
|
# The directory used by pyinstaller is created by mkdtemp("_MEIXXXXXX"),
|
||||||
|
# we can use that to differentiate between the cases.
|
||||||
|
lp = env.get(lp_key)
|
||||||
|
if lp is not None and re.search(r'/_MEI......', lp):
|
||||||
|
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)
|
||||||
# for information, give borg version to the subprocess
|
# for information, give borg version to the subprocess
|
||||||
|
|
Loading…
Reference in a new issue