Mir-kiosk test - daemon accessing wrong XDG_RUNTIME_DIR

Hi,

I’ve been following along a few mir-kiosk examples from the docks.
I came across a strange issue with this one: https://ubuntu.com/tutorials/wayland-kiosk

I’m working on UC20.

Everything basically works fine, and I get to the final result, except that I cannot get the app to run under the daemon. It works fine in devmode, but as soon as I install it without that it fails to launch, but only as the daemon, if I launch it on the cli it works [ including while in snap run --shell ]

The problem seems to be that when you run it under the daemon, it does this:

Sep 18 17:41:16 ubuntu audit[16225]: AVC apparmor="DENIED" operation="connect" profile="snap.glmark2-test.daemon" name="/run/user/0/wayland-0" pid=16225 comm="glmark2-wayland" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0

You can see it’s trying to access /run/user/0/wayland-0, instead of /run/user/0/snap.glmark2-test/wayland-0

I’m using wayland-launch from https://github.com/MirServer/mir-kiosk-snap-launch.git , so it should work fine, and indeed the symlink and everything is set up correctly, so I know for a fact that the $XDG_RUNTIME_DIR variable is set correctly.
It just seems like $XDG_RUNTIME_DIR is being ignored when the app ix exec by the deamon

snapcraft.yaml looks like this:

name: glmark2-test
version: '0.1'
summary: GLMark2 IoT kiosk test
description: GLMark2 IoT kiosk test, using Wayland
base: core18
confinement: strict
grade: devel

apps:
  glmark2:
    command: wayland-launch $SNAP/usr/bin/glmark2-wayland --fullscreen
    plugs:
    -  opengl
    -  wayland
  daemon:
    command: run-daemon wayland-launch $SNAP/usr/bin/glmark2-wayland --fullscreen
    daemon: simple
    restart-condition: always

environment:
  LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}:${SNAP}/usr/lib/:${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/
  PATH: $SNAP/bin/:$SNAP/usr/bin/:${PATH}
  # Prep EGL
  __EGL_VENDOR_LIBRARY_DIRS: $SNAP/etc/glvnd/egl_vendor.d:$SNAP/usr/share/glvnd/egl_vendor.d
  LIBGL_DRIVERS_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/dri
  LIBVA_DRIVERS_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/dri

layout:
  /usr/share/glmark2:
    bind: $SNAP/usr/share/glmark2


parts:
  glmark2-wayland:
    plugin: nil
    stage-packages:
      - glmark2-wayland
  mesa:
    plugin: nil
    stage-packages:
      - libgl1-mesa-dri
      - libwayland-egl1-mesa
      - libglu1-mesa
  mir-kiosk-snap-launch:
    plugin: dump
    source: https://github.com/MirServer/mir-kiosk-snap-launch.git
    override-build:  $SNAPCRAFT_PART_BUILD/build-with-plugs.sh opengl wayland

If anyone can shed any light on this I’d appreciate it. Thanks!

Cheers,
Just

Ahh - finally realised what was happening here.

It wasn’t that the $XDG_RUNTIME_DIR variable was wrong when the executable was run via the daemon. I suddenly realised that even if the variable was pointing to /run/user/0/wayland-0 instead, that should still work, as that is where the symlink points to, so it must be confinement.

Then I realised that you obviously need to re-specify the plugs for the daemon command too:

apps:
  glmark2:
    command: wayland-launch $SNAP/usr/bin/glmark2-wayland --fullscreen
    plugs:
    -  opengl
    -  wayland
  daemon:
    command: run-daemon wayland-launch $SNAP/usr/bin/glmark2-wayland --fullscreen
    daemon: simple
    restart-condition: always
    plugs:
    -  opengl
    -  wayland

Now it works :slight_smile:

Hopefully this helps someone else.

Cheers, Just

1 Like