Skip to content

Instantly share code, notes, and snippets.

@paulrobello
Created September 16, 2026 22:09
Show Gist options
  • Select an option

  • Save paulrobello/6b57d1de3d47e2904fcaf3f27f3ef69a to your computer and use it in GitHub Desktop.

Select an option

Save paulrobello/6b57d1de3d47e2904fcaf3f27f3ef69a to your computer and use it in GitHub Desktop.
Herdr.app: app-bundle wrapper that fixes macOS Tahoe Local Network Privacy for the herdr server

Herdr.app: fixing macOS Tahoe Local Network Privacy for the herdr server

A tiny macOS app-bundle wrapper that gives the herdr terminal multiplexer server (and every child process it spawns) a grantable identity under System Settings → Privacy & Security → Local Network.

Verified end-to-end on macOS Tahoe (2026-09): after pointing the herdr LaunchAgent at the bundle's launcher and granting "Herdr" Local Network permission, a non-Apple-signed process inside a herdr pane successfully opened TCP sockets to LAN hosts with attribution to Herdr.app.

The problem

macOS Tahoe's Local Network Privacy attaches permission grants to a responsible app — the nearest ancestor that is a real app bundle with a code signature. A herdr server spawned by launchd has no bundle anywhere in its ancestry, so macOS treats it as having no grantable identity:

  • Every pane child is silently blocked from LAN sockets (connections fail with EHOSTUNREACH).
  • Apple-signed tools (e.g. nc, curl via a signed shell) keep working, so the failure looks selective and confusing.
  • There is nothing in System Settings to grant — no toggle ever appears for it.

The solution

Wrap the server in a minimal .app bundle:

  1. The bundle's executable is a ~40-line C launcher (launcher.c) that execs the herdr CLI in-process: a bare launch runs herdr server, any arguments are forwarded verbatim so a supervisor (e.g. a LaunchAgent or a hub script) can drive the bundle binary as if it were herdr itself.
  2. LSUIElement in Info.plist keeps the app out of the Dock and the app switcher — it's infrastructure, not a user-facing app.
  3. NSLocalNetworkUsageDescription provides the Local Network usage string.
  4. Ad-hoc code signing (codesign --force -s -) gives the bundle the real Mach-O
    • signature that attribution and the Settings toggle require. (Script launchers cannot be signed, so the launcher must be compiled.)
  5. stdout/stderr land in ~/Library/Logs/herdr-server.log because launchd/Finder give the app no terminal.

Two empirical findings worth knowing:

  • Attribution survives daemonization. herdr's daemon hop to PPID 1 does not break the attribution to the signed bundle — the grant covers the whole process tree.
  • One grantable bundle, signed once, never touched again. The Local Network grant binds to the ad-hoc signature; rebuilding and replacing a granted /Applications/Herdr.app can silently void the permission, going all pane children LAN-dark until re-granted. Rebuild only for fresh machines.

Build

Verbatim from the repo's Makefile app target:

mkdir -p build/Herdr.app/Contents/MacOS build/Herdr.app/Contents/Resources
cc -O2 -o build/Herdr.app/Contents/MacOS/Herdr app/launcher.c
cp app/Info.plist build/Herdr.app/Contents/Info.plist
printf 'APPL????' > build/Herdr.app/Contents/PkgInfo
codesign --force -s - build/Herdr.app
plutil -lint build/Herdr.app/Contents/Info.plist

Install & grant

  1. Copy build/Herdr.app to /Applications.
  2. Start the server through the bundle: point your herdr LaunchAgent's herdr path at /Applications/Herdr.app/Contents/MacOS/Herdr, or just run open -a Herdr.
  3. Trigger a LAN connection, then grant Herdr under System Settings → Privacy & Security → Local Network.
  4. Optional: add a launchd log-capping LaunchAgent for ~/Library/Logs/herdr-server.log — a plain StandardErrorPath log never rotates (one grew to 326 MB in ~5.5 weeks for a related agent).

Troubleshooting

  • A dead LAN host perfectly mimics the privacy silent-fail signature. Before concluding a privacy block, verify the target host is alive and probe a known-live LAN port with an Apple-signed tool (nc -z <gateway> 80).
  • Grep the actual process name, not the project name, when checking whether the server is running — check launchctl list and listening sockets first.
  • Inspect the log: tail -f ~/Library/Logs/herdr-server.log.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Herdr</string>
<key>CFBundleDisplayName</key>
<string>Herdr</string>
<key>CFBundleIdentifier</key>
<string>com.paulrobello.herdr-server</string>
<key>CFBundleExecutable</key>
<string>Herdr</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>LSMinimumSystemVersion</key>
<string>13.0</string>
<key>LSUIElement</key>
<true/>
<key>NSLocalNetworkUsageDescription</key>
<string>Herdr serves Herdr terminal workspaces and connects to Herdr machines on your local network.</string>
</dict>
</plist>
/* Herdr.app launcher: execs the herdr CLI in-process so macOS Local Network
Privacy attributes the server — and every pane child — to this app bundle.
Bare launch runs `herdr server`; arguments are forwarded verbatim, making
the bundle binary a faithful herdr proxy for callers that pass flags (e.g.
the par-remote-herd hub driving $HERDR_BIN). stdout/stderr are appended to
~/Library/Logs/herdr-server.log because launchd/Finder give the app no
terminal. */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef HERDR_BIN
#define HERDR_BIN "/Users/probello/.local/bin/herdr"
#endif
int main(int argc, char **argv) {
const char *home = getenv("HOME");
char logpath[512];
snprintf(logpath, sizeof logpath, "%s/Library/Logs/herdr-server.log", home ? home : "/tmp");
int log = open(logpath, O_WRONLY | O_CREAT | O_APPEND, 0644);
if (log >= 0) {
dup2(log, STDOUT_FILENO);
dup2(log, STDERR_FILENO);
}
char *exec_args[255];
int n = 0;
exec_args[n++] = "herdr";
if (argc == 1) {
exec_args[n++] = "server";
} else {
for (int i = 1; i < argc && n < 253; i++) exec_args[n++] = argv[i];
}
exec_args[n] = NULL;
execv(HERDR_BIN, exec_args);
perror("herdr-app: exec " HERDR_BIN);
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment