The dev daemon
chainmail daemon --dev runs a daemon as your own user, for work on chainmail itself. It needs no sudo, no system user and no service, so you can start a build from a checkout, stop it and start it again in seconds. To use chainmail with real mail, run chainmail bootstrap instead.
When dev mode is on, the daemon prints this warning on stderr before its first log line, and logs it as a WARN record with dev=true. chainmail admin status --output table repeats it in a warning row.
dev mode: this daemon runs as you, so any program running as you, including agents, can read the vault key and every stored password. Use it only to develop chainmail, never with real accounts.
A production daemon keeps its key and its state under its own user, where your user cannot read them. The security model explains what that separation protects. A dev daemon has no such separation. It admits only your own user at the socket, and it ignores socket and client_group in the config. Give it test accounts only.
Blocks fenced as sh run unchanged in bash and in fish. Where a step keeps shell state, the page gives a bash tab and a fish tab.
The vault key
Make a config directory, a state directory and the vault key. age-keygen -o writes the key with mode 0600. The daemon refuses a key file that other users can read, and one that its group can read unless root owns it.
mkdir -p ~/.config/chainmail-dev ~/.local/state/chainmail-dev
age-keygen -o ~/.config/chainmail-dev/vault-key
The key is the only way to open the vault in the state directory. If you lose it, move vault.age aside and store the test secrets again.
The config file
A minimal config has one account. Save it as ~/.config/chainmail-dev/config.toml:
[accounts.site]
provider = "hostinger"
site is the account's name, which commands use to refer to it. Accounts and providers has a table for each preset, and Configuration lists every key. The daemon reads the file only at startup, so restart it after an edit.
Start the daemon
Start it in a terminal of its own. Giving --socket explicitly works the same on Linux and on macOS.
chainmail daemon --dev \
--config ~/.config/chainmail-dev/config.toml \
--state-dir ~/.local/state/chainmail-dev \
--vault-key-file ~/.config/chainmail-dev/vault-key \
--socket ~/.local/state/chainmail-dev/chainmail.sock
The daemon prints the dev mode warning, then logs JSON lines to stderr, and logs daemon listening once it accepts clients. It keeps vault.age, state.db, cache.db and calendar.db in the state directory. It replaces a stale socket left by a crashed daemon, and refuses to start if another daemon is listening on the path.
--dev refuses the production state directory, /var/lib/chainmail, including through a symlink, with --dev needs a --state-dir other than /var/lib/chainmail. Without --socket, a dev daemon uses CHAINMAIL_SOCKET, then $XDG_RUNTIME_DIR/chainmail-dev.sock. Where XDG_RUNTIME_DIR is not set, as on macOS, it needs one of the first two, and otherwise exits with --dev needs --socket, CHAINMAIL_SOCKET or XDG_RUNTIME_DIR.
Point the CLI at the socket
Clients pick their socket from --socket, then CHAINMAIL_SOCKET, then socket in cli.toml, then /run/chainmail/chainmail.sock. They never look at XDG_RUNTIME_DIR.
A cli.toml that names the dev socket sends every command and every agent to the dev daemon, including on a machine that also runs a production daemon. So set the variable in the shells you develop in instead. A dev daemon started where it is set uses it too, so you can then leave out --socket. When chainmail bootstrap finds a cli.toml or a CHAINMAIL_SOCKET that names another socket, it leaves the setting alone and warns with the line to change.
- bash
- fish
export CHAINMAIL_SOCKET="$HOME/.local/state/chainmail-dev/chainmail.sock"
chainmail admin status --output table
set -gx CHAINMAIL_SOCKET "$HOME/.local/state/chainmail-dev/chainmail.sock"
chainmail admin status --output table
admin status prints the daemon's version, dev mode true, the names of the stored secrets, a warning row with the dev mode warning, and each folder's sync state and each account's cache state. A second warning row appears when the daemon's version differs from the CLI's, as it can when the daemon is a build from your checkout and chainmail on PATH is an installed release. CLI settings describes cli.toml, if you want it anyway.
The daemon also reads its other flags from the environment: CHAINMAIL_CONFIG, CHAINMAIL_STATE_DIR, CHAINMAIL_VAULT_KEY_FILE and CHAINMAIL_DEV. A flag on the command line wins over its variable, so an explicit --dev or --dev=false wins over CHAINMAIL_DEV, which takes a boolean such as true or 1. This starts the same dev daemon as above:
- bash
- fish
export CHAINMAIL_CONFIG="$HOME/.config/chainmail-dev/config.toml"
export CHAINMAIL_STATE_DIR="$HOME/.local/state/chainmail-dev"
export CHAINMAIL_VAULT_KEY_FILE="$HOME/.config/chainmail-dev/vault-key"
export CHAINMAIL_SOCKET="$HOME/.local/state/chainmail-dev/chainmail.sock"
export CHAINMAIL_DEV=true
chainmail daemon
set -gx CHAINMAIL_CONFIG "$HOME/.config/chainmail-dev/config.toml"
set -gx CHAINMAIL_STATE_DIR "$HOME/.local/state/chainmail-dev"
set -gx CHAINMAIL_VAULT_KEY_FILE "$HOME/.config/chainmail-dev/vault-key"
set -gx CHAINMAIL_SOCKET "$HOME/.local/state/chainmail-dev/chainmail.sock"
set -gx CHAINMAIL_DEV true
chainmail daemon
Store the test account's secret
The hostinger preset logs in with a password, which goes in the vault as accounts/site. secret set prompts for it without echo when stdin is a terminal, and reads it from stdin otherwise.
chainmail secret set accounts/site
chainmail accounts test site --output table
Stop the daemon
Press Ctrl-C in its terminal. From another terminal, send that one daemon SIGTERM, which stops it just as cleanly. The first command below prints the PID of the chainmail daemon whose command line ends with this page's --socket path. <pid> is that number. If it prints none or more than one, use Ctrl-C instead.
pgrep -f -- 'chainmail daemon .*--socket '"$HOME"'/\.local/state/chainmail-dev/chainmail\.sock$'
kill '<pid>'
Everything the daemon knows stays in the state directory. The next start picks up where it stopped.
Tests against a dev daemon
The live tests run against a daemon you start. Their write tests need expunge and folder deletion turned on. Turn them on in a dev daemon config made for the run, never in production.
A dev daemon that already holds accounts you mean to keep can move to a production daemon, as Move a dev daemon's state to production describes.