Skip to content

Commit a67567e

Browse files
authored
fix(snap): require mTLS for the snap gateway (NVIDIA#3726)
* fix(snap): require mTLS for the snap gateway Replace the installer opt-in with an authenticated snap gateway. The wrapper no longer forces plaintext, so the gateway serves TLS from the bundle it already generates in $SNAP_COMMON/tls. The install hook writes a config that enables mTLS user auth instead of unauthenticated access, and a new post-refresh hook migrates the exact legacy default on existing installs. install.sh waits for the gateway, detects whether it serves TLS, copies the client bundle into the target user's snap state directory, and registers the gateway over HTTPS. Older plaintext snap revisions still register over HTTP with a warning. The release canary asserts mTLS auth and HTTPS registration. Signed-off-by: Drew Newberry <[email protected]> * fix(snap): pass config preflight and detect the mTLS gateway reliably An explicit [openshell.gateway.mtls_auth] table fails config preflight, which validates mTLS auth before the local TLS bundle supplies the client CA. Write a default that pins the Docker driver instead; with the wrapper's TLS bundle the gateway requires client certificates and enables mTLS user auth automatically, as the native packages do. The mTLS gateway rejects TLS handshakes without a client certificate, and it still answers plaintext loopback HTTP for sandbox service routing, so the installer could misdetect it as a legacy plaintext gateway. Probe HTTPS with the root-owned client bundle, and treat a gateway as legacy only when a plaintext gRPC Health call succeeds. Signed-off-by: Drew Newberry <[email protected]> * chore(snap): simplify install hook comment Signed-off-by: Drew Newberry <[email protected]> * fix(snap): migrate insecure gateway configs on refresh Signed-off-by: Drew Newberry <[email protected]> * refactor(snap): simplify mTLS detection and config migration Detect the mTLS snap from the installed revision's post-refresh hook instead of probing plaintext gRPC, and drop the scheme global. Remove the installer's pre-hook config fallback, which is dead now that every channel ships the install hook and which wrote the insecure default. Give the install hook a single write path with a simple backup name, and shorten the manual client certificate steps. Signed-off-by: Drew Newberry <[email protected]> * fix(snap): stop keeping a copy of replaced insecure configs Signed-off-by: Drew Newberry <[email protected]> * feat(install): make the snap an opt-in install method Stop selecting the OpenShell snap just because the snap command exists. Linux installs default to the Debian or RPM package; OPENSHELL_INSTALL_METHOD=snap (or deb, rpm) selects the package explicitly. Hosts that already have the OpenShell snap keep refreshing it rather than gaining a second gateway on the same port. The release canary and snap repro script opt in explicitly. Signed-off-by: Drew Newberry <[email protected]> * fix(snap): let the gateway auto-detect its compute driver Signed-off-by: Drew Newberry <[email protected]> * fix(snap): restart the gateway after refresh Published revisions use refresh-mode: endure, and snapd honors the old revision's setting during a refresh, so the plaintext gateway kept running with the migrated config unused until a manual restart. Restart the gateway from the post-refresh hook so the mTLS config takes effect immediately. Signed-off-by: Drew Newberry <[email protected]> * docs(snap): drop refresh notes from the snap description Signed-off-by: Drew Newberry <[email protected]> * docs(snap): trim snap refresh notes from installation docs Signed-off-by: Drew Newberry <[email protected]> --------- Signed-off-by: Drew Newberry <[email protected]>
1 parent f155899 commit a67567e

15 files changed

Lines changed: 404 additions & 189 deletions

File tree

‎.github/workflows/release-canary.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ jobs:
195195
name: Ubuntu Snap with system Docker
196196
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
197197
runs-on: ubuntu-latest
198+
env:
199+
OPENSHELL_INSTALL_METHOD: snap
198200
timeout-minutes: 20
199201
steps:
200202
- name: Install snapd
@@ -232,6 +234,9 @@ jobs:
232234
sudo snap connections openshell | grep -E '^docker +openshell:docker +:docker +'
233235
openshell --version
234236
sudo snap services openshell
237+
sudo journalctl -b -u snap.openshell.gateway.service --no-pager |
238+
grep -F "mTLS user authentication enabled"
239+
openshell gateway list | grep -F "https://127.0.0.1:17670"
235240
openshell status
236241
237242
- name: Create and exercise a sandbox
@@ -262,6 +267,8 @@ jobs:
262267
name: Ubuntu Snap Docker preflight
263268
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
264269
runs-on: ubuntu-latest
270+
env:
271+
OPENSHELL_INSTALL_METHOD: snap
265272
timeout-minutes: 20
266273
steps:
267274
- name: Install snapd

‎architecture/build.md‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -324,24 +324,30 @@ for direct executable installation on every environment. Release Dev and
324324
Release Tag run Ubuntu conformance through the Debian package, while Fedora
325325
continues using direct executable installation until RPM coverage is available.
326326
The release canary separately exercises the public installer on Ubuntu. The
327-
OpenShell Snap requires a compatible, preinstalled non-Snap Docker daemon. Its
328-
positive canary uses system Docker; negative preflight coverage verifies that
329-
the installer rejects both missing Docker and the Docker Snap before installing
330-
OpenShell. Its Debian lane removes snapd before running the installer so Snap
331-
precedence cannot change the package under test.
332-
Explicit release tags and the `pre` alias bypass Snap selection and use the
333-
native Debian or RPM package path even when `snap` is available. The `pre` alias
327+
installer selects the OpenShell Snap only with `OPENSHELL_INSTALL_METHOD=snap`
328+
or when the Snap is already installed; otherwise it uses the native Debian or
329+
RPM package. The Snap requires a compatible, preinstalled non-Snap Docker
330+
daemon. Its positive canary uses system Docker; negative preflight coverage
331+
verifies that the installer rejects both missing Docker and the Docker Snap
332+
before installing OpenShell.
333+
Explicit release tags and the `pre` alias always use the native Debian or RPM
334+
package path. The `pre` alias
334335
checks matching Git tags in version order, then looks up the exact platform
335336
artifact and verifies the release run instead of listing every repository
336337
artifact.
337338

338339
Snapd runs the gateway as a root-owned system service. Its generated client
339-
certificates reside in root-owned snap state and are unavailable to ordinary CLI
340-
users, so the Snap uses plaintext loopback transport and enables unauthenticated
341-
local users by default. Debian and RPM packages instead run systemd user services
342-
and use user-owned mTLS material. Bootstrap creates the default configuration
343-
only when it is missing. Sandbox-to-gateway sessions remain authenticated with
344-
gateway-minted JWTs.
340+
certificates reside in root-owned snap state. The installer copies the client
341+
bundle into the target user's private Snap state and registers the TLS endpoint;
342+
direct Snap installs require the same enrollment. The install and post-refresh
343+
hooks replace configs that explicitly enable plaintext or unauthenticated access
344+
with the secure default. Snap refreshes
345+
restart the gateway so the migrated config takes effect immediately.
346+
347+
Debian and RPM packages instead run systemd user services with user-owned mTLS
348+
material. Sandbox-to-gateway sessions remain authenticated with gateway-minted
349+
JWTs.
350+
345351
The Debian qualification profile keeps candidate-image overrides outside the
346352
operator-owned gateway configuration: it writes a harness-owned file under
347353
`/var/lib/openshell-qualification` and selects it through the packaged systemd

‎docs/about/installation.mdx‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install.sh |
3838
OPENSHELL_VERSION=pre sh
3939
```
4040

41-
The installer checks prerelease tags from newest to oldest, selects an unexpired artifact from a successful release run for the current platform, and downloads only that artifact. Installed packages keep the candidate's exact version, such as `0.1.0-pre.3`. Prerelease tags do not create entries on the GitHub Releases page. On Linux, prereleases and explicit release tags use Debian or RPM packages even if `snap` is installed.
41+
The installer checks prerelease tags from newest to oldest, selects an unexpired artifact from a successful release run for the current platform, and downloads only that artifact. Installed packages keep the candidate's exact version, such as `0.1.0-pre.3`. Prerelease tags do not create entries on the GitHub Releases page. On Linux, prereleases and explicit release tags use Debian or RPM packages.
4242

4343
The rolling [`dev` release](https://github.com/NVIDIA/OpenShell/releases/tag/dev) does not require GitHub authentication:
4444

@@ -86,7 +86,7 @@ The gateway reads `~/.config/openshell/gateway.toml` if it exists, otherwise the
8686

8787
## Linux
8888

89-
The script uses the [Snap](#snap) package when `snap` is available. Otherwise, or when you set `OPENSHELL_VERSION` to a release tag, it installs a Debian package on Debian and Ubuntu or an RPM package on Fedora and RHEL. Linux packages require glibc 2.28 or newer.
89+
The script installs a Debian package on Debian and Ubuntu or an RPM package on Fedora and RHEL. Set `OPENSHELL_INSTALL_METHOD=snap` to install the [Snap](#snap) package instead; hosts that already have the OpenShell snap keep refreshing it. Linux packages require glibc 2.28 or newer.
9090

9191
The gateway runs as a systemd user service at `https://127.0.0.1:17670` and reads `~/.config/openshell/gateway.toml`.
9292

@@ -110,20 +110,22 @@ The snap requires Docker Engine installed from your distribution or Docker's pac
110110
sudo snap install openshell
111111
```
112112

113-
The snap does not migrate existing Debian, RPM, or Homebrew installs. Remove any existing installation first, then rerun the script with `OPENSHELL_ACK_BREAKING_UPGRADE=1`.
113+
The snap does not migrate existing Debian, RPM, or Homebrew installs. Remove any existing installation first, then rerun the script with `OPENSHELL_INSTALL_METHOD=snap OPENSHELL_ACK_BREAKING_UPGRADE=1`.
114114

115-
The gateway runs as a system service at `http://127.0.0.1:17670` and reads `/var/snap/openshell/common/gateway.toml`.
116-
117-
<Warning>
118-
The snap gateway allows unauthenticated access from the local host. Any local user or process can operate it. Do not expose it beyond the local host.
119-
</Warning>
120-
121-
Snap refreshes do not restart the gateway, so active sandboxes keep running. Restart it to pick up a new version:
115+
The gateway runs as a system service at `https://127.0.0.1:17670` and reads `/var/snap/openshell/common/gateway.toml`. It requires a client certificate. The install script copies that certificate to the installing user's Snap state and registers the gateway automatically. If you installed with `sudo snap install openshell`, give each trusted user the certificate and register the gateway from that user's account:
122116

123117
```shell
124-
sudo systemctl restart snap.openshell.gateway
118+
d=~/snap/openshell/common/.local/state/openshell/tls
119+
mkdir -p -m 700 "$d" "$d/client"
120+
sudo install -o "$USER" -m 600 /var/snap/openshell/common/tls/ca.crt "$d/"
121+
sudo install -o "$USER" -m 600 -t "$d/client" \
122+
/var/snap/openshell/common/tls/client/tls.crt /var/snap/openshell/common/tls/client/tls.key
123+
openshell gateway add https://127.0.0.1:17670 --local --name openshell
124+
openshell status
125125
```
126126

127+
Keep the client key private.
128+
127129
To install a locally built snap, connect its interfaces manually:
128130

129131
```shell

‎install.sh‎

Lines changed: 69 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,22 @@ ENVIRONMENT VARIABLES:
6161
OPENSHELL_ACK_BREAKING_UPGRADE
6262
Set to 1 only after backing up and cleaning up a
6363
pre-v0.0.37 or non-snap installation.
64+
OPENSHELL_INSTALL_METHOD
65+
Linux package to install: snap, deb, or rpm. Unset
66+
selects deb or rpm from the host package manager.
6467
6568
NOTES:
6669
When OPENSHELL_VERSION is unset, this resolves the latest tagged release
6770
from ${GITHUB_URL}/releases/latest.
6871
69-
On Linux, the installer uses the OpenShell snap when the snap command is
70-
available and OPENSHELL_VERSION is unset or dev. Snap installs use
71-
latest/stable by default and latest/edge for dev. Explicit release tags
72-
and prereleases use Debian or RPM packages. The OpenShell snap requires a
73-
running Docker Engine installed from a system package or Docker's package
72+
Linux installs the Debian package on amd64/arm64 or the RPM packages on
73+
x86_64/aarch64, depending on the host package manager. Set
74+
OPENSHELL_INSTALL_METHOD=snap to install the OpenShell snap instead; hosts
75+
that already have the OpenShell snap keep refreshing it. Snap installs use
76+
latest/stable by default and latest/edge for dev, and do not support
77+
explicit release tags or prereleases. The OpenShell snap requires a running
78+
Docker Engine installed from a system package or Docker's package
7479
repository. The Docker snap is not currently compatible with OpenShell.
75-
76-
For explicit versions or without snap, Linux installs the Debian package
77-
on amd64/arm64 or the RPM packages on x86_64/aarch64, depending on the
78-
host package manager.
7980
macOS installs the release Homebrew formula on Apple Silicon and starts a
8081
brew services-backed local gateway.
8182
EOF
@@ -658,9 +659,20 @@ local_gateway_endpoint() {
658659
}
659660

660661
linux_package_method() {
662+
case "${OPENSHELL_INSTALL_METHOD:-}" in
663+
snap | deb | rpm)
664+
echo "$OPENSHELL_INSTALL_METHOD"
665+
return 0
666+
;;
667+
'') ;;
668+
*) error "unsupported OPENSHELL_INSTALL_METHOD=${OPENSHELL_INSTALL_METHOD}; use snap, deb, or rpm" ;;
669+
esac
670+
671+
# Keep refreshing an existing snap install instead of adding a second
672+
# gateway on the same port.
661673
case "${OPENSHELL_VERSION:-}" in
662674
'' | dev)
663-
if has_cmd snap; then
675+
if has_cmd snap && snap list openshell >/dev/null 2>&1; then
664676
echo "snap"
665677
return 0
666678
fi
@@ -1220,43 +1232,6 @@ openshell_snap_channel() {
12201232
esac
12211233
}
12221234

1223-
ensure_snap_gateway_config() {
1224-
_config_file="${1:-/var/snap/openshell/common/gateway.toml}"
1225-
1226-
as_root sh -c '
1227-
set -eu
1228-
config_file=$1
1229-
if [ -e "$config_file" ] || [ -L "$config_file" ]; then
1230-
exit 0
1231-
fi
1232-
1233-
config_dir=${config_file%/*}
1234-
mkdir -p "$config_dir"
1235-
umask 077
1236-
temporary_file=$(mktemp "${config_file}.tmp.XXXXXX")
1237-
trap '\''rm -f "$temporary_file"'\'' 0 HUP INT TERM
1238-
1239-
cat >"$temporary_file" <<'\''EOF'\''
1240-
[openshell]
1241-
version = 2
1242-
1243-
[openshell.gateway]
1244-
1245-
[openshell.gateway.auth]
1246-
allow_unauthenticated_users = true
1247-
EOF
1248-
1249-
if ! ln "$temporary_file" "$config_file"; then
1250-
if [ -e "$config_file" ] || [ -L "$config_file" ]; then
1251-
exit 0
1252-
fi
1253-
exit 1
1254-
fi
1255-
rm -f "$temporary_file"
1256-
trap - 0 HUP INT TERM
1257-
' sh "$_config_file"
1258-
}
1259-
12601235
wait_for_docker_daemon() {
12611236
_timeout="${OPENSHELL_INSTALL_DOCKER_TIMEOUT:-30}"
12621237
_elapsed=0
@@ -1280,9 +1255,39 @@ wait_for_docker_daemon() {
12801255
error "Docker daemon did not become reachable within ${_timeout}s"
12811256
}
12821257

1258+
# Copy the snap gateway's client bundle into the target user's snap state
1259+
# directory, where `openshell gateway add --local` imports it. Root only reads
1260+
# the source files; the target user writes the copies into their own home.
1261+
copy_snap_client_bundle() {
1262+
_src="${OPENSHELL_SNAP_TLS_DIR:-/var/snap/openshell/common/tls}"
1263+
_dst="${TARGET_HOME}/snap/openshell/common/.local/state/openshell/tls"
1264+
1265+
as_target_user mkdir -p "${_dst}/client"
1266+
as_target_user chmod 700 "$_dst" "${_dst}/client"
1267+
for _file in ca.crt client/tls.crt client/tls.key; do
1268+
as_root cat "${_src}/${_file}" |
1269+
as_target_user sh -c 'umask 077; cat >"$1"' sh "${_dst}/${_file}"
1270+
as_target_user chmod 600 "${_dst}/${_file}"
1271+
done
1272+
}
1273+
1274+
# Snap revisions that require mTLS ship the post-refresh hook that migrates
1275+
# older plaintext configs.
1276+
snap_gateway_uses_mtls() {
1277+
[ -e "${OPENSHELL_SNAP_DIR:-/snap/openshell/current}/meta/hooks/post-refresh" ]
1278+
}
1279+
12831280
register_snap_gateway() {
12841281
_register_bin="${OPENSHELL_REGISTER_BIN:-/snap/bin/openshell}"
1285-
_endpoint="http://127.0.0.1:${LOCAL_GATEWAY_PORT}"
1282+
1283+
if snap_gateway_uses_mtls; then
1284+
_endpoint="https://127.0.0.1:${LOCAL_GATEWAY_PORT}"
1285+
info "copying the gateway client certificate for ${TARGET_USER}..."
1286+
copy_snap_client_bundle
1287+
else
1288+
_endpoint="http://127.0.0.1:${LOCAL_GATEWAY_PORT}"
1289+
warn "this OpenShell snap revision serves plaintext HTTP without client authentication; any local user can operate the gateway"
1290+
fi
12861291

12871292
if _add_output="$(as_target_user "$_register_bin" gateway add "$_endpoint" --local --name openshell 2>&1)"; then
12881293
[ -z "$_add_output" ] || print_gateway_add_output "$_add_output"
@@ -1304,15 +1309,28 @@ register_snap_gateway() {
13041309
esac
13051310
}
13061311

1312+
# The mTLS gateway rejects TLS handshakes without a client certificate, so
1313+
# probe it with the root-owned client bundle.
13071314
wait_for_snap_gateway_listener() {
13081315
_timeout="${OPENSHELL_INSTALL_GATEWAY_TIMEOUT:-30}"
13091316
_elapsed=0
13101317
_last_output=""
1311-
_probe_url="http://127.0.0.1:${LOCAL_GATEWAY_PORT}/"
1318+
_tls_dir="${OPENSHELL_SNAP_TLS_DIR:-/var/snap/openshell/common/tls}"
1319+
1320+
if snap_gateway_uses_mtls; then
1321+
_probe_url="https://127.0.0.1:${LOCAL_GATEWAY_PORT}/"
1322+
_probe_as=as_root
1323+
set -- --cacert "${_tls_dir}/ca.crt" \
1324+
--cert "${_tls_dir}/client/tls.crt" --key "${_tls_dir}/client/tls.key"
1325+
else
1326+
_probe_url="http://127.0.0.1:${LOCAL_GATEWAY_PORT}/"
1327+
_probe_as=""
1328+
set --
1329+
fi
13121330

13131331
info "waiting for local gateway listener to become reachable..."
13141332
while [ "$_elapsed" -lt "$_timeout" ]; do
1315-
if _last_output="$(curl -sS --max-time 2 -o /dev/null "$_probe_url" 2>&1)"; then
1333+
if _last_output="$($_probe_as curl -sS --max-time 2 "$@" -o /dev/null "$_probe_url" 2>&1)"; then
13161334
info "local gateway listener is reachable"
13171335
return 0
13181336
fi
@@ -1350,13 +1368,12 @@ Install Docker Engine from a system package or Docker's package repository, then
13501368
as_root snap install openshell --channel="$_channel"
13511369
fi
13521370

1353-
ensure_snap_gateway_config
13541371
as_root snap restart openshell.gateway
13551372

13561373
info "installed OpenShell snap from ${_channel}"
1374+
wait_for_snap_gateway_listener
13571375
info "registering local gateway as ${TARGET_USER}..."
13581376
register_snap_gateway
1359-
wait_for_snap_gateway_listener
13601377
OPENSHELL_REGISTER_BIN="/snap/bin/openshell"
13611378
wait_for_local_gateway_status
13621379
}

‎nix/test-guest/scripts/snap-gateway-repro.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ for attempt in $(seq 1 "${attempts}"); do
9999
echo "==> install.sh Snap ${mode} reproduction attempt ${attempt}/${attempts}"
100100
if [ "${mode}" != system-docker ]; then
101101
output=$(mktemp)
102-
if OPENSHELL_VERSION=dev sh "${install_script}" >"${output}" 2>&1; then
102+
if OPENSHELL_INSTALL_METHOD=snap OPENSHELL_VERSION=dev sh "${install_script}" >"${output}" 2>&1; then
103103
echo "install.sh unexpectedly succeeded in ${mode} mode" >&2
104104
cat "${output}" >&2
105105
rm -f "${output}"
@@ -127,7 +127,7 @@ for attempt in $(seq 1 "${attempts}"); do
127127
fi
128128

129129
sandbox="snap-${attempt}-$$"
130-
if ! OPENSHELL_VERSION=dev sh "${install_script}" ||
130+
if ! OPENSHELL_INSTALL_METHOD=snap OPENSHELL_VERSION=dev sh "${install_script}" ||
131131
! sudo snap list openshell >/dev/null ||
132132
! snap info openshell | grep -Eq '^tracking: +latest/edge$' ||
133133
! docker_is_ready ||

‎python/openshell/release_formula_test.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ def test_snap_wrapper_uses_optional_gateway_config_without_generating_toml() ->
155155
'export OPENSHELL_DB_URL="${OPENSHELL_DB_URL:-sqlite:${SNAP_COMMON}/gateway.db?mode=rwc}"'
156156
in wrapper
157157
)
158-
assert 'export OPENSHELL_DISABLE_TLS="${OPENSHELL_DISABLE_TLS:-true}"' in wrapper
158+
assert "OPENSHELL_DISABLE_TLS" not in wrapper
159+
assert (
160+
'export OPENSHELL_LOCAL_TLS_DIR="${OPENSHELL_LOCAL_TLS_DIR:-${SNAP_COMMON}/tls}"'
161+
in wrapper
162+
)
159163
assert (
160164
'exec "${SNAP}/bin/openshell-gateway" --config "$CANONICAL_CONFIG_FILE" "$@"'
161165
in wrapper

‎skills/debug-openshell-cluster/SKILL.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Common findings:
7272
- `No active gateway`: register one with `openshell gateway add <endpoint>`.
7373
- Connection refused: gateway process is not running, service exposure is wrong, or a port-forward/proxy is not active.
7474
- TLS/certificate errors: the endpoint scheme or trust chain is wrong, a local mTLS bundle does not match the gateway CA, or TLS termination does not match the gateway listener.
75+
- A Snap refresh restarts the gateway with its migrated mTLS config. The secure Snap gateway uses `https://127.0.0.1:17670` and requires a client bundle in the user's Snap state. Refresh replaces insecure configs without keeping a copy; follow the published Snap installation steps to re-register an old HTTP client.
7576
- `Unauthenticated` from an edge or OIDC gateway: refresh stored credentials with `openshell gateway login [name]`, then retry. Use `gateway logout` only when intentionally clearing local credentials.
7677
- A direct development endpoint with a private or self-signed certificate can be isolated with `--gateway-endpoint <url> --gateway-insecure`; do not persist or recommend insecure verification for shared gateways.
7778

‎snap/hooks/install‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,34 @@
22
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
# SPDX-License-Identifier: Apache-2.0
44

5+
# Create the mTLS default and replace insecure configs on refresh.
6+
57
set -eu
68

79
config_file="${SNAP_COMMON}/gateway.toml"
8-
if [ -e "$config_file" ] || [ -L "$config_file" ]; then
10+
insecure='^[[:space:]]*(allow_unauthenticated_users|disable_tls)[[:space:]]*=[[:space:]]*true([[:space:]#]|$)'
11+
12+
# Keep secure operator configs, symlinks, and directories. Replace a config
13+
# that explicitly allows plaintext or anonymous access, even if it has other
14+
# edits.
15+
if [ -L "$config_file" ]; then
16+
exit 0
17+
elif [ -f "$config_file" ]; then
18+
grep -Eq "$insecure" "$config_file" || exit 0
19+
echo "openshell: replacing insecure gateway config with the mTLS default" >&2
20+
elif [ -e "$config_file" ]; then
921
exit 0
1022
fi
1123

1224
mkdir -p "$SNAP_COMMON"
1325
umask 077
1426
temporary_file=$(mktemp "${config_file}.tmp.XXXXXX")
1527
trap 'rm -f "$temporary_file"' 0 HUP INT TERM
16-
17-
cat >"$temporary_file" <<'EOF'
28+
cat >"$temporary_file" <<'CONFIG'
1829
[openshell]
1930
version = 2
2031
2132
[openshell.gateway]
22-
23-
[openshell.gateway.auth]
24-
allow_unauthenticated_users = true
25-
EOF
26-
27-
# A hard link publishes the config atomically without replacing a path created
28-
# concurrently. SNAP_COMMON and the temporary file are on the same filesystem.
29-
if ! ln "$temporary_file" "$config_file"; then
30-
if [ -e "$config_file" ] || [ -L "$config_file" ]; then
31-
exit 0
32-
fi
33-
exit 1
34-
fi
35-
rm -f "$temporary_file"
33+
CONFIG
34+
mv -f "$temporary_file" "$config_file"
3635
trap - 0 HUP INT TERM

0 commit comments

Comments
 (0)