From eab26c08889a749603308074a8fbc1422d454fdf Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 11 Nov 2026 15:01:03 -0700 Subject: [PATCH] Stop SSHFS hanging, and name the real reason Gatekeeper refuses an app With macFUSE's FSKit extension off, sshfs waits forever and ignores TERM; sftp_mount gives it 30 seconds, then stops it and says to turn macFUSE on. On a Mac that allows only App Store apps, app_install said the download "isn't notarized"; it now says the Mac only allows App Store apps, and where to change that. The vanilla image is like that and since macOS 15 only System Settings or MDM can change it, so 70-apps checks the message and skips the installs there. 85-sftp checks that add_sftp gives up while the extension is off. Co-Authored-By: Claude Opus 5.5 --- configure.d/lib/apps.sh | 22 ++++++++++++++++++++-- configure.d/lib/sftp.sh | 20 ++++++++++++++++++-- smoketest/README.md | 5 +++-- smoketest/scenarios/70-apps.sh | 15 +++++++++++++++ smoketest/scenarios/85-sftp.sh | 23 ++++++++++++++++++----- 5 files changed, 74 insertions(+), 11 deletions(-) diff --git a/configure.d/lib/apps.sh b/configure.d/lib/apps.sh index b6178a5..0dfbbe7 100644 --- a/configure.d/lib/apps.sh +++ b/configure.d/lib/apps.sh @@ -97,12 +97,30 @@ verify_team() { fi } +# Whether Gatekeeper allows apps from identified developers, and not only +# the App Store (System Settings > Privacy & Security) +developer_id_allowed() { + ! spctl --status -v 2> /dev/null | grep -q 'developer id disabled' +} + +# Why Gatekeeper turned something down: this Mac only allows App Store apps, +# or it isn't notarized +gatekeeper_refused() { + if ! developer_id_allowed; then + echo "${RED}Gatekeeper doesn't accept $1: this Mac only allows apps from the App Store.$RESET" + echo "In System Settings > Privacy & Security, allow applications from the App Store" + echo "and identified developers, then try again." + else + echo "${RED}Gatekeeper doesn't accept $1 (it isn't notarized). Not installing it.$RESET" + fi +} + # Install a downloaded .pkg, once it's checked. The installer needs admin. install_pkg() { local pkg="$1" verify_team "The download" "$(pkg_team "$pkg")" || return 1 if ! spctl --assess --type install "$pkg" 2> /dev/null; then - echo "${RED}Gatekeeper doesn't accept the download (it isn't notarized). Not installing it.$RESET" + gatekeeper_refused "the download" return 1 fi echo "Installing $APP_TITLE needs your Mac password." @@ -123,7 +141,7 @@ install_dmg() { elif ! verify_team "$APP_BUNDLE" "$(app_team "$app")"; then status=1 elif ! spctl --assess --type execute "$app" 2> /dev/null; then - echo "${RED}Gatekeeper doesn't accept $APP_BUNDLE (it isn't notarized). Not installing it.$RESET" + gatekeeper_refused "$APP_BUNDLE" status=1 elif ! ditto "$app" "/Applications/$APP_BUNDLE" 2> /dev/null; then echo "Copying $APP_TITLE to Applications needs your Mac password." diff --git a/configure.d/lib/sftp.sh b/configure.d/lib/sftp.sh index dc8bcc7..6961a06 100644 --- a/configure.d/lib/sftp.sh +++ b/configure.d/lib/sftp.sh @@ -92,7 +92,7 @@ sftp_mounted() { # mounted. reconnect and ServerAlive* bring it back after the network drops # (e.g. sleep); idmap=user shows your files on the server as yours here. sftp_mount() { - local url="$1" point="$2" backend opts + local url="$1" point="$2" backend opts pid i backend="$(fuse_backend)" || return 1 sftp_parse "$url" use_ssh_agent @@ -104,7 +104,23 @@ sftp_mount() { mkdir -p "$point" || return 1 opts="$opts,defer_permissions,noappledouble" fi - "$SSHFS" "$SFTP_USER@$SFTP_HOST:$SFTP_PATH" "$point" -o "$opts" + # With macFUSE's extension off, SSHFS waits forever (and ignores TERM), so + # it gets 30 seconds + "$SSHFS" "$SFTP_USER@$SFTP_HOST:$SFTP_PATH" "$point" -o "$opts" & + pid=$! + for i in $(seq 1 30); do + kill -0 "$pid" 2> /dev/null || { wait "$pid"; return; } + sleep 1 + done + kill -TERM "$pid" 2> /dev/null + sleep 2 + kill -KILL "$pid" 2> /dev/null + wait "$pid" 2> /dev/null + if [ "$backend" = fskit ]; then + echo "SSHFS didn't finish mounting. Is macFUSE turned on in System Settings, under" + echo "General > Login Items & Extensions > File System Extensions?" + fi + return 1 } sftp_unmount() { diff --git a/smoketest/README.md b/smoketest/README.md index fc543b7..1472d5b 100644 --- a/smoketest/README.md +++ b/smoketest/README.md @@ -34,7 +34,7 @@ Each scenario runs on a fresh clone of Cirrus Labs' **vanilla** macOS image (def - **What's in it:** macOS as it comes, with auto-login and a user `admin` (password `admin`) who has passwordless sudo. - **Why vanilla:** the "base" images come with Homebrew, Node.js and jq. Those would hide the paths a new Mac takes, where `configure` has to download its tools. -- **Gatekeeper:** the vanilla image switches Gatekeeper off, so `70-apps` switches it back on before testing downloads. +- **Gatekeeper:** the vanilla image switches Gatekeeper off, so `70-apps` switches it back on before testing downloads. The image also allows only App Store apps (`spctl --status -v` says "developer id disabled"), and since macOS 15 only System Settings or MDM can change that. So `70-apps` checks that `app_install` says so, and skips installing Element, Nextcloud and Tailscale. To test those installs, allow "App Store & Known Developers" in a VM's Privacy & Security once, and use that VM as the image (see below). `run` drives each scenario from your Mac: @@ -66,9 +66,10 @@ macOS deliberately allows these only with a click, so test them by hand on a VM - **Installing the profile:** in System Settings > Profiles, choose "Federated Core (...)", then Install. Then check Mail, Calendar and Contacts against a real Core. `configure core` notices the profile was installed. - **Full Disk Access for Federated Backup:** after granting it, `configure backup` says it can read all your files, and the backup log no longer has permission errors for Documents and Desktop. -- **Turning on macFUSE's file system extension**, if `85-sftp` couldn't do it with `pluginkit`: then mount an SFTP folder with `configure storage`. +- **Turning on macFUSE's file system extension**, if `85-sftp` couldn't do it with `pluginkit`: then mount an SFTP folder with `configure storage`. With the extension off, `85-sftp` checks that `add_sftp` gives up after 30 seconds rather than hanging. - **Mounting a real SMB share:** the sign-in window, "Remember this password in my keychain", and whether `mount volume "smb://host"` without a share offers a list of shares. - **Tailscale's VPN approval**, and **Nextcloud's sign-in** in the browser. +- **Installing Element, Nextcloud and Tailscale**, on an image that allows apps from identified developers: start a VM with `--keep`, choose "App Store & Known Developers" in System Settings > Privacy & Security, stop it, then `tart clone` it to a new name and run `smoketest/run --image 70`. ## Writing a scenario diff --git a/smoketest/scenarios/70-apps.sh b/smoketest/scenarios/70-apps.sh index d401742..113ca1b 100644 --- a/smoketest/scenarios/70-apps.sh +++ b/smoketest/scenarios/70-apps.sh @@ -26,6 +26,13 @@ wrong_team_refused() { ! install_pkg "$pkg" } +# Tailscale's real package, turned down with the reason that applies +app_store_only_refused() { + local out + out="$(app_install tailscale 2>&1)" && return 1 + echo "$out" | grep -q "only allows apps from the App Store" +} + team_of() { codesign -dv "$(app_path "$1")" 2>&1 | sed -n 's/^TeamIdentifier=//p' } @@ -45,6 +52,14 @@ scenario() { check "Gatekeeper turns down an app no one notarized" unnotarized_refused check "install_pkg refuses a package signed by another Team ID" wrong_team_refused + # The vanilla image also allows only App Store apps, and since macOS 15 + # only System Settings (a click) or MDM can change that + if ! developer_id_allowed; then + check "app_install says this Mac only allows App Store apps" app_store_only_refused + skip "Gatekeeper here only allows App Store apps, so Element, Nextcloud and Tailscale can't install (see README)" + return + fi + for app in element nextcloud tailscale; do step "$app" check "app_install $app (its Team ID and notarization check out)" app_install "$app" diff --git a/smoketest/scenarios/85-sftp.sh b/smoketest/scenarios/85-sftp.sh index 83ff1c8..2fdfa2f 100644 --- a/smoketest/scenarios/85-sftp.sh +++ b/smoketest/scenarios/85-sftp.sh @@ -38,6 +38,15 @@ remounts() { sftp_mounted "$point" } +# add_sftp fails, within sftp_mount's 30 seconds and not by asking to turn +# the extension on (which waits 5 minutes), and leaves nothing mounted +gives_up() { + local start=$SECONDS + add_sftp "$URL" < /dev/null && return 1 + [ $((SECONDS - start)) -le 60 ] || return 1 + ! sftp_mounted "/Volumes/localhost-sftp-source" +} + scenario() { local backend id check "fuse_backend picks one" fuse_backend @@ -59,11 +68,6 @@ scenario() { fskit_enabled || pluginkit -e use -i "$id" 2> /dev/null sleep 2 fi - if ! fskit_ready; then - skip "Turning macFUSE's extension on needs a click in System Settings: check mounting by hand" - return - fi - step "A folder from this Mac, over SSH" mkdir -p "$HOME/.ssh" "$SOURCE_DIR" echo "hello over sftp" > "$SOURCE_DIR/hello.txt" @@ -73,6 +77,15 @@ scenario() { mkdir -p "$CONF_DIR" : > "$STORAGE_CONF" check "sftp_key_works" sftp_key_works "$URL" + # The extension needs a click in System Settings, so it's usually off here + fskit_enabled + case $? in + 1) skip "Turning macFUSE's extension on needs a click in System Settings: check mounting by hand" + return ;; + 2) check "add_sftp gives up, rather than hanging, while macFUSE's extension isn't on" gives_up + skip "Turning macFUSE's extension on needs a click in System Settings: check mounting by hand" + return ;; + esac check "add_sftp mounts it and adds it to the list" add_sftp "$URL" check "launchd has the job" job_loaded check "a file reads through the mount" reads_through_mount