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
This commit is contained in:
Claude
2026-06-16 17:32:32 +00:00
parent 56e3d17459
commit 879e2ecd14
+4 -4
View File
@@ -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)"