macOS: run the launchd daemon as root so it can reach the LAN

On macOS 15, Local Network privacy blocks LAN connections from a launchd
daemon running as a user (EHOSTUNREACH; curl works), and a daemon can't show
the permission prompt. Tested on 15.3.1 with the probe's own Python: a root
daemon connects to the hub, the same daemon with UserName gets "No route to
host". The plist no longer sets UserName. The checkout, venv and
<name>-update stay owned by the installing user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-04 20:15:43 -08:00
parent 30ce39d5f0
commit 380243545c
4 changed files with 17 additions and 4 deletions

View file

@ -48,7 +48,7 @@ ensure_python() {
if [ "$(uname -s)" = Darwin ]; then
PLATFORM=launchd
SERVICE="dev.neilbantoc.$NAME"
SVC_USER=$(id -un)
SVC_USER=$(id -un) # owns the checkout and runs <name>-update; the daemon itself runs as root
[ "$SVC_USER" != root ] || native_die "on macOS, run the installer as your own user, not with sudo"
else
PLATFORM=systemd
@ -125,7 +125,10 @@ else
<plist version="1.0">
<dict>
<key>Label</key><string>$SERVICE</string>
<key>UserName</key><string>$SVC_USER</string>
<!-- No UserName: the daemon runs as root. macOS 15 Local Network privacy exempts root
launchd daemons but blocks LAN connections (EHOSTUNREACH) from a daemon running as a
user, and a daemon can't show the permission prompt. Code, venv and updates stay
owned by $SVC_USER. -->
<key>ProgramArguments</key>
<array><string>/bin/bash</string><string>$INSTALL_DIR/native/run.sh</string></array>
<key>WorkingDirectory</key><string>$INSTALL_DIR</string>