From 43266a4cf0db1332f5e08c5549a54d3b6e2ff704 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 16 Jun 2026 17:17:37 +0000 Subject: [PATCH] Fix Electron binary extraction: chown dist/ before extracting as kiosk user The previous fix incorrectly ran unzip as root, which fails because /home/kiosk is not accessible to root. The kiosk user is the right actor for the extraction, but two things blocked it: 1. node_modules/electron/dist/ can be owned by root when npm's electron postinstall runs with --unsafe-perm, so the kiosk user gets 'Permission denied' trying to write there. Fix: sudo chown -R the electron directory to the kiosk user before extracting. 2. With set -euo pipefail active (upgrade call had no || guard), a failed unzip or chmod would abort the script silently before the diagnostic error messages could print. Fix: add || true to both commands so the function always reaches the explicit -f check which prints the real error and returns 1. The upgrade call already has || { log_error ...; return 1; } from the previous commit. https://claude.ai/code/session_01VQ13Fwq4MXxwThLfCXBeGr --- ubuntu-based-kiosk-v1.0.3.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ubuntu-based-kiosk-v1.0.3.sh b/ubuntu-based-kiosk-v1.0.3.sh index 28849c3..659a339 100644 --- a/ubuntu-based-kiosk-v1.0.3.sh +++ b/ubuntu-based-kiosk-v1.0.3.sh @@ -11099,12 +11099,12 @@ install_electron_binary() { tmp_zip=$(mktemp --suffix=.zip) if wget --timeout=300 --tries=3 --show-progress -O "$tmp_zip" "$electron_url" 2>&1; then command -v unzip >/dev/null 2>&1 || sudo apt install -y unzip - # Run as root so we can write regardless of who owns node_modules/electron/dist/ - # (npm postinstall may create it as root when --unsafe-perm is used) - mkdir -p "$KIOSK_DIR/node_modules/electron/dist" - unzip -o "$tmp_zip" -d "$KIOSK_DIR/node_modules/electron/dist/" - chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_DIR/node_modules/electron/dist/" - chmod +x "$electron_bin" + # Fix ownership first so the kiosk user can write into the directory + # (npm postinstall with --unsafe-perm can leave dist/ owned by root) + sudo chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_DIR/node_modules/electron/" 2>/dev/null || true + sudo -u "$KIOSK_USER" mkdir -p "$KIOSK_DIR/node_modules/electron/dist" + sudo -u "$KIOSK_USER" unzip -o "$tmp_zip" -d "$KIOSK_DIR/node_modules/electron/dist/" || true + sudo -u "$KIOSK_USER" chmod +x "$electron_bin" || true fi rm -f "$tmp_zip" fi