fix: isolate CHRNX local integration state

This commit is contained in:
chrnx committed 2026-08-12 09:48:12 -05:00
1 parent 21da6da227
commit 6e93c0ad20
16 files changed
+536 -65

No files matched your search

+20 -9
View File
@@ -16,20 +16,31 @@ if [ "$chrnx_image_output" = "/" ] || [ "$chrnx_image_output" = "$chrnx_image_ro
echo "Refusing broad image output path: $chrnx_image_output" >&2
exit 2
fi
if [ -L "$chrnx_image_output" ]; then
echo "Refusing symbolic-link image output: $chrnx_image_output" >&2
exit 2
fi
if [ "$chrnx_image_output" != "$chrnx_image_default_output" ]; then
chrnx_image_safe_tmp=${TMPDIR:-/tmp}
chrnx_image_safe_tmp=${chrnx_image_safe_tmp%/}
case "$chrnx_image_output" in
"$chrnx_image_safe_tmp"/chrnx-*) ;;
*)
echo "Temporary image output must be an existing chrnx-* directory under $chrnx_image_safe_tmp." >&2
exit 2
;;
esac
if [ ! -d "$chrnx_image_output" ]; then
echo "Temporary image output does not exist: $chrnx_image_output" >&2
exit 2
fi
chrnx_image_safe_tmp=$(CDPATH= cd -P -- "${TMPDIR:-/tmp}" && pwd)
chrnx_image_output_parent=$(dirname -- "$chrnx_image_output")
chrnx_image_output_name=$(basename -- "$chrnx_image_output")
chrnx_image_output_parent=$(CDPATH= cd -P -- "$chrnx_image_output_parent" && pwd)
case "$chrnx_image_output_name" in
chrnx-*) ;;
*)
echo "Temporary image output basename must start with chrnx-." >&2
exit 2
;;
esac
if [ "$chrnx_image_output_parent" != "$chrnx_image_safe_tmp" ]; then
echo "Temporary image output must be a direct child of $chrnx_image_safe_tmp." >&2
exit 2
fi
chrnx_image_output=$(CDPATH= cd -P -- "$chrnx_image_output" && pwd)
fi
chrnx_image_tmp=$(mktemp -d "${TMPDIR:-/tmp}/chrnx-images.XXXXXX")
trap 'rm -rf -- "$chrnx_image_tmp"' EXIT HUP INT TERM