Skip to main content

Module root

Module root 

Source
Expand description

The shell scripts run as root (Linux), and the pieces of those that download something and trust it only once it is checked: a fresh private work directory, gpg with a keyring of its own there, and the check of a downloaded signing key against the fingerprints pinned for it. The vendors’ apt repositories an install sets up (super::linux) go through the same check, and so can an embedder’s own root scripts.

Structs§

RootScript
A shell script run as root (through pkexec on Linux, or sudo -n unattended). The only way to make one is RootScript::new, which starts it with PRELUDE: no root script can miss stopping at its first failure, its private work directory, apt’s wait for the dpkg lock, or the C locale its output is read in. The step that runs a script as root takes this type, never a String.

Constants§

NEED_CURL
curl, installed first where a bare system has none (Debian’s minimal image): every vendor install downloads with it, and without it the repository checks read as “no packages”. Through apt where it is, else dnf (Fedora and the distributions built on it).
NEED_GPG
gpg, for the vendors’ signing keys (Debian’s minimal installs have only gpgv), and a private keyring folder for it in the work directory, so root’s own keyring is never read or changed.
NEED_UNZIP
unzip, for Amazon’s AWS CLI bundle, through apt where it is, else dnf.
PRELUDE
What every RootScript starts with: the private work directory (set -e, $d, apt’s lock wait), then the C locale, so a tool’s output the script reads (apt-cache policy’s Candidate:) is the same words on every system: pkexec keeps the user’s LANG, and apt translates its labels.

Functions§

check_keys
Stops the script unless "$d/key", a vendor’s signing key (or keyring) just downloaded, holds exactly the keys pinned here (fingerprints, 40 hex digits each, their primary keys), no more and no fewer. TLS alone trusted whatever the vendor’s server sent the first time; a swapped key would sign the packages apt then installs as root. Runs after NEED_GPG.