"Interfaces: desktop and session"
interface family for users for app developers for snapd developers
Forty-three interfaces for graphical desktops and the user session. Two shapes dominate: classic-only implicit slots standing for one D-Bus session-bus service, and "operating as or interacting with" interfaces whose slot is the system's on classic or an app snap's on Ubuntu Core. Plus the legacy Ubuntu Touch services.
On the map: interfaces district, family row
01 The pattern
Two shapes: a classic-only implicit slot standing for one session-bus service (absent on Ubuntu Core), and "operating as or interacting with", where the slot is the system's on classic or an app snap's on Ubuntu Core. Nearly all policy is D-Bus session-bus AppArmor rules.
The photo editor on your laptop needs a window, sound, your theme, maybe a saved password. Those are services in your desktop session, and this family's forty three interfaces reach them, mostly in two shapes. In the first, the slot exists only on a classic desktop. snapd provides it, and it stands for one service on the D-Bus session bus, like the calendar or the password manager. On Ubuntu Core there's no such slot. In the second shape, the slot is the system's on classic, or an app snap's, like a compositor, on Ubuntu Core. Nearly all the policy is AppArmor rules for the session bus.
02 What a desktop app connects for users in place of the general version
On a desktop, desktop, desktop-legacy, x11 or wayland, opengl, audio-playback and home connect at install. audio-record, password-manager-service, screencast-legacy and cups-control wait for snap connect. On Ubuntu Core home and opengl stay with the system; the desktop, display and audio slots exist only when a snap provides them, and then the store must allow the connection.
Install the photo editor on your laptop, and most of what it asks for is connected straight away: desktop, desktop-legacy, x11 or wayland, opengl, audio-playback and home. snapd provides those slots on a desktop. A few stay disconnected until you decide. audio-record, so the editor can't use the microphone until you say so. The password-manager-service. snap connections shows which is which, and snap connect, naming the snap and the plug, grants one. On an Ubuntu Core device, home and opengl still come from the system, but the desktop, display and audio slots exist only when a snap, such as a compositor, provides them.
03 Same plug, two worlds general version
The same desktop plug gets different policy by slot owner: the system slot on classic means peer=(label=unconfined) plus a classic-only snippet; a shell snap's slot on Ubuntu Core means the slot's label and, by the plug-side rule deny-connection: slot-snap-type: [app], a store rule. wayland and x11 use deny-connection: on-classic: false.
Look at the photo editor's snap.yaml and the plug is just desktop. What changes is who owns the slot. On your laptop the slot is the system's. The connected plug rules name the D-Bus peer as unconfined, plus a snippet not yet ported to snap-provided slots: theme files, notifications, media keys. On Ubuntu Core a shell snap provides the slot. That snap's label goes into the rules instead, the extra snippet is left out, and the plug-side base declaration denies connecting to an app's slot: the store has to allow it. wayland and x11 do the same with deny-connection, on-classic: false.
04 The audio split
pulseaudio granted playback and, on some distributions, recording, and no longer auto-connects. audio-playback has the socket rules and auto-connects on a desktop; audio-record's policy is only a comment: the sound server asks snapd whether it is connected. Recording is a deliberate snap connect.
Say the photo editor can attach a voice note to a picture. Should that mean it can listen? Audio used to be one interface, pulseaudio: playback and, on some distributions, recording. It no longer auto-connects. In its place are two plugs. audio-playback carries the sandbox rules that let the app reach the sound server, and it auto-connects on a desktop. audio-record carries no rules at all. Its policy is a comment saying the audio service will verify that audio-record is connected. The sound server asks snapd before it records for the app. So recording takes a deliberate snap connect.
05 Deny beats allow for app developers for snapd developers
desktop-legacy and unity7 deny reading other snaps' desktop files at priority 0 under the key desktop-file-access. Because an AppArmor deny beats any allow, desktop-launch adds an empty snippet under the same key at priority 100, which replaces those deny rules when it is connected.
desktop-legacy and unity7, which the photo editor may plug, add rules for the directory where snapd exports desktop files. The editor can read its own files there; every other snap's is explicitly denied, to cut noisy denials from xdg libraries. A launcher plugs desktop-launch, and needs to read them all. In AppArmor a deny wins over any allow, so adding allows changes nothing. Instead, desktop-launch registers an empty snippet under the key desktop-file-access, at priority one hundred. The deny rules sit at priority zero under the same key, so when desktop-launch is connected, they're dropped. Without it, nothing changes.
06 An interface with no sandbox rules for app developers for snapd developers
snap-themes-control adds no backend snippets. /v2/accessories/themes gates GET with interfaceOpenAccess and POST with interfaceAuthenticatedAccess plus polkit, both naming the interface. Connected is a capability token. The plug is super-privileged: allow-installation: false.
The photo editor asks for a GTK theme that isn't installed. Something in your session has to notice and install the theme snap, and that something needs snap-themes-control: an interface with no sandbox rules at all. It adds nothing to AppArmor, seccomp, udev or mounts. Its whole effect is inside snapd. The themes endpoint lets a snap with this plug connected check themes, and, as root or through polkit, install them. snapd looks up which snap is calling on its socket and whether that plug is connected. So here, connected is a key, not a rule. Because the key installs snaps, the plug is super-privileged.
07 The legacy shape for Ubuntu Core developers for snapd developers
mir, online-accounts-service and ubuntu-download-manager have a base slot rule deny-connection: true and no deny-auto-connection. Manual snap connect is refused; auto-connection finds no rule and is allowed. By design, and legacy. For unity8 the base plug rule is consulted first and has no connection constraint, so snap connect works.
One shape is left over from Ubuntu Touch: mir, online-accounts-service and ubuntu-download-manager. Their base slot rule is deny-connection true, with no deny-auto-connection. A manual snap connect evaluates the connection rules, and is refused. auto-connection at install evaluates the auto-connection rules, finds none, and treats that as allow. So a snap plugging mir auto-connects to an installed Mir server snap, but can't be connected by hand. For online accounts that's by design: the service itself mediates access. unity8 has the same slot rule, but its plug rule is checked first, so a manual connect is allowed there.
08 Where to go from here
The gatehouse is the overview; the gatekeepers' hall collects the snippets into profiles; the walls apply them; home has its own deck; prompting asks before access; the files, data and snapd's API family is next.
A window, a sound, a theme, and a microphone you switch on yourself. Here's where to go next. The gatehouse is the interfaces overview. The gatekeepers' hall shows how the D-Bus snippets in this family become AppArmor profiles, and the walls show where those profiles apply when the photo editor starts. Home, the one plug almost every desktop app has besides these, has a deck of its own. Prompting shows how home and audio-record can ask you first. And the next family, files, data and snapd's API, has the file access interfaces.
09 All 43 interfaces at a glance
Every interface in the family by connection class: 4 auto-connect, 8 conditionally, 4 auto-connect but need a store rule to connect by hand, 19 by hand, 8 need a store rule to connect; 4 are super-privileged.
All 43 interfaces of the desktop and session family at a glance, sorted by how they get connected. 4 auto-connect on every system: desktop-legacy, gsettings, opengl, unity7. 8 auto-connect under conditions: audio-playback, browser-support, desktop, media-hub, screen-inhibit-control and 3 others. 4 auto-connect, but need a store rule to connect by hand: mir, online-accounts-service, ubuntu-download-manager, unity8. 19 connect by hand with snap connect, which is most of the family. 8 need a store rule even to connect: cups, location-control, location-observe, maliit, storage-framework-service and 3 others. 4, marked with a star, are super-privileged and need a store rule to install. 15, in italics, are Ubuntu Touch era and effectively legacy. Every one of them is in the catalogue below this deck, with what it grants and its rule.
Read more
The three shapes
| Shape | Members | Slot | Connection |
|---|---|---|---|
| One session service, classic only | accounts-service, appstream-metadata, calendar-service, contacts-service, desktop-legacy, desktop-launch, gconf, gsettings, jack1, password-manager-service, pcscd, screencast-legacy, unity7 | the system, on classic only; none on Ubuntu Core | mostly by hand; desktop-legacy, gsettings and unity7 auto-connect |
| Operating as or interacting with | audio-playback, audio-record, cups-control, desktop, pipewire, pulseaudio, screen-inhibit-control, udisks2, upower-observe, wayland, x11 | the system on classic, or an app snap such as a compositor or a sound server | connecting to an app snap's slot needs a store rule (deny-connection: on-classic: false or a plug-side rule) |
| Ubuntu Touch services | location-control, location-observe, maliit, media-hub, mir, online-accounts-service, storage-framework-service, thumbnailer-service, ubuntu-download-manager, unity8, unity8-calendar, unity8-contacts | an app snap | legacy; see below |
What connects on a classic desktop
- At install: desktop, desktop-legacy, x11, wayland, opengl, audio-playback, gsettings, unity7, browser-support (without
allow-sandbox) and home. - By hand: audio-record, pulseaudio, password-manager-service, screencast-legacy, cups-control, gconf, udisks2 and the calendar, contacts and accounts services.
- Only with a store rule: desktop-launch, snap-themes-control, xdg-portal-permission-store and unity8 need one to install (super-privileged plugs);
browser-supportwithallow-sandbox: trueneeds one to connect.
Gotchas
- audio-record grants nothing by itself. It works only together with audio-playback, and only with a sound server that asks snapd whether it is connected.
- password-manager-service cannot isolate one snap's secrets from another's: the policy says so. unity7 and desktop-legacy admit that they allow some input sniffing on the session bus.
- On Ubuntu Core there is no desktop, x11, wayland or audio slot. A kiosk or audio device ships a snap that provides the slot, and connecting to it by hand needs a store rule.
- mir, online-accounts-service and ubuntu-download-manager auto-connect to an installed snap that provides the slot, but refuse
snap connect. Their slot rule hasdeny-connection: trueand nodeny-auto-connection, and auto-connection reads only the auto-connection rules. unity8 has a plug rule that is checked first, so manual connection is allowed (policy/basedeclaration_test.goTestConnection). - cups-control chooses at auto-connection between the system slot and the cups snap's slot, depending on whether the host has
/etc/cups/cupsd.conf. - upower-observe has a slot on Ubuntu Core only when the base contains
/usr/libexec/upowerd.
Further reading
- The desktop interface: what it grants, and its attributes.
- The audio-record interface: how it pairs with audio-playback.
- XDG desktop portals: how a confined desktop app opens files and links through portals.
- Interface auto-connection: which connections are made at install, and how to request more.
- Connect interfaces:
snap connections,snap connectandsnap disconnect.
Roads from here
INTERFACES AND CONFINEMENT
- Interfaces — back to the interfaces overview
- How interfaces are implemented — how the D-Bus snippets become AppArmor profiles
- The home interface — the other plug almost every desktop app has
- Confinement — where the profiles are applied when an app starts
INTERFACE FAMILIES · every interface, grouped by what it touches
- "Interfaces: files, data and snapd's own API" — the next family with the markers that unlock snapd's API
DESKTOP · snaps in a user session
- AppArmor prompting — asking the user before access is granted