Click apps started with ubuntu-app-launch (or via aa-exec-click via legacy desktop files) have a number of environment variables set. Eg, for a test app of mine with APP_ID of 'com.ubuntu.developer.jdstrand.click-env_click-env_0.1':
APP_ID=com.ubuntu.developer.jdstrand.click-env_click-env_0.1
__GL_SHADER_DISK_CACHE_PATH=/home/phablet/.cache/com.ubuntu.developer.jdstrand.click-env
LD_LIBRARY_PATH=/opt/click.ubuntu.com/.click/users/phablet/com.ubuntu.developer.jdstrand.click-env/lib/arm-linux-gnueabihf:/opt/click.ubuntu.com/.click/users/phablet/com.ubuntu.developer.jdstrand.click-env/lib
PATH=/opt/click.ubuntu.com/.click/users/phablet/com.ubuntu.developer.jdstrand.click-env/lib/arm-linux-gnueabihf/bin:/opt/click.ubuntu.com/.click/users/phablet/com.ubuntu.developer.jdstrand.click-env:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
QML2_IMPORT_PATH=/opt/click.ubuntu.com/.click/users/phablet/com.ubuntu.developer.jdstrand.click-env/lib/arm-linux-gnueabihf
TMPDIR=/run/user/32011/confined/com.ubuntu.developer.jdstrand.click-env
UBUNTU_APPLICATION_ISOLATION=1
XDG_CACHE_HOME=/home/phablet/.cache
XDG_CONFIG_HOME=/home/phablet/.config
XDG_DATA_DIRS=/opt/click.ubuntu.com/.click/users/phablet/com.ubuntu.developer.jdstrand.click-env:/usr/share
XDG_DATA_HOME=/home/phablet/.local/share
XDG_RUNTIME_DIR=/run/user/32011
For scopes, we should probably do the same thing. I suggest the following:
APP_ID=<apparmor profile name>
LD_LIBRARY_PATH=<click install directory>/lib/$multiarch:<click install directory>/lib
PATH=<click install directory>/lib/$multiarch/bin:<click install directory>:$PATH
UBUNTU_APPLICATION_ISOLATION=1
XDG_DATA_DIRS=<click install directory>:/usr/share
XDG_DATA_HOME=$HOME/.local/share
XDG_RUNTIME_DIR=/run/user/$UID
APP_ID may not strictly be needed since these are scopes and not subject to application lifecycle, etc, but if it is provided developers will have a consistent environment when developing apps and scopes and it might make it easier for them to programmatically determine the location of certain directories, specifically their scope-specific writable area. Eg:
You might also provide an API to determine that. TMPDIR is not listed above, but probably should be since apparmor policy does not allow access to /tmp. If you want to provide that, I suggest:
TMPDIR=/run/user/$UID/confined-scopes/leaf-net/<'name' from click manifest>
Note, 'leaf-net' is used for the same reason here as it is in {HOME}/.local/share/unity-scopes/leaf-net/@{APP_PKGNAME}/ in the policy: to prevent other scope types from having overlapped writable directories which could lead to information disclosure (see bug 1326105 for a description of the attack). 'leaf-net' should be used with scopes that use the ubuntu-scope-network apparmor template and 'leafs-fs' for scopes that use the (currently unavailable) ubuntu-scope-local-content apparmor template.
Click apps started with ubuntu-app-launch (or via aa-exec-click via legacy desktop files) have a number of environment variables set. Eg, for a test app of mine with APP_ID of 'com.ubuntu. developer. jdstrand. click-env_ click-env_ 0.1': com.ubuntu. developer. jdstrand. click-env_ click-env_ 0.1 DISK_CACHE_ PATH=/home/ phablet/ .cache/ com.ubuntu. developer. jdstrand. click-env PATH=/opt/ click.ubuntu. com/.click/ users/phablet/ com.ubuntu. developer. jdstrand. click-env/ lib/arm- linux-gnueabihf :/opt/click. ubuntu. com/.click/ users/phablet/ com.ubuntu. developer. jdstrand. click-env/ lib click.ubuntu. com/.click/ users/phablet/ com.ubuntu. developer. jdstrand. click-env/ lib/arm- linux-gnueabihf /bin:/opt/ click.ubuntu. com/.click/ users/phablet/ com.ubuntu. developer. jdstrand. click-env: /usr/local/ sbin:/usr/ local/bin: /usr/sbin: /usr/bin: /sbin:/ bin PATH=/opt/ click.ubuntu. com/.click/ users/phablet/ com.ubuntu. developer. jdstrand. click-env/ lib/arm- linux-gnueabihf /run/user/ 32011/confined/ com.ubuntu. developer. jdstrand. click-env APPLICATION_ ISOLATION= 1 HOME=/home/ phablet/ .cache HOME=/home/ phablet/ .config DIRS=/opt/ click.ubuntu. com/.click/ users/phablet/ com.ubuntu. developer. jdstrand. click-env: /usr/share HOME=/home/ phablet/ .local/ share DIR=/run/ user/32011
APP_ID=
__GL_SHADER_
LD_LIBRARY_
PATH=/opt/
QML2_IMPORT_
TMPDIR=
UBUNTU_
XDG_CACHE_
XDG_CONFIG_
XDG_DATA_
XDG_DATA_
XDG_RUNTIME_
For scopes, we should probably do the same thing. I suggest the following: PATH=<click install directory> /lib/$multiarch :<click install directory>/lib /lib/$multiarch /bin:<click install directory>:$PATH APPLICATION_ ISOLATION= 1 DIRS=<click install directory> :/usr/share HOME=$HOME/ .local/ share DIR=/run/ user/$UID
APP_ID=<apparmor profile name>
LD_LIBRARY_
PATH=<click install directory>
UBUNTU_
XDG_DATA_
XDG_DATA_
XDG_RUNTIME_
APP_ID may not strictly be needed since these are scopes and not subject to application lifecycle, etc, but if it is provided developers will have a consistent environment when developing apps and scopes and it might make it easier for them to programmatically determine the location of certain directories, specifically their scope-specific writable area. Eg:
my_pkgname = $APP_ID. split(' _')[0] HOME/unity- scopes/ leaf-net/ $my_pkgname
my_writable_dir = $XDG_DATA_
You might also provide an API to determine that. TMPDIR is not listed above, but probably should be since apparmor policy does not allow access to /tmp. If you want to provide that, I suggest: /run/user/ $UID/confined- scopes/ leaf-net/ <'name' from click manifest>
TMPDIR=
Note, 'leaf-net' is used for the same reason here as it is in {HOME}/ .local/ share/unity- scopes/ leaf-net/ @{APP_PKGNAME} / in the policy: to prevent other scope types from having overlapped writable directories which could lead to information disclosure (see bug 1326105 for a description of the attack). 'leaf-net' should be used with scopes that use the ubuntu- scope-network apparmor template and 'leafs-fs' for scopes that use the (currently unavailable) ubuntu- scope-local- content apparmor template.