summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Waldmann <tw@waldmann-edv.de>2023-11-06 17:26:54 +0100
committerThomas Waldmann <tw@waldmann-edv.de>2023-11-06 17:41:52 +0100
commite006a6f368aba610d6086af8aa1b486708c3f319 (patch)
tree15cd7c98e543b58458bc8500be08789b4f97dfd1 /src
parent11af475308c26750c3cbf9dcfe60ac4a5f4cb65f (diff)
create --*-from-command: run subcommands with a clean environment, fixes #7916
When borg invokes a system command, it needs to prepare the environment for that. This is especially important when using a pyinstaller-made borg fat binary that works with a modified env var LD_LIBRARY_PATH - system commands may crash with that. borg already had calls to prepare_subprocess_env at some places (e.g. when invoking ssh for the remote repo connection), but they were missing for: borg create --content-from-command ... borg create --paths-from-command ...
Diffstat (limited to 'src')
-rw-r--r--src/borg/archiver.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
index 392bd1dd3..aaa5badce 100644
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -533,7 +533,8 @@ class Archiver:
if not dry_run:
try:
try:
- proc = subprocess.Popen(args.paths, stdout=subprocess.PIPE, preexec_fn=ignore_sigint)
+ env = prepare_subprocess_env(system=True)
+ proc = subprocess.Popen(args.paths, stdout=subprocess.PIPE, env=env, preexec_fn=ignore_sigint)
except (FileNotFoundError, PermissionError) as e:
self.print_error('Failed to execute command: %s', e)
return self.exit_code
@@ -552,7 +553,8 @@ class Archiver:
paths_sep = eval_escapes(args.paths_delimiter) if args.paths_delimiter is not None else '\n'
if args.paths_from_command:
try:
- proc = subprocess.Popen(args.paths, stdout=subprocess.PIPE, preexec_fn=ignore_sigint)
+ env = prepare_subprocess_env(system=True)
+ proc = subprocess.Popen(args.paths, stdout=subprocess.PIPE, env=env, preexec_fn=ignore_sigint)
except (FileNotFoundError, PermissionError) as e:
self.print_error('Failed to execute command: %s', e)
return self.exit_code