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
This commit is contained in:
@@ -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 ""
|
||||
|
||||
|
||||
+5
-1
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user