Let Hermes' gateway reach only a Matrix server you've allowed

Ports CoreDesktop's e991264, 05b13b2 and d974b91.

configure agents allowed Hermes' gateway the host in MATRIX_HOMESERVER
from ~/.hermes/.env, which Hermes can write from inside its sandbox, so
it could open the way out to any host it chose. The allowed server is
now in ~/.config/federated-connector/sandbox/hermes.json, which no
sandbox can write. configure hermes is to do while Hermes names a server
you haven't allowed, and asks about only that; configure agents says so.
Only a plain host name counts, so it can't be a wildcard or carry escape
codes into the question. sandbox/agent no longer reads
FEDERATED_SANDBOX_DOMAINS. The server an old drop-in allows is carried
over, read from the drop-in itself, when the gateway starts and when
configure agents rewrites it, so a working gateway keeps working.

Agents could read ~/.config/federated-connector, which has the Core's
domain and user name; base.json now hides it.

edit_json treats an empty settings file like a missing one: jq reads no
JSON from an empty file and writes nothing back, so configure ai-servers
said a server was added while the sandbox still blocked it.

agent_path joined the last folder on PATH to ~/.local/bin, so an agent
there wasn't found when ~/.local/bin wasn't on PATH (e.g. in a service).

Smoketest: 55-hermes-homeserver, and 50-sandbox checks that an agent
can't read the connector's settings. PLAN.md drops what's done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 18:55:37 -07:00
co-authored by Claude Opus 5.5
parent cf31ffc929
commit 1445ad7bb1
12 changed files with 210 additions and 37 deletions
+14 -9
View File
@@ -48,12 +48,21 @@ git -C ../coredesktop log --oneline <marker>..HEAD -- configure configure.d sand
Since `4a4a3bd`, to look at:
- [ ] `16e5a9c` Find storage and AI servers on the tailnet, not only over mDNS
- [ ] `e991264` Let Hermes' gateway reach only a Matrix server you've allowed
- [ ] `d974b91` configure: treat an empty settings file like a missing one
- [ ] `05b13b2` Test the agent sandbox from inside, and hide CoreDesktop's settings
- [ ] `05b13b2` Test the agent sandbox from inside: port
`smoketest/scenarios/60-security.sh`, which runs a script through
sandbox/bin's wrappers and checks what it can't read, write or reach,
and its later checks from `d5925fa` (what root runs is root's alone) and
`53c6c8b` (the install path). Hiding the connector's settings from
agents is done.
- [ ] `4fb3539` Claude notifications: clicking one brings back the app Claude runs in
- [ ] `9dc5eb1` Upgrade safeguards, hardware setup, sign-in options and Taildrop:
Taildrop is likely to apply; the rest is probably Arch-only
- [ ] `9dc5eb1` Upgrade safeguards, hardware setup, sign-in options and Taildrop.
To port: `configure security-key` and `configure fingerprint` (through
`pam-auth-update` and fprintd on Pop!_OS, not by editing PAM files),
Taildrop's service that saves files sent here to Downloads (COSMIC Files
has no Scripts menu for sending), keeping the computer awake during
`update`, and the captive portal script that pauses a Tailscale exit
node. Arch only: the pacman guard, unowned files, `hardware.sh`
(System76 does its own).
- [ ] `ffbaf71` Keep other machines on the network from reaching Docker
containers: only if the connector ever installs Docker
@@ -61,10 +70,6 @@ Arch or GNOME only, nothing to port: `e14a345` and `ba4dc17` (login screen
logo), `1e2581d` (kernel modules), `d456e31` (initramfs), `5d7db2c` (reboot
after update: Pop!_OS' own updates handle this).
- [ ] CoreDesktop's PLAN.md still plans to merge Pop!_OS support into its
`configure` and archive this repo ("Merge Pop!_OS support into
configure"). Update it there to say this project stays separate.
## Pop!_OS-specific
- [ ] The manual checks in [TEST.md](TEST.md) on a real Pop!_OS 24.04 machine,
+3 -3
View File
@@ -127,18 +127,18 @@ restic snapshots
opencode, Hermes and Cline Desktop run in Anthropic's sandbox runtime (srt), which uses bubblewrap. In the sandbox, an agent:
- can change files only in the folder you start it in (plus its own settings, /tmp and a few package caches), so start it from a project folder
- can't read your SSH keys, keyrings, password managers, browser profiles, Evolution's mail, calendars and contacts, Thunderbird, Element, cloud and Git credentials, or the other agents' logins
- can't read your SSH keys, keyrings, password managers, browser profiles, Evolution's mail, calendars and contacts, Thunderbird, Element, cloud and Git credentials, the other agents' logins, or Federated Connector's settings (your Core's domain and user name, and what the sandbox allows)
- can reach only AI providers and common developer sites: GitHub, Gitea, npm, PyPI, crates.io, RubyGems, the Go module proxy, and Ubuntu's and Pop!_OS' sites
Typing `opencode`, `hermes` or `hermes-agent` runs it in the sandbox: `configure agents` adds a block at the end of ~/.bashrc that puts `sandbox/bin` first on PATH. To run one without the sandbox, type `unsandboxed opencode`. Claude Code uses its own built-in sandbox, also on bubblewrap, for every command it runs, which `configure agents` turns on (see `/sandbox` inside Claude). If you had no Claude Code settings, it also adds notifications for when Claude needs you and when it's done.
If Hermes' gateway is set up as a service, `configure agents` runs it in the sandbox too, and lets it reach the Matrix server in Hermes' settings. If Cline Desktop is installed, its entry in the app library opens it in the sandbox.
If Hermes' gateway is set up as a service, `configure agents` runs it in the sandbox too. Hermes can change its own settings from inside the sandbox, so the Matrix server they name isn't trusted on its own: `configure hermes` asks whether it's your server and may be reached, and keeps your answer in `~/.config/federated-connector/sandbox/hermes.json`, which no sandbox can read or write. For other messaging services, add their domains to that file as shown below. If Cline Desktop is installed, its entry in the app library opens it in the sandbox.
srt needs Node.js 22.12 or later, and Pop!_OS 24.04's is older. Unless a new enough one is installed already, `configure agents` downloads the current LTS from nodejs.org into `~/.local/share/federated-connector/node`, checks it against the SHA-256 sums nodejs.org publishes, and uses it only for srt.
Ubuntu 24.04 lets only programs AppArmor allows make the user namespaces bubblewrap needs. If that stops the sandbox here, `configure agents` offers to add an AppArmor profile for `/usr/bin/bwrap` (`/etc/apparmor.d/federated-connector-bwrap`), as Ubuntu suggests.
To allow more, put a file in the same format as `sandbox/config/base.json` in `~/.config/federated-connector/sandbox/`: `base.json` for every agent, or `<agent>.json` for one. Lists in it are added to the built-in ones. Domains in `FEDERATED_SANDBOX_DOMAINS` (space-separated) are allowed too.
To allow more, put a file in the same format as `sandbox/config/base.json` in `~/.config/federated-connector/sandbox/`: `base.json` for every agent, or `<agent>.json` for one. Lists in it are added to the built-in ones.
## Where things are
+15 -9
View File
@@ -123,32 +123,38 @@ claude_notifications() {
# Hermes' gateway acts on messages from outside this machine, so it runs in
# the sandbox too: a systemd drop-in starts it through sandbox/bin/hermes. It
# also needs to reach the Matrix server in Hermes' settings, which differs on
# each machine; for other messaging services, add their domains to
# each machine. Hermes can change those settings itself, so the server isn't
# allowed from them; configure hermes asks you (see sandbox/hermes-homeserver.sh).
# For other messaging services, add their domains to
# ~/.config/federated-connector/sandbox/hermes.json.
GATEWAY_UNIT="$HOME/.config/systemd/user/hermes-gateway.service"
GATEWAY_DROPIN="$GATEWAY_UNIT.d/federated-connector-sandbox.conf"
source "$CONNECTOR/sandbox/hermes-homeserver.sh"
gateway_dropin() {
local homeserver
homeserver="$(sed -nE "s#^MATRIX_HOMESERVER=[\"']?https?://([^/:\"']+).*#\1#p" "$HOME/.hermes/.env" 2> /dev/null | head -n 1)"
cat << EOF
# Written by Federated Connector (configure agents): run Hermes' gateway in the sandbox
[Service]
Environment="FEDERATED_SANDBOX_DOMAINS=$homeserver"
ExecStart=
ExecStart=$SANDBOX_BIN/hermes gateway run
EOF
}
gateway_ok() {
[ ! -f "$GATEWAY_UNIT" ] || [ "$(cat "$GATEWAY_DROPIN" 2> /dev/null)" = "$(gateway_dropin)" ]
[ ! -f "$HERMES_GATEWAY_UNIT" ] || [ "$(cat "$HERMES_GATEWAY_DROPIN" 2> /dev/null)" = "$(gateway_dropin)" ]
}
sandbox_gateway() {
gateway_ok && return 0
mkdir -p "$(dirname "$GATEWAY_DROPIN")" && gateway_dropin > "$GATEWAY_DROPIN" \
local homeserver
if ! gateway_ok; then
hermes_carry_over_homeserver
mkdir -p "$(dirname "$HERMES_GATEWAY_DROPIN")" && gateway_dropin > "$HERMES_GATEWAY_DROPIN" \
&& systemctl --user daemon-reload || return 1
echo "Hermes' gateway runs in the sandbox (from its next start)."
fi
[ -f "$HERMES_GATEWAY_UNIT" ] || return 0
homeserver="$(hermes_homeserver)"
if [ -n "$homeserver" ] && ! hermes_homeserver_allowed "$homeserver"; then
echo "Hermes' settings name the Matrix server $homeserver, which its gateway can't reach until you allow it: configure hermes"
fi
}
# Cline Desktop is opened from the app menu, so an entry of the same name in
+38 -3
View File
@@ -7,17 +7,29 @@ TITLE="Hermes Agent"
DESCRIPTION="Choose a model provider and tools"
source "$CONNECTOR/configure.d/lib/agents.sh"
source "$CONNECTOR/sandbox/hermes-homeserver.sh"
is_installed() {
agent_installed hermes
}
# Signed in with OAuth (e.g. Nous Portal), or an API key is set
is_configured() {
[ -s "$HOME/.hermes/auth.json" ] || grep -qE '^[A-Z_]*API_KEY=.+' "$HOME/.hermes/.env"
has_provider() {
[ -s "$HOME/.hermes/auth.json" ] || grep -qE '^[A-Z_]*API_KEY=.+' "$HERMES_ENV" 2> /dev/null
}
run_configure() {
# The Matrix server in Hermes' settings that its sandbox may not reach yet
pending_homeserver() {
local host
host="$(hermes_homeserver)"
[ -n "$host" ] && ! hermes_homeserver_allowed "$host" && echo "$host"
}
is_configured() {
has_provider && [ -z "$(pending_homeserver)" ]
}
choose_provider() {
echo " 1) Nous Portal (one sign-in covers the model, web search, images and more)"
echo " 2) Another provider (OpenRouter, OpenAI, Anthropic or your own endpoint)"
local choice
@@ -28,3 +40,26 @@ run_configure() {
*) echo "Choose 1 or 2."; return 1 ;;
esac
}
# Hermes can name a Matrix server in its settings from inside its sandbox, so
# its gateway reaches only one you've said yes to here
allow_homeserver() {
local host
host="$(pending_homeserver)" || return 0
echo "Hermes' settings say its gateway talks to the Matrix server $host."
echo "Hermes can change those settings itself, so it can't reach a server until you allow it."
if confirm "Is $host your Matrix server, and may Hermes reach it?"; then
hermes_allow_homeserver "$host" || return 1
echo "Hermes can reach $host. Restart its gateway to use it: systemctl --user restart hermes-gateway"
else
echo "Hermes can't reach $host. If you didn't set it, check MATRIX_HOMESERVER in $HERMES_ENV."
fi
}
run_configure() {
# Only the server is new: don't ask about the provider again
if ! has_provider || [ -z "$(pending_homeserver)" ]; then
choose_provider || return 1
fi
allow_homeserver
}
+3 -2
View File
@@ -14,9 +14,10 @@ AGENT_DIRS="$HOME/.local/bin:$HOME/.opencode/bin:$HOME/.hermes/bin:/usr/local/bi
# The real command for an agent: the first on PATH, or in AGENT_DIRS, that
# isn't in sandbox/bin
agent_path() {
local dir bin_dir IFS=:
local dir bin_dir search="$PATH:$AGENT_DIRS" IFS=:
bin_dir="$(realpath "$SANDBOX_BIN" 2> /dev/null)"
for dir in $PATH:$AGENT_DIRS; do
# Split one variable: the ":" between two would join their neighbouring folders
for dir in $search; do
[ -n "$dir" ] && [ -d "$dir" ] || continue
[ "$(realpath "$dir")" = "$bin_dir" ] && continue
if [ -x "$dir/$1" ] && [ ! -d "$dir/$1" ]; then
+3 -2
View File
@@ -2,13 +2,14 @@
#
# Purpose : Edit JSON settings files for configure.d items. Source this file.
# Edit a JSON file in place with jq, creating it from $2 if it's missing.
# Edit a JSON file in place with jq, creating it from $2 if it's missing or
# empty (jq reads no JSON from an empty file, and would write nothing back).
# Leaves the file alone if it isn't valid JSON or jq fails.
edit_json() {
local file="$1" empty="$2" tmp
shift 2
mkdir -p "$(dirname "$file")" || return 1
[ -f "$file" ] || echo "$empty" > "$file"
[ -s "$file" ] || echo "$empty" > "$file"
tmp="$(mktemp "$file.XXXXXX")" || return 1
if jq "$@" "$file" > "$tmp"; then
mv -f "$tmp" "$file"
+10 -6
View File
@@ -12,9 +12,7 @@
# The config is sandbox/config/base.json, then sandbox/config/<agent>.json,
# then your own ~/.config/federated-connector/sandbox/base.json and
# <agent>.json, in the same format. Later files add to the lists in earlier
# ones. Domains in FEDERATED_SANDBOX_DOMAINS (space-separated) are allowed too;
# `configure agents` uses it for Hermes' gateway, whose messaging server
# differs on each machine.
# ones.
# Wrapped in { ...; exit; } so bash reads the whole script up front; update
# replaces this file (git pull) while agents are running.
@@ -51,6 +49,13 @@ case "$agent" in
*) profile="$agent" ;;
esac
# Hermes' gateway, started by a drop-in from before the Matrix server it may
# reach moved to hermes.json: carry that server over
if [ "$profile" = hermes ] && [ -n "$FEDERATED_SANDBOX_DOMAINS" ]; then
source "$SANDBOX/hermes-homeserver.sh"
hermes_carry_over_homeserver &> /dev/null
fi
# Cline Desktop is a window, usually opened from the app menu in your home
# directory, so it always starts in ~/Projects and can change projects there.
# Its profile hides /run/user, where your session's D-Bus and keyring sockets
@@ -109,9 +114,8 @@ done
# Outside the sandbox's writable paths, so the agent can't change its own rules
settings="$SETTINGS_DIR/$agent.$$.json"
if ! jq -s --arg domains "$FEDERATED_SANDBOX_DOMAINS" --arg socket "$gui_socket" \
"$MERGE"' | .network.allowedDomains += ($domains | split(" ") | map(select(. != "")))
| if $socket != "" then .filesystem.allowRead += [$socket] else . end' \
if ! jq -s --arg socket "$gui_socket" \
"$MERGE"' | if $socket != "" then .filesystem.allowRead += [$socket] else . end' \
"${configs[@]}" > "$settings"; then
echo "Couldn't read the sandbox config: ${configs[*]}"
exit 1
+1
View File
@@ -67,6 +67,7 @@
"~/.var/app",
"~/.davfs2",
"~/.winboat",
"~/.config/federated-connector",
"~/.claude",
"~/.claude.json",
"~/.hermes",
+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
#
# Purpose : The Matrix server Hermes' gateway talks to, and whether you've let
# its sandbox reach it. Source this file; used by configure agents,
# configure hermes and sandbox/agent. Needs CONNECTOR.
#
# Hermes' settings (~/.hermes/.env) name the server, but Hermes can change them
# from inside its sandbox, so they say only what Hermes wants to reach. The
# server it may reach is in your own hermes.json, which no sandbox can write
# (or read); configure hermes asks you before adding it there.
HERMES_ENV="$HOME/.hermes/.env"
HERMES_SANDBOX_CONF="$HOME/.config/federated-connector/sandbox/hermes.json"
HERMES_GATEWAY_UNIT="$HOME/.config/systemd/user/hermes-gateway.service"
HERMES_GATEWAY_DROPIN="$HERMES_GATEWAY_UNIT.d/federated-connector-sandbox.conf"
# A plain host name or IPv4 address, so it can't be a wildcard or carry
# characters that would change what a terminal shows when it's asked about
hermes_valid_host() {
[[ "$1" =~ ^[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?$ ]]
}
# The host in MATRIX_HOMESERVER, e.g. matrix.example.org, or nothing
hermes_homeserver() {
local host
host="$(sed -nE "s#^MATRIX_HOMESERVER=[\"']?https?://([^/:\"']+).*#\1#p" "$HERMES_ENV" 2> /dev/null | head -n 1)"
hermes_valid_host "$host" && echo "$host"
}
# hermes_homeserver_allowed HOST: true if Hermes' sandbox may reach HOST
hermes_homeserver_allowed() {
[ -n "$1" ] && jq -e --arg host "$1" '(.network.allowedDomains // []) | index($host) != null' \
"$HERMES_SANDBOX_CONF" > /dev/null 2>&1
}
# hermes_allow_homeserver HOST: let Hermes' sandbox reach HOST
hermes_allow_homeserver() {
source "$CONNECTOR/configure.d/lib/json.sh"
edit_json "$HERMES_SANDBOX_CONF" '{}' --arg host "$1" \
'.network.allowedDomains = ((.network.allowedDomains // []) - [$host] + [$host])'
}
# The gateway's drop-in used to allow it whatever server Hermes' settings
# named, through FEDERATED_SANDBOX_DOMAINS. Carry over the server an old
# drop-in allows, so a gateway that works keeps working until configure agents
# rewrites the drop-in without it. The drop-in is read, not the variable: the
# sandbox can't write the drop-in, but an agent's children inherit the variable.
hermes_carry_over_homeserver() {
local host
[ -f "$HERMES_GATEWAY_DROPIN" ] || return 0
host="$(sed -nE 's#^Environment="?FEDERATED_SANDBOX_DOMAINS=([^" ]*)"?$#\1#p' "$HERMES_GATEWAY_DROPIN" | head -n 1)"
hermes_valid_host "$host" || return 0
hermes_homeserver_allowed "$host" && return 0
hermes_allow_homeserver "$host"
}
+2 -1
View File
@@ -32,7 +32,8 @@ Each run writes its logs to `smoketest/results/<time>/`, one per scenario, and p
| `20-goa` | `goa-account` with Online Accounts 3.50. It adds Nextcloud and email (quoting a name), adding again changes nothing, and it pauses email and ends the pause. Test a Core takes an unreachable mail server as a sign-in failure, not a wrong password. Removing leaves nothing in the keyring. |
| `30-core-local` | Superpanel's entry, Element's config (in ~/.config, or the Flatpak's folder), and the COSMIC Files sidebar. The sidebar check reads and writes ron's pretty format with network places and escaped names, keeps COSMIC Files' defaults, and leaves a file it can't read alone. Then davfs2's secret, read back. |
| `40-backup` | restic and rclone from apt, with `rclone serve webdav` standing in for Nextcloud and the secrets in the keyring. `system/backup` makes a snapshot that leaves out caches and the install, a file restores from it, and without the passphrase it fails. |
| `50-sandbox` *(all)* | Node.js and srt download and install. A stand-in agent can't read `~/.ssh` or write outside its project, reaches allowed sites only, and won't start in your home folder. A new bash finds the sandboxed command first. |
| `50-sandbox` *(all)* | Node.js and srt download and install. A stand-in agent can't read `~/.ssh` or Federated Connector's settings, or write outside its project, reaches allowed sites only, and won't start in your home folder. A new bash finds the sandboxed command first. |
| `55-hermes-homeserver` | Hermes' gateway reaches only a Matrix server you've allowed: a server in Hermes' settings is to do until `configure hermes` allows it, a wildcard or escape codes never count, and `configure agents` carries over the server an old drop-in allowed. `edit_json` fills an empty file from its default. |
| `60-packages` *(all)* | davfs2 installs with `mount.davfs` setuid, and `davfs2_ready` fixes one installed without. sshfs' `fusermount3` and smbclient are where `configure storage` expects them, and so is GTK's CUPS print backend. mise installs from its apt repository and a new bash has it. |
## What still needs Pop!_OS
+5
View File
@@ -24,6 +24,7 @@ scenario() {
#!/bin/bash
case "$1" in
read-ssh) cat ~/.ssh/id_test ;;
read-settings) cat ~/.config/federated-connector/core.conf ;;
write-home) echo x > ~/outside ;;
write-here) echo x > ./inside ;;
fetch) curl -sf -o /dev/null --max-time 20 "$2" ;;
@@ -31,7 +32,11 @@ esac
AGENT
chmod +x "$HOME/.local/bin/opencode"
cd "$project" || return
mkdir -p "$HOME/.config/federated-connector"
echo 'CORE_DOMAIN=smoke.invalid' > "$HOME/.config/federated-connector/core.conf"
check_not "it can't read ~/.ssh" "$SANDBOX_BIN/opencode" read-ssh
check "unsandboxed, Federated Connector's settings are readable" "$SANDBOX_BIN/unsandboxed" opencode read-settings
check_not "it can't read Federated Connector's settings" "$SANDBOX_BIN/opencode" read-settings
check_not "it can't write outside its project" "$SANDBOX_BIN/opencode" write-home
check "it can write in its project" "$SANDBOX_BIN/opencode" write-here
check "it reaches an allowed site" "$SANDBOX_BIN/opencode" fetch https://registry.npmjs.org/
@@ -0,0 +1,59 @@
# shellcheck shell=bash
# Scenarios set what the runner and items read
# shellcheck disable=SC2034
DESCRIPTION="Hermes' gateway reaches only a Matrix server you've allowed; edit_json and empty files"
TIER=quick
scenario() {
local out
source "$CONNECTOR/configure.d/30-agents.sh"
source "$CONNECTOR/configure.d/lib/json.sh"
mkdir -p "$HOME/.hermes" "$(dirname "$HERMES_GATEWAY_UNIT")"
step "edit_json"
mkdir -p "$CONF_DIR/sandbox"
: > "$CONF_DIR/sandbox/test.json"
check "it edits an empty file" edit_json "$CONF_DIR/sandbox/test.json" '{}' '.a = 1'
check_eq "from its default" 1 "$(jq .a "$CONF_DIR/sandbox/test.json")"
rm -f "$CONF_DIR/sandbox/test.json"
step "What Hermes' settings name"
echo 'MATRIX_HOMESERVER=https://matrix.smoke.invalid:8448/' > "$HERMES_ENV"
check_eq "the host in MATRIX_HOMESERVER" matrix.smoke.invalid "$(hermes_homeserver)"
echo 'MATRIX_HOMESERVER=https://*.smoke.invalid' > "$HERMES_ENV"
check_eq "not a wildcard" "" "$(hermes_homeserver)"
printf 'MATRIX_HOMESERVER=https://evil\033[2Jhost\n' > "$HERMES_ENV"
check_eq "not escape codes" "" "$(hermes_homeserver)"
step "configure hermes asks before it's reached"
source "$CONNECTOR/configure.d/33-hermes.sh"
echo 'MATRIX_HOMESERVER=https://matrix.smoke.invalid' > "$HERMES_ENV"
echo 'OPENROUTER_API_KEY=x' >> "$HERMES_ENV"
check_not "a server not allowed yet isn't" hermes_homeserver_allowed matrix.smoke.invalid
check_eq "it's to do for that server" matrix.smoke.invalid "$(pending_homeserver)"
check_not "Hermes is to do" is_configured
check "run_configure asks only about the server" run_configure
check "the server is allowed" hermes_homeserver_allowed matrix.smoke.invalid
check "Hermes is done" is_configured
echo 'MATRIX_HOMESERVER=https://other.smoke.invalid' > "$HERMES_ENV"
check_not "a server Hermes names later isn't allowed" hermes_homeserver_allowed other.smoke.invalid
step "The gateway's drop-in"
# No systemd user manager in a container
systemctl() { :; }
rm -f "$HERMES_SANDBOX_CONF"
touch "$HERMES_GATEWAY_UNIT"
mkdir -p "$(dirname "$HERMES_GATEWAY_DROPIN")"
printf '[Service]\nEnvironment="FEDERATED_SANDBOX_DOMAINS=matrix.smoke.invalid"\nExecStart=\nExecStart=x\n' > "$HERMES_GATEWAY_DROPIN"
check_not "an old drop-in isn't ok" gateway_ok
out="$(sandbox_gateway 2>&1)"
check "the server an old drop-in allowed is carried over" hermes_homeserver_allowed matrix.smoke.invalid
check "the new drop-in is ok" gateway_ok
check_not "it allows no domains itself" grep -q FEDERATED_SANDBOX_DOMAINS "$HERMES_GATEWAY_DROPIN"
check "it says the server Hermes names now needs allowing" grep -q "other.smoke.invalid.*configure hermes" <<< "$out"
printf '[Service]\nEnvironment="FEDERATED_SANDBOX_DOMAINS=*"\n' > "$HERMES_GATEWAY_DROPIN"
rm -f "$HERMES_SANDBOX_CONF"
hermes_carry_over_homeserver
check_not "a wildcard isn't carried over" test -s "$HERMES_SANDBOX_CONF"
rm -rf "$HERMES_GATEWAY_UNIT" "$HERMES_GATEWAY_UNIT.d" "$HOME/.hermes"
}