Skip to content

How policy is enforced

The services that own a setting apply what the policy decides and refuse calls that would change it, whatever program makes the call, so the luft command and scripts are held to it as much as Settings. The files, their folders, which one wins and every key are in Locking settings with a policy.

Keys Enforced by
organization Nothing to enforce; Settings shows the name. Joining an organization, below, writes a whole policy
screen-lock, nearby-sharing locksmith, below, which locks the desktop settings
updates updater: Schedule and DownloadAutomatically report the policy’s values and the scheduled check follows them. A system on another channel than the policy’s moves to it the way a channel switch does, waiting until that channel has caught up. A system following another image than image moves to it the same way, keeping its standard or NVIDIA image, but only to an image /etc/containers/policy.json requires a signature for, such as an organization’s own.
firewall shield: with home-networks off, no network is home and none waits to be chosen; with public-access off, apps and ports allowed anywhere only open on home networks; with open-ports off, the ports opened for services stay closed.
software.system-packages, software.package-sources packager refuses Install and InstallFile, or AddRepository. Schelf and the schelf command show and refuse them before asking. Packages and sources added earlier stay.
software.app-sources Schelf, its install window for files and the schelf command refuse to install from other sources and show those apps as managed. Apps installed earlier keep updating and can be removed.
developer The greeter service’s DeveloperTools, which everything that depends on Developer tools reads
extensions packager refuses InstallUnreviewedExtension and AllowExtensionFolder, and Kestrel stops every extension that isn’t from the store, copies and approved folders included
encryption trustd refuses CancelSystemDiskEncryption. On a computer whose TPM unlocks the disk, it asks for encryption itself when it starts and when the policy changes, with a recovery key it keeps sealed to the TPM, which an administrator can show in Settings; the disk is encrypted from the next restart. Without such a TPM, someone has to turn encryption on in Settings, with a passphrase.
accounts.add, accounts.administrators locksmith writes a polkit rule that denies AccountsService’s org.freedesktop.accounts.user-administration to everyone but root
accounts.automatic-sign-in The greeter service refuses SetAutomaticLogin for a person, and the login screen doesn’t sign anyone in by itself
remote-login remoted: Enabled and PasswordLogin report what the policy leaves, turning remote login or passwords on fails, and a running SSH server is stopped, or loses passwords, as soon as the policy changes. At startup, sshd only starts when the policy allows it.
crash-reports The crash reports service in each session: its Choice is the policy’s, SetChoice fails, and with "never" nothing waiting or queued is sent
sign-in luft-sign-in, below
usb.protection portguard follows the policy and keeps its mode, which it saves so the startup image holds devices back the same way; SetMode fails
usb.read-only, devices.camera, devices.microphone locksmith raises a flag in /run/luft/policy that 72-luft-policy.rules follows: USB drives are set read-only with blockdev --setro as they’re added, and cameras and microphones’ capture devices lose their uaccess tag and belong to root alone
devices.bluetooth locksmith masks bluetooth.service for the running system and stops it
erase locksmith’s polkit rule turns com.lantharos.installer.erase into auth_self for everyone or no for everyone, and the installer service refuses Erase while nobody may
screen-capture Kestrel refuses org.gnome.Shell.Screenshot and org.gnome.Shell.Screencast, the screenshot interface, starting screen casts and remote desktop through the portal, window captures and Peek
network, certificates locksmith keeps /run/NetworkManager/system-connections/luft-policy-*.nmconnection and /etc/pki/ca-trust/source/anchors/luft-policy-*.pem as the policy lists them, again at every start, and reloads NetworkManager or runs update-ca-trust. Settings shows those connections without a way to change or forget them, and luft-network refuses to delete them.
printers locksmith-printers.service, once the network is up, adds each printer as a driverless queue with lpadmin and removes the ones the policy no longer lists
appearance, region locksmith locks the wallpaper and automatic time zone in dconf, sets the time zone and the system language, and its polkit rule denies org.freedesktop.timedate1.set-timezone and org.freedesktop.locale1.set-locale. The login screen starts sessions in the policy’s language.
settings Settings and Kestrel’s search leave the pages out
apps.hidden locksmith writes a launcher marked Hidden=true for each app to /run/luft/policy/share/applications, which sessions have first in XDG_DATA_DIRS, so it stands in for the app’s own in Start, search and Open with
apps.blocked appguard, below, and Schelf refuses installing them
apps.installed Schelf installs them at every sign-in, as --preinstall does, and refuses removing them
apps.downloaded appguard, below. Schelf, its install window and the schelf command refuse every install for one account, and --preinstall installs nothing
kiosk, one-app luft-kiosk, the greeter service, appguard, locksmith and Kestrel, below

A refused call fails with the service’s Managed error, such as com.lantharos.Updater1.Error.Managed.

The screen lock, Post’s visibility, the wallpaper and the automatic time zone are desktop settings each person keeps in their own dconf database, so a service can’t refuse changes to them. Instead, locksmith.service compiles the decided values into the dconf system database /etc/dconf/db/luft_policy, with each key locked, and Kestrel’s session puts that database right after each person’s own, so its values are the ones read and the person’s own can’t be written. locksmith.path runs it again whenever a policy folder changes; it marks the old database as replaced and tells running sessions over the system bus, the way dconf update does, so the new values reach them at once.

The same run writes the polkit rules for accounts, erase and region to /run/polkit-1/rules.d/00-luft-policy.rules, which polkit reads as soon as it changes, applies the devices, networks, certificates, time zone and language the policy decides, hides apps, and publishes the whole policy as JSON in /run/luft/policy/policy.json, without passwords and keyfiles, which Kestrel follows for extensions, screen-capture, settings and the language. Each part is applied on its own, so one that fails, such as NetworkManager not answering, doesn’t hold back the others, and the run fails afterwards so the journal shows it.

luft-sign-in reads the policy at every request. Keys whose model isn’t in security-keys, judged by the AAGUID the key reported when it was added, and cards whose certificate none of card-issuers signed stop counting, as do whole ways ways leaves out; AddSecurityKey refuses such a key with KeyNotAllowed and AddSmartCard such a card with Managed. With key-attestation, the AAGUID is only taken once the key proved it, as Signing in with keys and cards describes. The password counts while the person keeps it on or password-off is off, and only while ways lists it, but, as before, also whenever nothing else is left, so nobody is locked out. For administrator prompts and sudo the same rules run with administrators narrowing the ways further. The PAM module’s confirm-password and confirm-fingerprint ask about prompts and sudo, and fingerprint about the lock screen’s fingerprint rules. With taken-out = "sign-out", logind ends the sessions instead of locking them.

appguard.service runs from the start and follows the policy. While the policy blocks no app, confines no account and leaves apps.downloaded on, it attaches nothing; once it does, it attaches two BPF LSM programs, bprm_check_security and mmap_file, which run for every program started and every file mapped to run, and keeps them up to date. They walk from the file up to the top of its filesystem, then down again through a tree of the places on the list, named within their own filesystem as /proc/self/mountinfo has them, so a program is found the same way from the system, inside a Flatpak sandbox or with system packages merged over /usr. Each place and app carries who it’s blocked for: everyone but root and the members of wheel, which appguard follows through /etc/group, the kiosk’s account, or one-app accounts. They refuse with EPERM on reaching a place blocked for the person running the file, or an app inside an app folder (Flatpak’s app, the store’s sabine/apps, Luft’s luft/appimages and luft/preinstall) that’s blocked for them, or, for a confined account, not allowed it, whoever installed it. Checking mmap_file too keeps the dynamic loader from running a blocked program. They cost a few map lookups per folder, and nothing at all while nothing is blocked.

With apps.downloaded = false, the same programs refuse every regular file that isn’t one of the system’s own to everyone but root and unconfined administrators. A file is the system’s when its filesystem is one the system runs from, the ones mounted at /, /usr and the one holding /var/lib/flatpak, by the device number the kernel gives each, and either that filesystem is read-only, as the image and its system packages are, or the file and every folder above it up to the top of its filesystem belong to root and nobody else can write to them. appguard reads those filesystems from /proc/self/mountinfo, and while it’s attached it reads them again whenever the mounts change, such as when system packages are merged over /usr anew. Everything else is refused: home folders and the writable folders under /var, which belong to people or are open to everyone, /tmp, /dev/shm and the memory files memfd_create makes, USB drives and FUSE mounts, whoever claims to own their files. Scripts started directly are refused like programs, as are interpreters named on a script’s first line. A walk up the folders is a few reads per level, as for blocked apps, and a read-only filesystem needs none.

Flatpaks installed for everyone run, since /var/lib/flatpak belongs to root and only administrators install there: an organization brings its own apps that way or in its own image. Flatpaks a person installs for themselves are in their home folder, so they don’t run; nor do apps from schelf.store and AppImages, which Schelf installs into each account and runs from there or through FUSE. Schelf follows that and refuses installing them rather than installing what can’t run.

The kernel can’t see what an interpreter does with a script it reads, or code a program copies into memory of its own and makes executable, so neither is refused: a JIT compiler, which browsers need, works that way too.

The kiosk’s account and one-app accounts are confined: appguard blocks every app of the system for them, Luft’s own in /usr/lib/sabine and every app Start shows, except the ones the policy allows and what their sessions need: Schelf, which installs the organization’s apps, and for one-app accounts Settings and, with file-picker = "documents", Rover, which answers file choosers. In app folders it allows only those apps, so an app such an account installs or finds elsewhere doesn’t run either. A confined administrator is confined too.

luft-kiosk.service starts before the login screen while the policy has a kiosk or one-app accounts, and locksmith starts it when one appears. It makes the kiosk’s account with useradd if it’s missing and serves com.lantharos.Kiosk1: Authorize, Leave and Unlock need com.lantharos.kiosk.manage, an administrator kept for a few minutes, and Restart answers the kiosk itself and root. Starting over ends the kiosk’s sessions through logind, clears its home back to /etc/skel while keeping the folders that hold installed apps, without following any link the account made, and restarts greetd.service. It does the same when the kiosk’s session ends any other way, such as Kestrel crashing, at most once every ten seconds. Leave notes /run/luft/kiosk/left before ending the session; Unlock lists the caller in /run/luft/kiosk/unlocked, which appguard follows, and waits for appguard to note in /run/luft/kiosk/applied that it did, so Settings opened right after runs, until the account locks again, its sessions end or the kiosk starts over.

The greeter service writes greetd’s initial_session for the kiosk’s account into its configuration, unless the kiosk was left, so greetd signs it in when it starts. locksmith adds a transient luft-kiosk-reset.timer with systemd-run for reset-at and a polkit rule that keeps the kiosk from UDisks.

A web kiosk’s browser policy reaches only the kiosk’s account. luft-kiosk writes it to /run/luft/kiosk/browser/luft.json, only the site, without downloads or developer tools, and a drop-in for the account’s user@UID.service in /run/systemd/system with BindReadOnlyPaths=/run/luft/kiosk/browser:/etc/chromium/policies/managed, then reloads systemd, all before the login screen starts. Kestrel and everything it starts run under that systemd, so they see the kiosk’s folder where Helium reads its managed policy, and every other account sees the system’s. The account can’t change it: the folder belongs to root, the bind is read-only, and a mount systemd made can’t be taken off from inside the account. A drop-in rather than a wrapper around Helium, because Chromium reads managed policy only from that one folder, and a wrapper the kiosk’s own session starts could be gone around.

Kestrel reads the kiosk from the published policy and starts the kiosk’s account in its kiosk session mode, with no desktop, Start, notifications, switchers, screenshot tool or on-screen displays: every keybinding is filtered, including the ones that switch to a text console, and apps can’t keep shortcuts for themselves. It opens the app, or Helium in kiosk mode on the site, keeps its windows full screen, opens it again 250 ms after it closes, and asks Restart once nobody touched the screen for reset-after seconds after someone did. For one-app accounts the usual desktop runs, with Start, search, the taskbar’s pins and the desktop menu limited to the allowed apps and pages, and no file or web search. Settings shows one-app accounts only its Wi-Fi and sound pages, and Rover’s file chooser keeps them in Documents, checking every path with its links followed, or answers at once without files when the picker is off; Rover’s own window and file manager service don’t open for any confined account. In both, Ctrl+Alt+Shift+Delete is grabbed past every filter and asks Authorize, through Kestrel’s own administrator prompt, before it offers its choices.

Kiosk and one-app sessions have two more ways out for screens without a keyboard. luft-kiosk reads the kernel’s device announcements from a netlink socket and, while a card reader is plugged in, waits on pcscd for cards put in or tapped on, so it does nothing until a device arrives. For a new HID device whose report descriptor has the FIDO usage page, or a card in a reader, it asks luft-sign-in for Present, the accounts whose enrolled key or card is there now, which checks keys without a touch and cards by their certificate, and only root may ask. When one of them is in wheel, it sends AdministratorArrived. Kestrel listens for it and, while its session is on screen, asks Authorize as the shortcut does. A Clutter long-press gesture on the stage, in the capture phase, watches touches that start in a 48 by 48 point square in the top corner on the side text starts from; touches keep reaching the app below, and only a finger that stays within the drag threshold for 5 seconds asks Authorize.

BPF LSM rather than fapolicyd or SELinux: fapolicyd asks a daemon about every file opened and run, which slows the whole system and stalls it when the daemon hangs, and it names files by paths that look different from inside a sandbox. SELinux can’t change the labels of the signed, read-only image at run time, and Luft’s people all run unconfined, so it has no notion of who is an administrator to work with.

Joining an organization puts its policy in /etc/luft/policy.d and keeps it up to date, so every service above applies it as it would any policy file.

An enrollment file is TOML with the signature on its first line: # luft-signature: and an Ed25519 signature, in base64, of luft-organization, a NUL byte and everything after that first line. The rest is the policy, which has to name the organization in [organization], and an [enrollment] table with the organization’s public key, the https:// address newer files come from and a serial. A release file has only a [release] table with the computer it lets go, or all, and its own serial. Ed25519 because its keys and signatures are short enough to read and paste, signing can’t go wrong with a bad random number, and the ed25519-dalek Luft already uses for schelf.store’s signatures checks it strictly.

com.lantharos.Organization1, served by luft-organization on demand, joins and leaves for Setup, Settings and luft org. Join and Leave need com.lantharos.organization.manage, an administrator. Joining keeps the enrollment file in /var/lib/luft-organization/enrollment.toml, readable only by root, and its key is the one the computer pins: from then on a file counts only when that key signed it and its serial is higher than the one the computer has, or the same file again. Release files count only for this computer’s id, a hash of its machine id, or all, and only while their serial is higher than the policy’s, so an old release can’t be played back after newer policy. A file signed by another key is refused, as is joining a second organization.

A rotation moves computers to a new key: an enrollment file signed by the new key and naming it, signed again as a whole, signature line included, by the key it replaces, so it opens with two signature lines. A computer that pinned the old key takes it like any newer file, by the same serial rules, and keeps the inner enrollment file, so from then on the new key is pinned and files signed only by the old one are refused. A computer that already has the new key reads the inner file, and one joining for the first time joins with it, so the organization can serve the rotation at its address for as long as computers might still be on the old key; replaying it once newer policy is in place fails the serial check like any older file. While its folder still holds previous.key, luft org sign signs enrollment and release files this way too, and a release counts when the pinned key signed it either way. The policy is written next to it, as 90-organization.toml and 91-organization-private.toml with mode 600 for the sections holding password or keyfile, each written to a temporary file in the same folder and renamed, so the services following the folder never read half of one.

The installer joins in the new system itself, with the same code, when Setup hands it an enrollment file with the install plan; Setup finds one in luft-enrollment.toml at the top of a USB stick, which it mounts read-only through UDisks once per stick, or fetches the address a code stands for. A valid file on a stick is always joined, so whoever hands out the stick decides; one that can’t be used is shown with the reason, and Setup installs without joining. luft-organization-image.service joins the organization in /usr/share/luft/enrollment.toml, an organization’s own image, before the login screen starts, and takes the image’s file again when it’s newer. luft-organization-update.service fetches the address and takes what it finds there: luft-organization-update.timer starts it every three hours, and the NetworkManager dispatcher script 90-luft-organization whenever a connection comes up or connectivity changes.

The code and its tests are in packages/organization (luft-organization), the service in services/organization, and the part Setup and Settings share in packages/system/joining.

luft-policy in packages/policy reads and merges the files into a typed Policy. Policy::load() reads this computer’s, Policy::from_folders any folders, Policy::explain() which file decides each value, and luft_policy::check reads one file’s text or names every problem in it. With the follow feature, Follow watches both folders, including ones that don’t exist yet, and changed() waits until the policy really changes and gives the new one; long-running services wait on it next to their other work. Services that exit when idle follow the policy while they run, and remoted-policy.path and trustd-policy.path start them when a folder changes. Settings and Schelf get the same Policy from their policy commands and a policy.changed or schelf.policy event, and pass locked to the shared Row from @luft/ui.