Skip to content

Configuration ​

cairn has very little to configure. This page lists the environment variables it reads, the two host policy files /etc/cairn/net.conf and /etc/cairn/vmm.conf, the cairn admin tools for checking and maintaining a host, and how $CAIRN_HOME is laid out on disk. Settings for a single app live in cairn.toml and are covered in manifest.

Environment variables ​

Variables you may set ​

VariableMeaning
CAIRN_HOMENot read by an installed (release) cairn: your state (apps, networks, volumes, kernels, ...) is always in ~/.cairn, ~ being your home directory in /etc/passwd, so each user has exactly one. A debug build from a checkout (the tests) reads CAIRN_HOME, else $HOME/.cairn.
CAIRN_PROGRESS=plainTurn off the live, redrawing progress display and print plain lines. See troubleshooting. Any other value changes nothing.
NO_COLORWhen set and not empty, never use colour.
CLICOLOR_FORCEWhen set and not empty, use colour even into a pipe.
CLICOLOR=0No colour.
TERM, CIColour is on for a terminal when TERM is set and not dumb, or CLICOLOR is set, or CI is set. Live progress needs a terminal and a TERM that is not dumb.
LC_ALL, LC_CTYPE, LANGThe first one that is set and non-empty decides whether cairn draws with Unicode: it must name UTF-8.

Colour decisions are made per stream (standard output and standard error separately) and follow the same rules as cairn --help, in this order: NO_COLOR, then CLICOLOR_FORCE, then CLICOLOR=0, then the terminal test above. --json output is never painted.

Variables cairn reads from the session ​

VariableUsed for
HOMEThe default for CAIRN_HOME, and the fallback for systemd's user unit directory.
XDG_CONFIG_HOMEWhen set and absolute, the user's systemd unit directory is $XDG_CONFIG_HOME/systemd/user; otherwise $HOME/.config/systemd/user. cairn writes the units for start-at-boot machines there.
XDG_RUNTIME_DIR, DBUS_SESSION_BUS_ADDRESSHow cairn reaches your systemd user manager (systemctl --user). Without a session, systemd-launched machines are reported unavailable. cairn doctor says so.
NOTIFY_SOCKETSet by systemd when it starts a machine's supervisor; cairn uses it to report readiness. Never set it yourself.
PATHWhere cairn finds podman, git, curl and similar. cairn run removes the synced folder's directories from PATH before it runs any tool. See run.

Environment for your workload ​

cairn.toml's .env support, ${NAME} templates and [env] are about the variables your app sees inside its machine, and are documented in manifest. cairn's own variables above are not passed to your workload. For cairn run, -e and an alias's env list choose what is forwarded (run). Inside an exec health check, cairn sets CAIRN_CHECK_ADDR to the address the http and tcp checks probe (the guest's own address, or 127.0.0.1 when the network is off).

Developer overrides (do not set these) ​

CAIRN_JAIL, CAIRN_NETD and CAIRN_HELPER replace the path of cairn-jail, cairn-netd and cairn-helper for the unprivileged cairn command. They exist so tests can run stand-ins. A normal install finds those programs in /usr/libexec/cairn and there is no setting for that path. Systemd units cairn writes copy these three variables if they are set when the unit is written. Any variable named CAIRN_TEST_*, CAIRN_*_TEST_* or CAIRN_UPDATE_GOLDEN is a test hook and not supported.

Host policy files ​

Two files in /etc/cairn/ hold policy for the privileged programs. The package installs both with every key at its default, which is exactly what a host with no file gets. An upgrade keeps your edits; the shipped reference copies are /usr/share/doc/cairn/net.conf.example and /usr/share/doc/cairn/vmm.conf.example.

Both files use one strict syntax:

  • one key = value per line; blank lines and lines starting with # are ignored,
  • a # after a value is an error (put comments on their own line),
  • a key may appear once,
  • an unknown key is an error, not a warning: the program refuses to start with a file it cannot read, naming the line,
  • whitespace around the key and value is trimmed; lists are comma-separated; user ids are plain decimal numbers (names are not accepted).

The files must be a regular file owned by root that only root can write, no larger than 64 KiB. A missing file means the defaults. The old key allow_uids is refused with a message: access is controlled by the cairn group (see getting-started).

Check a file before relying on it:

sh
cairn admin check-config
console
ok /etc/cairn/net.conf
ok /etc/cairn/vmm.conf

It parses each file with the privileged program's own parser. --file <PATH> checks a different file. cairn doctor runs the same check.

/etc/cairn/net.conf ​

Policy for cairn-helper, the setuid program that creates networks and ports. See networking for what these limits mean in use.

KeyDefaultMeaning
transit_pool10.250.0.0/16The IPv4 pool every network's /30 transit link is carved from. Must be a valid pool (cairn rejects one that is unsuitable).
extra_blockedemptyExtra IPv4 ranges (CIDR, comma-separated) guests may never reach, beyond the built-in list.
max_networks_per_uid16Most networks one user may have. Range 1 to 4096.
max_ports_per_uid64Most published ports one user may have. Range 1 to 4096.
min_host_port1024Lowest host port an ordinary user may publish. Range 1 to 65535.
allow_privileged_portsemptyUser ids (comma-separated) who may publish below min_host_port.
allow_public_publishfalsetrue or false. Whether any allowed user may publish on an address other than 127.0.0.1.
allow_public_uidsemptyUser ids who may publish publicly even when allow_public_publish is false.

Example: let user 1001 publish on any address, and cap everyone at 8 networks:

ini
max_networks_per_uid = 8
allow_public_uids = 1001

/etc/cairn/vmm.conf ​

Policy for cairn-jail, the setuid program that starts Firecracker inside its jail.

KeyDefaultMeaning
max_machines_per_uid64Most machine trees one user may have at once, live or dead, until cleanup. Counts trees, not bytes. Range 1 to 4096.
root_size_mib64Size in MiB of each running VMM's private tmpfs root. Range 32 to 1024.

There is deliberately no key for the jailer path, the Firecracker path, or the jail's base directory.

cairn admin ​

cairn admin holds tools for the person who administers the host. The first four need root.

sh
sudo cairn admin inventory
CommandWhat it does
inventoryLists everything cairn has on the host: every network and port record (tombstones included), every live machine tree, and every cairn process found in /proc. Changes nothing. --require-quiet exits 0 only when none of those remain. Root only.
cleanupFinishes stale cleanup: the helper's garbage collection, then the jail's. Root only.
maintenance beginRaises the maintenance barrier: nothing new can start while it is up. Runs cleanup and records whether the host is quiet. --why <WHY> labels it (remove, uninstall, or your own word; default admin). --require-quiet removes the mark again and exits 1 when the inventory is not quiet. Root only.
maintenance endRemoves the mark; creation is allowed again. Root only.
maintenance statusPrints the mark. Root only.
check-configParses the two policy files as above. Any user.
check-caps <PATH>...Compares each file's security.capability attribute to --expect (none, or cap_a,cap_b=ep; default none), comparing as sets. Used by the packaging checks.
probe-device <PATH>...Opens device paths and reports each as JSON. Used by cairn doctor for /dev/kvm and /dev/net/tun.

All accept --json. Running a root-only command as an ordinary user fails with a message that tells you to use sudo.

A typical use is taking a host down for maintenance or removing the package: raise the barrier, check nothing is running, do the work, lower it.

sh
sudo cairn admin maintenance begin --why remove --require-quiet
# ... remove or upgrade ...
sudo cairn admin maintenance end

The CAIRN_HOME directory ​

Everything below is per user, under $CAIRN_HOME (~/.cairn by default), owned by you. Do not edit records by hand.

text
$CAIRN_HOME/
  apps/<app>/
    app.json            the app's current machine, its network membership, the
                        ports it publishes, and any hold on starting it
    deploy.json         only while a deploy or its cleanup is unfinished: the
                        attempt's state, which the next command settles
    launch.json         the machine and token of the latest launch attempt,
                        which the network's agent checks before it attaches
    records/<id>.json            the machine's record: pid, start time, boot id
    records/<id>.spec.json       the machine's spec (including its kernel digest)
    records/<id>.run.json        liveness and health the supervisor renews
    records/<id>.supervisor.log  what the supervisor said
    records/<id>.control.json    a pause or resume request, until the supervisor
                                 answers it in the run file
    machines/<id>/      only what the VMM needs: rootfs.ext4 (root disk), config.ext4
                        (config drive), vm.json, console.log, firecracker.log,
                        and volume-<name>.ext4 (hard link to a volume)
    sync/               for `cairn run` apps: the sync's baseline, report, log, journal
  volumes/<app>/        persistent volumes: <id>.ext4 and <id>.json per volume
  networks/<name>.toml  the network's definition (desired state); its members
                        are the apps whose app.json names it
  kernels/              the pinned kernel and custom imports (see kernels.md)
  templates/            cached root disks that `cairn run` clones from
  providers             optional: your [run] aliases (see run.md)
  build/                scratch space for image builds
  run/                  runtime state, safe to lose after a reboot
    net/<name>/         a network's agent: agent.sock, agent.lock, pending.json,
                        agent.log, egress.log
    net/<name>.lock
    deploy/             per-app and per-network deploy locks
    supervise/<app>/    per-machine supervisor locks
    volumes/<app>/      per-volume locks (the state is in volumes/<app>/<id>.json)
    cairn-run/          `cairn run`: folder leases (roots.lock, roots/, folders/), and
                        apps/<app>/ with session.lock, sync.lock and session.sock

Notes:

  • machines/<id>/ is the VMM's. A jailed Firecracker can write there, so the record that decides which process stop signals lives in records/, not in it. cairn reads files from it as untrusted.
  • Volumes are hard-linked into machines/<id>/, so volumes/ must be on the same filesystem as apps/. See volumes.
  • Every record is written durably (temporary file, sync, rename, directory sync), so a reader sees the whole old version or the whole new one.
  • run/ is runtime state. It is stale after a reboot and cairn rebuilds what it needs.
  • Systemd units for machines you start at boot are not in $CAIRN_HOME; they are in your user unit directory (see XDG_CONFIG_HOME above) and carry an X-CairnHome= line naming the home.

Host-wide state ​

Privileged state is not in your home:

PathOwnerContents
/etc/cairn/net.conf, /etc/cairn/vmm.confrootThe policy files above.
/var/lib/cairn/rootThe state root (0755).
/var/lib/cairn/net/cairn-helper (0700)The helper's ledger of networks and ports, and the maintenance lock.
/var/lib/cairn/vmm/root (0700)The jail's machine trees.
/usr/libexec/cairn/rootcairn-helper, cairn-jail, cairn-netd, the jailer and Firecracker.

See architecture and security for what each privileged program does.