Interfaces

overview for users for app developers

A confined snap gets permissions only through interfaces, a plug on the snap and a slot on the system or another snap joined by a connection, and three parties decide whether that connection exists.

On the map: the gatehouse in the west wall

▶ Watch this deck — 6 scenes, ~4 min

01 Plugs, slots, connections

INTERFACES photo-editor, confinededitor homenetworkcameraplugs: I would like these system :cameraa slot: I provide it other snaps can offer slots too a connectioncamera rules join the snap's profiles over two hundred interfaces, each with its own rules and security policy
The photo-editor snap, confined, with home, network and camera plugs on its border; the system's camera slot; a connection from the camera plug to the slot adds camera rules to the snap's profiles

A snap declares a plug, the system or another snap offers a slot, and a connection joins them. Only a connected plug grants anything.

The photo editor wants your pictures, the network and, now and then, the camera. Confined, it can reach none of them on its own. Each of those is a separate interface. The snap declares a plug for each: I'd like the camera. The system offers a matching slot: I provide the camera. Other snaps can offer slots too. Only when a connection joins the plug to the slot does snapd add the camera rules to the photo editor's profiles. snapd knows over two hundred interfaces, each with its own rules and its own security policy.

02 Who decides

WHO DECIDES photo-editor:cameraone plug 1 · the developerdeclares the plug when building 2 · the rulesbase declaration · snap-declaration network, home: yes · camera: waits 3 · yousnap connect · snap disconnect the snap can ask whether a plug is connected, but cannot connect it
Three parties around the photo-editor camera plug: the developer at build time, the rules in the base declaration and snap-declaration, and the user with snap connect and disconnect; the snap itself can only ask

The developer declares plugs at build time; the base declaration and the store's snap-declaration set the rules; the user connects and disconnects. A snap can ask with snapctl is-connected but cannot connect itself.

So who decides that the photo editor gets the camera? Three parties, each at a different moment. The developer declares the plug when building the snap; without a plug, nothing can connect. Then the rules: the base declaration built into snapd, which a store snap-declaration can override, says whether the plug may be installed and whether it connects by itself. On a laptop, network and home do, and the camera doesn't. Then you, with snap connect and snap disconnect. The snap has no say: snapctl can ask whether a plug is connected, but can't connect one.

03 Where to go from here general version

ROADS Interfaces For userslist, connect, disconnect For developersdeclaring plugs and slots Policythe rules themselves Implementationrepository and backends Confinementthe sandbox a connection opens Interface families: every interface, in seven groupshomenetworkcontent
Roads from interfaces: for users, for developers, policy, implementation, confinement and the interface families with home, network and content

For users, for developers, the policy, the implementation, confinement, and every interface in seven families.

Plugs, slots, connections and three parties who decide. Here's where each part is explained. For users, there's listing, connecting and disconnecting. For developers, declaring plugs and slots in snap.yaml. The policy district holds the rules themselves, and the implementation deck shows the repository and the backends. Confinement shows the sandbox a connection opens. And every interface has a place in one of seven families, with home, network and content in decks of their own.

04 Where to go from here for users in place of the general version

ROADS · FOR USERS InterfacesFor userslist, connect, disconnect, remembered homenetwork AppArmor promptingbe asked before a file opens Interface familiesevery interface and what it allows the developer and implementation decks are optional reading
Roads for a snap user: the users' deck, then home and network, AppArmor prompting and the interface families

For a user: the users' deck, home and network, AppArmor prompting, and the interface families.

As a snap user, start with the users' deck: listing connections, connecting and disconnecting, and what snapd remembers when you do. Then the two interfaces you'll meet on every desktop, home and network. If you'd rather be asked before an app opens a file, AppArmor prompting is in the desktop district. And the interface families list every interface, with what each one lets a snap do. The developer and implementation decks are there if you're curious.

05 Where to go from here for app developers for Ubuntu Core developers in place of the general version

ROADS · FOR DEVELOPERS InterfacesFor developersplugs, slots, attributes, auto-connection Policythe rule that decides contentshared runtimes and themes Interface familiesevery interface Interface hookscheck a connection before it is made Confinementwhat a denial means
Roads for a developer: the developers' deck, policy, content, the interface families, interface hooks and confinement

For a developer: the developers' deck, policy, content, the interface families, interface hooks and confinement.

As a developer, start with the developers' deck: declaring plugs and slots in snap.yaml, attributes, and which plugs connect by themselves. The policy district explains those rules, and how to read the one that decides. Content is the interface you'll most likely use to share runtimes and themes. The interface families list every interface by what it touches. Interface hooks let a snap check a connection before it's made. And confinement explains the denials you'll see while you get the plug list right.

06 Where to go from here for snapd developers in place of the general version

ROADS · FOR SNAPD DEVELOPERS InterfacesImplementationrepository · eleven backends · the connect task Policy: evaluation, when askedone rule decides; the interface manager asks The overlordchanges and tasks Sandbox internals · hotplugmount profiles at runtime · slots that come and go Classificationall interfaces by how they are built
Roads for a snapd developer: implementation, policy, the overlord, sandbox internals with hotplug, and the classification of interfaces

For a snapd developer: implementation, policy, the overlord, sandbox internals and hotplug, and the classification of interfaces.

As a snapd developer, go straight to the implementation deck: the repository, the eleven security backends and the connect task. Then the policy district, for how one rule decides and where the interface manager asks. The overlord shows the changes and tasks around a connection. Sandbox internals show how a mount profile changes while an app runs, and how hotplug slots come and go. And the classification groups all the interfaces by how they're built.

Read more

Terms

TermMeaning
Interfacea named kind of access, such as camera or network, with its own rules and security policy
Pluga snap's request for an interface; it has a name, which defaults to the interface name
Slotan offer of an interface, by the system or by another snap
Connectiona plug joined to a slot; only then does the plug grant anything
Auto-connectiona connection snapd makes by itself when a snap is installed or refreshed, if the rules allow it
System slota slot of the system, shown as :<name> in snap connections

Who decides, and when

PartyWhenHow
The developerwhen building the snapdeclares plugs and slots; a plug that is not declared cannot be connected
snapd and the storeat install, refresh and connectionthe base declaration built into snapd, replaced per interface by a rule in the store's snap-declaration for that snap
The device brand (Ubuntu Core)before the device is seeded, and in a remodelthe gadget snap's connection list, checked against the connection rules
The user or administratorany timesnap connect, snap disconnect; a disconnected auto-connection is remembered
The snap itselfany timecan only ask: snapctl is-connected <plug or slot>

Auto-connection of a few common interfaces

InterfaceAuto-connects on a classic desktopNote
networkyes
homeyesnot on Ubuntu Core other than Core Desktop; a plug asking to read other users' files is denied
desktop, wayland, x11, openglyesto the system slot
camerano
removable-mediano
snapd-controlnoalso needs a store rule to install

A store rule in a snap's snap-declaration can allow auto-connection of a plug that the base declaration does not auto-connect. Publishers request it on the forum; see the process below.

Further reading

Roads from here

START HERE

  • snapd — back to the overview

INTERFACES AND CONFINEMENT

HOOKS · code snapd runs inside a snap

POLICY · who may install and connect what

DESKTOP · snaps in a user session

SANDBOX INTERNALS · the mount namespace