From 879e2ecd14a4f080c2c5b3fbd4380f545860f4e7 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 16 Jun 2026 17:32:32 +0000 Subject: [PATCH] Fix all file existence checks to run as kiosk user /home/kiosk is mode 700 so root cannot traverse it. Every [[ -f ]] or [[ ! -f ]] check on paths inside /home/kiosk was silently returning 'not found' even after the kiosk user had successfully written the file. Replace all three [[ ! -f "$electron_bin" ]] checks and the [[ -f "$sandbox" ]] check in install_electron_binary with sudo -u "$KIOSK_USER" test -f so they run in the kiosk user's security context and can actually see the files. https://claude.ai/code/session_01VQ13Fwq4MXxwThLfCXBeGr --- ubuntu-based-kiosk-v1.0.3.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ubuntu-based-kiosk-v1.0.3.sh b/ubuntu-based-kiosk-v1.0.3.sh index 2bf345a..cb7e882 100644 --- a/ubuntu-based-kiosk-v1.0.3.sh +++ b/ubuntu-based-kiosk-v1.0.3.sh @@ -11082,12 +11082,12 @@ import_settings() { install_electron_binary() { local electron_bin="$KIOSK_DIR/node_modules/electron/dist/electron" - if [[ ! -f "$electron_bin" ]]; then + if ! sudo -u "$KIOSK_USER" test -f "$electron_bin"; then log_warning "Electron binary missing — retrying via install.js..." sudo -u "$KIOSK_USER" bash -lc "cd '$KIOSK_DIR' && ELECTRON_FORCE_DOWNLOAD=true node node_modules/electron/install.js" || true fi - if [[ ! -f "$electron_bin" ]]; then + if ! sudo -u "$KIOSK_USER" test -f "$electron_bin"; then log_warning "Attempting direct wget download of Electron binary (~120MB)..." local electron_ver electron_ver=$(sudo -u "$KIOSK_USER" node -e \ @@ -11111,7 +11111,7 @@ install_electron_binary() { fi fi - if [[ ! -f "$electron_bin" ]]; then + if ! sudo -u "$KIOSK_USER" test -f "$electron_bin"; then log_error "Electron binary download failed after all attempts." log_error "Check your internet connection and re-run the installer." return 1 @@ -11120,7 +11120,7 @@ install_electron_binary() { # chrome-sandbox MUST be owned by root and setuid — without this Electron shows a blank screen local sandbox="$KIOSK_DIR/node_modules/electron/dist/chrome-sandbox" - if [[ -f "$sandbox" ]]; then + if sudo -u "$KIOSK_USER" test -f "$sandbox"; then sudo chown root:root "$sandbox" sudo chmod 4755 "$sandbox" log_success "Chrome sandbox permissions set (required for display)"