From 0dc4dfaefae95b87aa8343113e449d644dfd876d Mon Sep 17 00:00:00 2001 From: okxlin <61420215+okxlin@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:18:51 +0800 Subject: [PATCH] fix: preserve external photo library ownership --- apps/this-week-in-past/4.1.5/scripts/init.sh | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/this-week-in-past/4.1.5/scripts/init.sh b/apps/this-week-in-past/4.1.5/scripts/init.sh index e86cb374a..c93633444 100755 --- a/apps/this-week-in-past/4.1.5/scripts/init.sh +++ b/apps/this-week-in-past/4.1.5/scripts/init.sh @@ -80,5 +80,29 @@ ensure_dir() { chown -R --no-dereference 1337:1337 "$path" } -ensure_dir "PHOTO_LIBRARY_PATH" "./data/photos" +ensure_photo_library() { + local raw path + raw="$(configured_value PHOTO_LIBRARY_PATH "./data/photos")" + case "$raw" in + ""|.|..|../*|*/../*|*/..) fail "unsafe PHOTO_LIBRARY_PATH path" ;; + esac + if [[ "$raw" =~ [[:cntrl:]] ]]; then + fail "unsafe PHOTO_LIBRARY_PATH path" + fi + + if [[ "$raw" == /* ]]; then + path="$raw" + else + path="$(realpath -m -- "$ROOT_DIR/$raw")" || fail "unsafe PHOTO_LIBRARY_PATH path" + fi + + if [[ "$raw" != /* && "$path" == "$ROOT_DIR/"* ]]; then + mkdir -p -- "$path" + return + fi + + [[ -d "$path" ]] || fail "PHOTO_LIBRARY_PATH must point to an existing directory" +} + +ensure_photo_library ensure_dir "APP_DATA_DIR" "./data/app"