From f7901a36842537aa8fb340da98d377cb5669681c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 16:59:28 +0000 Subject: [PATCH] Don't glob or test inside the kiosk user's private home as the admin Reported on a 26.04 offline install, first-boot step 4: chown: cannot dereference '/home/kiosk/kiosk-app/*.js': No such file or directory (same for *.mjs, *.html). `sudo chown ... "$KIOSK_DIR"/*.js` has the glob expanded by the calling (admin) shell before sudo runs; the kiosk user's home is created mode 750, so the admin can't list it, the pattern stays literal, and chown fails - stopping the install under set -e. - provision_install_app: chown the copied top-level files with `sudo find "$KIOSK_DIR" -maxdepth 1 -type f -exec chown ...` (root does the listing). Top level only, so chrome-sandbox inside node_modules keeps its root ownership. - Swept lib/ and menus/ for the same class of bug: Asterisk Intercom's baresip_is_installed and status read $KIOSK_HOME/.baresip/accounts without sudo, so they always reported "not configured". Now sudo test / sudo head. Everything else that touches the kiosk home (config.json, kiosk-app checks) already goes through sudo -u kiosk. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cjz8a58eB5P9sUweqd3NHm --- lib/provision.sh | 7 ++++++- menus/addon_asterisk_intercom.sh | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/provision.sh b/lib/provision.sh index 9df888c..d1fb3a5 100644 --- a/lib/provision.sh +++ b/lib/provision.sh @@ -138,7 +138,12 @@ provision_install_app() { echo "[4/10] Installing kiosk app..." # *.mjs: pdf-render.mjs (pdf.js only ships as a JavaScript module). sudo cp "$KIOSK_APP_SRC"/*.js "$KIOSK_APP_SRC"/*.mjs "$KIOSK_APP_SRC"/*.html "$KIOSK_APP_SRC/package.json" "$KIOSK_APP_SRC/start.sh" "$KIOSK_DIR/" - sudo chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_DIR"/*.js "$KIOSK_DIR"/*.mjs "$KIOSK_DIR"/*.html "$KIOSK_DIR/package.json" "$KIOSK_DIR/start.sh" + # Not `chown "$KIOSK_DIR"/*.js ...`: that glob is expanded by *this* + # (admin) shell before sudo runs, and the kiosk user's home is private + # (mode 750 on 26.04), so it can't be listed - the pattern stays literal + # and chown fails. find runs as root. Top level only: node_modules is + # already the kiosk user's, and chrome-sandbox inside it must stay root's. + sudo find "$KIOSK_DIR" -maxdepth 1 -type f -exec chown "$KIOSK_USER:$KIOSK_USER" {} + sudo chmod +x "$KIOSK_DIR/start.sh" if offline_mode_active; then diff --git a/menus/addon_asterisk_intercom.sh b/menus/addon_asterisk_intercom.sh index c70a418..ff88e6b 100644 --- a/menus/addon_asterisk_intercom.sh +++ b/menus/addon_asterisk_intercom.sh @@ -62,7 +62,9 @@ baresip_installed_version() { # `apt install baresip` with no configured extension isn't something # this menu should call done. baresip_is_installed() { - command -v baresip &>/dev/null && [[ -f "$BARESIP_CONFIG_DIR/accounts" ]] + # sudo: it's under the kiosk user's home, which the admin running this + # can't look inside (mode 750) - a plain [[ -f ]] is always false there. + command -v baresip &>/dev/null && sudo test -f "$BARESIP_CONFIG_DIR/accounts" } baresip_is_running() { @@ -78,9 +80,9 @@ addon_asterisk_intercom_status() { else echo "Asterisk Intercom: Installed (v${ver:-unknown}) - Not running" fi - if [[ -f "$BARESIP_CONFIG_DIR/accounts" ]]; then + if sudo test -f "$BARESIP_CONFIG_DIR/accounts"; then local account - account=$(head -1 "$BARESIP_CONFIG_DIR/accounts" 2>/dev/null) + account=$(sudo head -1 "$BARESIP_CONFIG_DIR/accounts" 2>/dev/null) local extension="${account#