Skip to content

Commit 32da1c6

Browse files
committed
fix(snap): add documentation of global to per-user enablement migration
Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
1 parent a6782b0 commit 32da1c6

6 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎docs/about/installation.mdx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ systemctl --user enable --now snap.openshell.user-gateway.service
130130

131131
The user gateway is disabled globally by default. The install script enables it only for the user who ran the script. After a direct snap installation, choose one user account to run the gateway and enable it with the command above. Do not enable the gateway for multiple users who may be logged in at the same time: every user gateway binds to `127.0.0.1:17670`, so only one can run on the system at a time.
132132

133+
Older OpenShell snap revisions could enable the user gateway globally, causing it to start for every user. Remove that global enablement once, then enable the gateway from the account that will run it:
134+
135+
```shell
136+
sudo systemctl disable --global snap.openshell.user-gateway.service
137+
systemctl --user enable --now snap.openshell.user-gateway.service
138+
```
139+
140+
The global command prevents automatic activation for other users but does not stop gateways already running in their user sessions. Run the following command from each other affected user's session:
141+
142+
```shell
143+
systemctl --user disable --now snap.openshell.user-gateway.service
144+
```
145+
133146
The snap installs the standalone policy prover as `openshell.prover`. The
134147
`openshell-prover` alias requires Snap Store approval and may not be available.
135148
The prover reads local policy files through the `home` interface and does not

‎install.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,9 @@ Install Docker Engine from a system package or Docker's package repository, then
14941494
warn "restarting the OpenShell gateway to use the refreshed snap; active sandbox sessions will be interrupted"
14951495
as_root snap restart openshell.system-gateway
14961496
else
1497+
# In case refreshing from an old snap which had a globally-enabled user
1498+
# gateway service, globally disable it, then just enable for the target user
1499+
as_root systemctl --global disable snap.openshell.user-gateway.service
14971500
as_target_user systemctl --user daemon-reload
14981501
as_target_user systemctl --user enable --now snap.openshell.user-gateway.service
14991502
if [ "$_existing_snap" = true ]; then

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +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 CLI mTLS bundle does not match the gateway CA, a supervisor is missing the gateway CA, or TLS termination does not match the gateway listener. Workloads and supervisors should not contain a user TLS client certificate or private key.
75-
- Fresh snap installations select `gateway-mode=user`, but the user gateway is globally disabled by default. `install.sh` enables `snap.openshell.user-gateway.service` only for its target user; direct snap installations must select one user and run `systemctl --user enable --now snap.openshell.user-gateway.service` from that user's session. Do not enable it for multiple concurrently logged-in users: every instance binds to `127.0.0.1:17670`, so later instances fail with an address-in-use error. Setting `gateway-mode=user` disables the system gateway without changing any user's service. To change the selected user, disable and stop the current user's unit before enabling the new user's unit. Upgraded installations retain their system-owned state through `openshell.system-gateway`. Existing HTTPS registrations continue to work after the service rename. Follow the published snap installation steps to enroll a new user, replace an old HTTP registration, or change modes safely through the `disable` maintenance state. If `gateway-mode=disable`, no local snap gateway is expected to run.
75+
- Fresh snap installations select `gateway-mode=user`, but the user gateway is globally disabled by default. `install.sh` enables `snap.openshell.user-gateway.service` only for its target user; direct snap installations must select one user and run `systemctl --user enable --now snap.openshell.user-gateway.service` from that user's session. Do not enable it for multiple concurrently logged-in users: every instance binds to `127.0.0.1:17670`, so later instances fail with an address-in-use error. Older snap revisions could leave the unit globally enabled; remove that state with `sudo systemctl disable --global snap.openshell.user-gateway.service`, then disable and stop the service from every other affected user's session. The global command does not stop running user services. Setting `gateway-mode=user` disables the system gateway without changing any user's service. To change the selected user, disable and stop the current user's unit before enabling the new user's unit. Upgraded installations retain their system-owned state through `openshell.system-gateway`. Existing HTTPS registrations continue to work after the service rename. Follow the published snap installation steps to enroll a new user, replace an old HTTP registration, or change modes safely through the `disable` maintenance state. If `gateway-mode=disable`, no local snap gateway is expected to run.
7676
- `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.
7777
- Operator credential retrieval requires direct gateway mTLS, `[openshell.gateway.mtls_auth] operator_enabled = true`, and a verified certificate with exact `OU=operator`. OIDC admin roles and forwarded certificate headers do not grant access. Do not combine the operator certificate with an `Authorization` header. Enabling this role grants gateway-wide administration; never repair a denial by issuing operator certificates to ordinary users. See the published gateway authentication and provider references.
7878
- 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.

‎snapcraft.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ description: |
3333
same time. Every user gateway binds to 127.0.0.1:17670, so only one can
3434
run on the system at a time.
3535
36+
Older OpenShell snap revisions could enable the user gateway globally.
37+
When upgrading such an installation, remove that global enablement so
38+
the gateway does not start automatically for other users:
39+
40+
sudo systemctl disable --global snap.openshell.user-gateway.service
41+
42+
This does not stop gateways already running in other user sessions.
43+
Those users must disable and stop the service from their own sessions.
44+
3645
If the OpenShell snap was installed before Docker was running, its user
3746
service may have hit the systemd start limit. Resolve this from the
3847
affected user's session after Docker is available:

‎tasks/scripts/test-install-sh.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ assert_snap_user_refresh_flow() {
366366
calls="$(cat "$out")"
367367
expected="wait:user-docker
368368
root:snap refresh openshell --channel=latest/stable
369+
root:systemctl --global disable snap.openshell.user-gateway.service
369370
target:systemctl --user daemon-reload
370371
target:systemctl --user enable --now snap.openshell.user-gateway.service
371372
target:systemctl --user restart snap.openshell.user-gateway.service
@@ -384,6 +385,7 @@ assert_snap_install_flow \
384385
1 0 "" \
385386
"wait:user-docker
386387
root:snap install openshell --channel=latest/stable
388+
root:systemctl --global disable snap.openshell.user-gateway.service
387389
target:systemctl --user daemon-reload
388390
target:systemctl --user enable --now snap.openshell.user-gateway.service
389391
wait:user-gateway-listener

‎tasks/scripts/test-packaging-assets.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,12 @@ assert_contains "$snap_install_docs" "systemctl --user reset-failed snap.openshe
233233
assert_contains "$snap_install_docs" "systemctl --user enable --now snap.openshell.user-gateway.service"
234234
assert_contains "$snapcraft" "systemctl --user enable --now snap.openshell.user-gateway.service"
235235
assert_contains "$ROOT/install.sh" "systemctl --user enable --now snap.openshell.user-gateway.service"
236+
assert_contains "$ROOT/install.sh" "systemctl --global disable snap.openshell.user-gateway.service"
236237
assert_contains "$snap_install_docs" 'every user gateway binds to `127.0.0.1:17670`'
237238
assert_contains "$snap_install_docs" "systemctl --user disable --now snap.openshell.user-gateway.service"
238239
assert_contains "$snapcraft" "Every user gateway binds to 127.0.0.1:17670"
240+
assert_contains "$snap_install_docs" "sudo systemctl disable --global snap.openshell.user-gateway.service"
241+
assert_contains "$snapcraft" "sudo systemctl disable --global snap.openshell.user-gateway.service"
239242
for snap_file in "$ROOT/install.sh" "$snapcraft" "$snap_install_docs"; do
240243
assert_not_contains "$snap_file" "snap start --user openshell.user-gateway"
241244
assert_not_contains "$snap_file" "snap restart openshell.user-gateway"

0 commit comments

Comments
 (0)