From 2249251895a09827bf271c9d5f01e187659762dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=8D=9A=E4=BB=81=28Buo-ren=20Lin=29?= Date: Wed, 10 Apr 2019 17:35:42 +0800 Subject: snap: Support canonical config paths, fixes #1403 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch supports canonical config paths by the help of the `personal-files` and the `system-files` security confinement interfaces. Signed-off-by: ๆž—ๅšไป(Buo-ren Lin) --- snap/local/launchers/glances-launch | 26 ++++++++++++++++++++++++++ snap/snapcraft.yaml | 19 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100755 snap/local/launchers/glances-launch (limited to 'snap') diff --git a/snap/local/launchers/glances-launch b/snap/local/launchers/glances-launch new file mode 100755 index 00000000..2b79fca2 --- /dev/null +++ b/snap/local/launchers/glances-launch @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# This is the maintainence launcher for the snap, make necessary runtime +# environment changes to make the snap work here. You may also insert +# security confinement/deprecation/obsoletion notice of the snap here. +set \ + -o errexit \ + -o errtrace \ + -o nounset \ + -o pipefail + +# Use user's real home directory for canonical configuration path access +HOME="$( + getent passwd "${USER}" \ + | cut --delimiter=: --fields=6 +)" + +# Use snap's own folder for cache directory +declare XDG_CACHE_HOME +mkdir \ + --parents \ + "${SNAP_USER_DATA}"/.cache +XDG_CACHE_HOME="${SNAP_USER_DATA}"/.cache +export XDG_CACHE_HOME + +# Finally run the next part of the command chain +exec "${@}" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index eb2f5ee1..4cb8a959 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -12,7 +12,9 @@ confinement: strict apps: glances: - command: bin/glances + command: > + bin/glances-launch + $SNAP/bin/glances plugs: - network - system-observe @@ -27,6 +29,16 @@ apps: LANG: C.UTF-8 LC_ALL: C.UTF-8 +plugs: + home-glances-config: + interface: personal-files + read: + - $HOME/.config/glances/glances.conf + etc-glances-config: + interface: system-files + read: + - /etc/glances/glances.conf + parts: glances: plugin: python @@ -50,3 +62,8 @@ parts: source: https://github.com/docker/docker-py.git source-tag: '3.7.0' source-depth: 1 + launchers: + source: snap/local/launchers + plugin: dump + organize: + '*': bin/ -- cgit v1.2.3