cockpit: fix subprocess invocation in frozen binaries

When running as a Pyinstaller-made binary, sys.executable points to the
borg binary itself. Invoking it with "-m borg" resulted in an incorrect
command line (e.g., "borg -m borg ..."), which confused the argument
parser in the subprocess.

This change checks sys.frozen to determine the correct invocation:
- If frozen: [sys.executable, ...args]
- If not frozen: [sys.executable, "-m", "borg", ...args]
This commit is contained in:
Thomas Waldmann 2026-02-14 21:22:30 +01:00
parent 40dcfe4d99
commit 054194f4cb
No known key found for this signature in database
GPG key ID: 9F88FB52FAF7B393

View file

@ -28,7 +28,10 @@ class BorgRunner:
self.logger.warning("Borg process already running.")
return
cmd = [sys.executable, "-m", "borg"] + self.command
if getattr(sys, "frozen", False):
cmd = [sys.executable] + self.command # executable == pyinstaller binary
else:
cmd = [sys.executable, "-m", "borg"] + self.command # executable == python interpreter
self.logger.info(f"Starting Borg process: {cmd}")