Skip to content

Commit

Permalink
Merge pull request #7924 from ThomasWaldmann/fix-subcommand-env-master
Browse files Browse the repository at this point in the history
create --*-from-command: run subcommands with a clean environment, fixes #7916
  • Loading branch information
ThomasWaldmann committed Nov 8, 2023
2 parents e78146f + f3ddaaf commit 3de808b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/borg/archiver/create_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from ..helpers import log_multi
from ..helpers import basic_json_data, json_print
from ..helpers import flags_dir, flags_special_follow, flags_special
from ..helpers import prepare_subprocess_env
from ..helpers import sig_int, ignore_sigint
from ..helpers import iter_separated
from ..helpers import MakePathSafeAction
Expand Down Expand Up @@ -70,8 +71,12 @@ def create_inner(archive, cache, fso):
if not dry_run:
try:
try:
env = prepare_subprocess_env(system=True)
proc = subprocess.Popen(
args.paths, stdout=subprocess.PIPE, preexec_fn=None if is_win32 else ignore_sigint
args.paths,
stdout=subprocess.PIPE,
env=env,
preexec_fn=None if is_win32 else ignore_sigint,
)
except (FileNotFoundError, PermissionError) as e:
self.print_error("Failed to execute command: %s", e)
Expand All @@ -93,8 +98,9 @@ def create_inner(archive, cache, fso):
paths_sep = eval_escapes(args.paths_delimiter) if args.paths_delimiter is not None else "\n"
if args.paths_from_command:
try:
env = prepare_subprocess_env(system=True)
proc = subprocess.Popen(
args.paths, stdout=subprocess.PIPE, preexec_fn=None if is_win32 else ignore_sigint
args.paths, stdout=subprocess.PIPE, env=env, preexec_fn=None if is_win32 else ignore_sigint
)
except (FileNotFoundError, PermissionError) as e:
self.print_error("Failed to execute command: %s", e)
Expand Down

0 comments on commit 3de808b

Please sign in to comment.