Skip to content

Commit

Permalink
snapcraft/wrappers/remote-viewer: do not export XDG_ var
Browse files Browse the repository at this point in the history
The spec [1] contains this:

> If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
> If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.
> If $XDG_STATE_HOME is either not set or empty, a default equal to $HOME/.local/state should be used.

So let's not export those since applications should simply rely on the
default/empty. Exporting those without any corresponding directory caused issue
with `nano` as can be seen in the previous commit.

Also, on a "normal" desktop environment, none of XDG_DATA_HOME, XDG_CONFIG_HOME
and XDG_STATE_HOME are exported:

```
$ env | grep ^XDG_
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
XDG_MENU_PREFIX=gnome-
XDG_SESSION_DESKTOP=ubuntu
XDG_SESSION_TYPE=wayland
XDG_CURRENT_DESKTOP=ubuntu:GNOME
XDG_SESSION_CLASS=user
XDG_RUNTIME_DIR=/run/user/1000
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
```

[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables

Signed-off-by: Simon Deziel <[email protected]>
(cherry picked from commit 1c07fcf)
  • Loading branch information
simondeziel committed Mar 14, 2024
1 parent dcdef06 commit 5178fb4
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions snapcraft/wrappers/remote-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ run_cmd() {
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export HOME="${SNAP_REAL_HOME}"
export USER="${USERNAME}"
[ -z "${XDG_DATA_HOME:-}" ] && export XDG_DATA_HOME="${HOME}/.local/share/"
[ -z "${XDG_CONFIG_HOME:-}" ] && export XDG_CONFIG_HOME="${HOME}/.config/"
[ -z "${XDG_STATE_HOME:-}" ] && export XDG_STATE_HOME="${HOME}/.local/state/"

exec unshare -U -r chroot "/var/lib/snapd/hostfs/" "${CMD}" "$@"
}
Expand Down

0 comments on commit 5178fb4

Please sign in to comment.