Why snaps

the problems snaps were built to solve for everyone

Three problems of traditional packaging explain the three decisions that shape snapd, namely one package for every distribution, a store where the publisher owns the name and signs every file, and confinement by default.

On the map: start here, next to the overview

▶ Watch this deck — 5 scenes, ~4 min

01 Three problems

WHY SNAPS three problems with traditional packaging many distributionsthe same programpackaged again and againat each distribution's pace no direct publishingthe author writes ita packager stands in betweenyou wait for them trust the developera package runs as youwith the whole systemwhoever wrote it snapd: three answers
Three problems of traditional packaging side by side, with one line below saying snapd is the shape of the three answers

One program became many packages; its authors could not publish to you directly; and a package ran with everything your account can reach. Each problem got one answer, and snapd is built around the three.

You'd like the photo editor on your laptop. Before snaps, getting it there ran into three problems. Every distribution packaged the program separately, at its own pace, so one program became many packages. Its authors couldn't hand it to you directly: a packager stood in between. And whatever you installed ran as you, with everything your account can reach, so you had to trust whoever wrote it. Snaps answer each problem with one decision, and most of snapd is the shape of those three answers.

02 One package for every distribution

ONE PACKAGE photo-editorone squashfs file, mounted read-onlyeditorconvert core24: the base it runs on a content snap: shared librariesinstalled for you when a snap needs one UbuntuFedoraArch Linuxthe same file on each the storechannel: latest/stablerefresh follows the channelthe publisher decides when
The photo-editor snap as one squashfs file with an app, standing on the core24 base and a content snap installed for you when a snap needs one; the same file installs on Ubuntu, Fedora and Arch Linux; the store channel drives refresh

A snap is one squashfs file with its own runtime: a base snap such as core24 and, for shared libraries, content snaps that snapd installs for you when a snap names them. The same file installs on any distribution with snapd, and refreshes follow the publisher's channel.

The first answer is one file for everyone. The photo editor ships as a single squashfs file that carries its own libraries. Its snap.yaml names a base snap, such as core24, and the app runs on that base rather than on your distribution's libraries. Libraries that several snaps share come from content snaps, and when a plug names a default-provider, snapd installs that snap for you. So the same file installs on Ubuntu, Fedora or Arch. And updates come from the store channel you track, when the publisher releases them.

03 The publisher owns the package

THE PUBLISHER the publisher accountnames the publisheraccount-keytheir signing key snap-declarationname and snap-idsnap-revisionthis exact file revision 42 released to latest/stable: the publisher releases, you track the channel $ snap install ./photo-editor_42.snaperror: cannot find signatures with metadata for snap/component "./photo-editor_42.snap"$ snap install --dangerous ./photo-editor_42.snap
A publisher at the top and four assertions below: account, account-key, snap-declaration binding photo-editor and its snap-id, and snap-revision tying the file to it; a revision released to a channel; a terminal where an unsigned file is refused and then installed with --dangerous

account, account-key, snap-declaration and snap-revision assertions bind a snap name, snap-id and file to one publisher, who controls revisions and channels. A file without assertions is refused unless --dangerous is given.

The second answer: the publisher puts the snap in your hands, and snapd checks who that is. Every snap from the store arrives with signed assertions. An account assertion names the publisher and an account-key holds their signing key. A snap-declaration binds the name photo-editor and its snap-id to that account, and a snap-revision assertion ties this exact file to it. The publisher uploads a revision and releases it to a channel; that's what you get. A file with no assertions is refused: snap install says it can't find signatures. --dangerous installs it anyway, at your own risk.

04 Trust by confinement

CONFINED BY DEFAULT $ photo-editorsnap-confinethe app, in the sandboxmount namespace · AppArmor profile · seccomp filter photo-editornetworkthe systemthe unit of trust base declaration · snap-declarationdecide auto-connection, not the developer snapd-control: a store rule even to install classic: store review and --classic
photo-editor started through snap-confine into a sandbox of mount namespace, AppArmor and seccomp; a network plug connected to the system as the unit of trust; the base declaration and the store deciding auto-connection; snapd-control and classic confinement needing the store

snap-confine builds the sandbox before every app runs. Interfaces are the unit of trust: the base declaration and the store's snap-declaration, not the developer, decide auto-connection. Super-privileged interfaces such as snapd-control need a store rule to install; classic confinement needs store review and --classic.

The third answer: you needn't trust the developer, because the snap is confined by default. Each time you start the photo editor, snap-confine builds its sandbox first: its own mount namespace, an AppArmor profile and a seccomp filter. Anything beyond the snap's own files comes through an interface, so the interface is the unit of trust. Whether a plug connects by itself isn't the developer's call: the base declaration in snapd and the store's snap-declaration decide. The most powerful interfaces, like snapd-control, need a store rule even to install. And classic confinement, which switches the sandbox off, needs store review and your consent.

05 Why the map looks like this

THE MAP one package everywherethe publisher owns itconfined by default The store: channelsPackaging: bases and contentRefresh: follows the channel Assertions: who published itUbuntu Core: the model Interfaces: the unit of trustPolicy: who connects whatConfinement and sandbox snapd overview: next door
Three decisions at the top, each leading to the districts of the map it explains, and the snapd overview at the bottom

One package everywhere: the store, packaging and refresh. The publisher owns it: assertions and the model. Confined by default: interfaces, policy and the sandbox. The overview is next door.

Those three decisions explain most of the map. One package for every distribution is why there's a store, a packaging district with bases and content, and a refresh that follows channels. The publisher owning the package is why there are assertions, checked before anything installs, and why an Ubuntu Core device has a signed model. Confinement by default is why interfaces are the biggest district, why a policy district decides who connects what, and why snap-confine and the sandbox internals exist. The overview is next door; from there, follow your question.

Read more

Three problems, three decisions

ProblemDecisionWhat it produced in snapd
Each distribution packages the same program again, at its own paceOne package for every distributionthe snap file (squashfs, mounted read-only), base snaps, content snaps installed from a default provider named by a plug, refresh from a store channel
The author cannot publish to users directlyThe publisher owns the packageassertions: account, account-key, snap-declaration, snap-revision; channels and revisions the publisher controls
A package runs with everything the user's account can reachConfinement by defaultsnap-confine, AppArmor and seccomp profiles, a mount namespace per snap, interfaces with plugs, slots and connections, the base declaration and per-snap store rules

What snapd checks before a store snap installs

  • The snap-revision assertion for the file's SHA3-384 digest, which names the snap-id and revision.
  • The snap-declaration for that snap-id, which names the snap and its publisher.
  • The account-key that signed them, and the account of the publisher.
  • The interface rules for installation: the snap's own snap-declaration, or else the base declaration.

A file without assertions is refused with cannot find signatures with metadata for snap/component "<file>". snap install --dangerous <file> installs it without assertions; --devmode implies the same for a file.

Confinement levels

LevelSandboxWho allows it
strictenforced; access only through connected interfacesthe default
devmodeviolations are logged, not blockedthe user, with --devmode; the docs say such a snap cannot be released to the stable channel and does not refresh automatically
classicnone; the snap sees the hoststore review, and the user with --classic; not available on Ubuntu Core

for app developers for Ubuntu Core developers for snapd developers for administrators

Interfaces that need the store

Super-privileged interfaces have allow-installation: false in the base declaration. A store snap with such a plug installs only when its own snap-declaration has a rule that allows it. snapd-control, mount-control and kernel-module-load are examples; see Policy for the rules.

Further reading

Roads from here

START HERE

  • snapd — the overview of the daemon these decisions produced

GETTING SNAPS

  • The store — the store that delivers and refreshes snaps
  • Snap packaging — the snap file with its base and content snaps

INTERFACES AND CONFINEMENT

ASSERTIONS · signed statements snapd trusts

POLICY · who may install and connect what

UBUNTU CORE · install and recovery