Skip to content

fix(snap): isolate CLI XDG paths from host environment#1995

Open
krishicks wants to merge 1 commit into
mainfrom
hicks/push-ylvnwszqszts
Open

fix(snap): isolate CLI XDG paths from host environment#1995
krishicks wants to merge 1 commit into
mainfrom
hicks/push-ylvnwszqszts

Conversation

@krishicks

Copy link
Copy Markdown
Collaborator

Summary

The Ubuntu Snap release canary is failing because GitHub-hosted runners set XDG_CONFIG_HOME=/home/runner/.config, and the strict OpenShell snap currently honors that host path. As a result, openshell gateway add tries to persist gateway metadata under /home/runner/.config/openshell/... instead of the snap-owned user directory, and strict snap confinement blocks the write.

The snap should set its user-facing app XDG paths explicitly to snap-owned locations under $SNAP_USER_COMMON, so host-defined XDG_* variables cannot redirect CLI or TUI state outside the snap sandbox.

The docs update also removes stale --classic Snap install examples, since the OpenShell snap is strict-confined rather than classic-confined.

Related Issue

Changes

  • Set snap-owned XDG config, data, and state paths for the CLI and TUI apps so host-defined XDG_* variables cannot point OpenShell outside the snap user directory.

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)
  • bash tasks/scripts/test-packaging-assets.sh

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

The Ubuntu Snap release canary is failing because GitHub-hosted runners set
`XDG_CONFIG_HOME=/home/runner/.config`, and the strict OpenShell snap currently
honors that host path. As a result, `openshell gateway add` tries to persist
gateway metadata under `/home/runner/.config/openshell/...` instead of the
snap-owned user directory, and strict snap confinement blocks the write.

The snap should set its user-facing app XDG paths explicitly to snap-owned
locations under `$SNAP_USER_COMMON`, so host-defined `XDG_*` variables cannot
redirect CLI or TUI state outside the snap sandbox.

The docs update also removes stale `--classic` Snap install examples, since the
OpenShell snap is strict-confined rather than classic-confined.

Signed-off-by: Kris Hicks <khicks@nvidia.com>
@github-actions

Copy link
Copy Markdown

Comment on lines +80 to +82
assert_occurrences "$snapcraft" 'XDG_CONFIG_HOME: "$SNAP_USER_COMMON/xdg-config"' 2
assert_occurrences "$snapcraft" 'XDG_DATA_HOME: "$SNAP_USER_COMMON/xdg-data"' 2
assert_occurrences "$snapcraft" 'XDG_STATE_HOME: "$SNAP_USER_COMMON/xdg-state"' 2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I asked in #1972 what is the purpose of testing something that we define ourselves?

Comment thread snapcraft.yaml
Comment on lines +65 to +68
environment:
XDG_CONFIG_HOME: "$SNAP_USER_COMMON/xdg-config"
XDG_DATA_HOME: "$SNAP_USER_COMMON/xdg-data"
XDG_STATE_HOME: "$SNAP_USER_COMMON/xdg-state"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any preference on these directories vs those from #1972?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants