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
01 Plugs, slots, connections
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
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
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
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
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
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
| Term | Meaning |
|---|---|
| Interface | a named kind of access, such as camera or network, with its own rules and security policy |
| Plug | a snap's request for an interface; it has a name, which defaults to the interface name |
| Slot | an offer of an interface, by the system or by another snap |
| Connection | a plug joined to a slot; only then does the plug grant anything |
| Auto-connection | a connection snapd makes by itself when a snap is installed or refreshed, if the rules allow it |
| System slot | a slot of the system, shown as :<name> in snap connections |
Who decides, and when
| Party | When | How |
|---|---|---|
| The developer | when building the snap | declares plugs and slots; a plug that is not declared cannot be connected |
| snapd and the store | at install, refresh and connection | the 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 remodel | the gadget snap's connection list, checked against the connection rules |
| The user or administrator | any time | snap connect, snap disconnect; a disconnected auto-connection is remembered |
| The snap itself | any time | can only ask: snapctl is-connected <plug or slot> |
Auto-connection of a few common interfaces
| Interface | Auto-connects on a classic desktop | Note |
|---|---|---|
network | yes | |
home | yes | not on Ubuntu Core other than Core Desktop; a plug asking to read other users' files is denied |
desktop, wayland, x11, opengl | yes | to the system slot |
camera | no | |
removable-media | no | |
snapd-control | no | also 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
- All about interfaces: plugs, slots and connections as the documentation explains them.
- Interface auto-connection: when snapd connects a plug by itself.
- Connect interfaces:
snap connections,snap connectandsnap disconnectwith examples. - Supported interfaces: the documentation's list, with an auto-connect column.
- Process for aliases, auto-connections and tracks: how a publisher asks the store for an auto-connection.
Roads from here
START HERE
- snapd — back to the overview
INTERFACES AND CONFINEMENT
- Interfaces for users — what a user sees and does
- Interfaces for snap developers — how a snap developer declares plugs and slots
- How interfaces are implemented — how snapd implements it
- Confinement — the sandbox a connection opens
- Interfaces by classification — every interface grouped by pattern
- The home interface — one interface in detail: home
- The network interface — one interface in detail: network
- The content interface — one interface in detail: content
- Workloads — workloads and why they are not in snapd yet
HOOKS · code snapd runs inside a snap
- Hooks: interface hooks — hooks that run around a connection
POLICY · who may install and connect what
- Interface policy: the questions snapd asks — the rules that decide installation and connection
DESKTOP · snaps in a user session
- AppArmor prompting — being asked before an app opens a file
SANDBOX INTERNALS · the mount namespace
- Hotplug slots — slots that come and go with devices