From 7c9aa7159ab061ad7425ce691f518fb3c96126ff Mon Sep 17 00:00:00 2001 From: sudolulo Date: Mon, 15 Jun 2026 16:03:19 +0000 Subject: [PATCH] Fix two confirmed findings from full codebase audit - patch_ui.py: wrap shutil.copy2 backup in try/except OSError so a permission or read-only filesystem error prints a specific diagnostic instead of crashing the script with a generic 'exited non-zero' message - install.sh: add early guard that detects pipe-install (bash <(curl ...)) and exits with a clear error pointing to the git clone workflow --- install.sh | 8 ++++++++ patch/patch_ui.py | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 4b59482..2a99a69 100755 --- a/install.sh +++ b/install.sh @@ -15,6 +15,14 @@ set -euo pipefail PATCH_DIR="/data/truecloud-patch" REPO_DIR="$(cd "$(dirname "$0")" && pwd)" +if [ ! -f "$REPO_DIR/patch/sitecustomize.py" ]; then + echo "ERROR: patch files not found at $REPO_DIR/patch/" >&2 + echo "Run install.sh from the cloned repository, not via pipe:" >&2 + echo " git clone https://github.com/sudolulo/truenas-truecloud-patch" >&2 + echo " cd truenas-truecloud-patch && bash install.sh" >&2 + exit 1 +fi + echo "=== TrueNAS TrueCloud Provider Patch — Install ===" echo "" diff --git a/patch/patch_ui.py b/patch/patch_ui.py index b93f73b..cc65625 100644 --- a/patch/patch_ui.py +++ b/patch/patch_ui.py @@ -90,7 +90,11 @@ def main(): backup = path + ".pre-truecloud-patch" if not os.path.exists(backup): - shutil.copy2(path, backup) + try: + shutil.copy2(path, backup) + except OSError as exc: + print(f"[truecloud-patch] ERROR: Could not create backup {backup}: {exc}") + return patched, count = FIND.subn(REPLACE, content) if count != 1: