Can't use dbus

name: nixwriter
base: core18
version: "2.0.0"
summary: Bootable Linux image writer
description: |
  Create bootable Linux images into flash drives from a simple user interface.

grade: devel
confinement: strict

    interface: dbus
    bus: system
    name: com.gitlab.adnan338.Nixwriter

    source: "."
    plugin: rust
      - libgtk-3-dev

    command: bin/nixwriter
    extensions: [gnome-3-28]
      - dbus-daemon
      - desktop
      - desktop-legacy
      - x11
      - wayland
      - home
      - udisks2
      - block-devices

Hello, I want access to dbus (and udisks2 services) but my app crashes on startup saying:

Failed to register: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type=“method_call”, sender=":1.1140" (uid=1000 pid=148137 comm="/snap/nixwriter/x1/bin/nixwriter " label=“snap.nixwriter.nixwriter (enforce)”) interface=“org.freedesktop.DBus” member=“RequestName” error name="(unset)" requested_reply=“0” destination=“org.freedesktop.DBus” (bus)
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

What does this mean?

Your slot definition says you want to be able to own com.gitlab.adnan338.Nixwriter on the D-Bus system bus.

The error message shows that your program is running as a regular user, so my guess is that it is trying to own the name on the D-Bus session bus. Try changing the slot definition to use bus: session, and see if that clears things up.