95.21. bolt-0.9.11
Thunderbolt device manager, so a dock behind firmware security is authorised
| Version | 0.9.11, release 1 |
| Shelf | hardware — Device access, bus and sensor tools, power management, and Bluetooth |
| Phase | 41_system (System), 667 of 1047 in build order |
| Licence | LGPL-2.1-or-later |
| Homepage | https://gitlab.freedesktop.org/bolt/bolt |
| Build time | 0.2 SBU |
| Installed size | 605.5 KiB in 13 files |
| Recipe | ports/core/hardware/bolt/kpkgbuild |
About
bolt manages Thunderbolt devices: boltd authorises a device the kernel has enumerated, by its stored policy, and boltctl lists, enrolls and authorises devices by hand. Where the firmware’s Thunderbolt security level is user or secure, the shipping default on most business laptops, a Thunderbolt 3 or 4 dock is enumerated and then never authorised without it, and the dock’s ports stay dead. An enrolled device is authorised only while boltd runs.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/hardware.txt:
Thunderbolt authorisation. Where the firmware's security level is
userorsecure— the shipping default on most business laptops — a TB3/TB4 dock is enumerated and then never authorised, so the dock's ports stay dead.
Sources
bolt-0.9.11.tar.gz(251.2 KiB)
sha256cde4fc6d4a188e37d088cf59a5b2d174ac4b03d57bf9d084d711ba92105c33c0
upstream: https://gitlab.freedesktop.org/bolt/bolt/-/archive/0.9.11/bolt-0.9.11.tar.gz
archive copy: sources-3/hardware--bolt-0.9.11.tar.gz
Dependencies
Depends on: meson, ninja, glib, polkit, eudev, dbus, asciidoc.
Required by (1): plasma-thunderbolt.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install bolt'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/hardware/bolt.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/hardware/bolt
echo 'cde4fc6d4a188e37d088cf59a5b2d174ac4b03d57bf9d084d711ba92105c33c0 bolt-0.9.11.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/bolt
SRC=$SRC_ROOT/bolt-0.9.11
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf bolt-0.9.11.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
meson setup build --prefix=/usr --sysconfdir=/etc --libdir=lib \
--localstatedir=/var \
--buildtype=release \
-Dman=true \
-Dinstall-tests=false \
-Dprivileged-group=wheel
meson compile -C build
DESTDIR=$PKG meson install --no-rebuild -C build
install -d "$PKG/usr/lib/udev/rules.d"
cat > "$PKG/usr/lib/udev/rules.d/91-kdos-bolt.rules" <<'RULES'
ACTION=="add", SUBSYSTEM=="thunderbolt", RUN+="/usr/bin/dbus-send --system --type=method_call --dest=org.freedesktop.bolt /org/freedesktop/bolt org.freedesktop.DBus.Peer.Ping"
RULES
install -d "$PKG/etc/init.d"
cat > "$PKG/etc/init.d/43_boltd.sh" <<'KDOS_SH'
#!/bin/bash
NAME="boltd"
case "$1" in
start)
# No controller, nothing to authorise; the udev rule starts boltd if
# one appears later.
if [ -z "$(ls -A /sys/bus/thunderbolt/devices 2>/dev/null)" ]; then
echo "[SKIP] $NAME: no thunderbolt controller"
exit 0
fi
echo "[KDOS] Starting $NAME..."
dbus-send --system --type=method_call \
--dest=org.freedesktop.bolt /org/freedesktop/bolt \
org.freedesktop.DBus.Peer.Ping
;;
stop)
# Started by the bus, so not ours to stop; it ends with the machine.
;;
status)
# Running is owning the bus name, which is also what a client needs.
if dbus-send --system --print-reply --dest=org.freedesktop.DBus \
/ org.freedesktop.DBus.NameHasOwner string:org.freedesktop.bolt \
2>/dev/null | grep -q 'boolean true'; then
echo "$NAME is running"
else
echo "$NAME is not running"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac
KDOS_SH
chmod 755 "$PKG/etc/init.d/43_boltd.sh"
The switches, and why each is set:
--localstatedir=/var— Keep the device database, which holds the enrolled devices and their keys, at/var/lib/boltd. meson derives the state directory from the prefix, and the path is compiled into the daemon (BOLT_DBDIR) and created at install, so a prefix other than/usrwith no--localstatedirwould compileboltdto keep its keys somewhere else.-Dman=true— Build the manual pages,boltctl(1)andboltd(8), and fail without the tool that makes them. At the default,auto, they are built only whena2xis found, so they would be dropped silently whenever asciidoc is not installed first; it is independsfor this.-Dinstall-tests=false— Install none of the test programs, which is also upstream’s default. They are compiled in any case, since bolt has no option to skip building them; the ones that need umockdev are not built, because that dependency is optional and umockdev is not a port.-Dprivileged-group=wheel— The group named in the polkit rule bolt installs, which grants it enroll, authorize and manage.wheelis upstream’s default and a group in/etc/group. KDOS’s/etc/polkit-1/rules.d/50-kdos.rulesis read first and answers the same three actions with an administrator’s password for anybody at the machine, so bolt’s grant applies to none of them and letting a device onto the PCIe bus always asks (see What50-kdos.ruleschanges).
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/bolt, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf bolt-0.9.11-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/bolt, and runs the triggers its paths call for.
Contents
Installed programs: boltctl.
Installed directories: /usr/share/licenses/bolt, /var/lib/boltd.
Short descriptions
boltctl |
control the thunderbolt device manager |
Notes
No switch turns systemd off, because none is needed. bolt’s systemd meson option is marked DEPRECATED and read nowhere; the build installs a unit file only when dependency('systemd', required: false) finds systemd.pc, which the tree does not have, and in that case it creates the device database directory at install instead. Nothing links sd-bus either: boltd uses GDBus, and its readiness notifications are its own write to $NOTIFY_SOCKET, which is unset here, so they do nothing.
boltd is installed in /usr/libexec, the meson default, and the same path is written into the D-Bus service file’s Exec=.
Starting boltd. D-Bus activation is the only way boltd starts. Upstream’s 90-bolt.rules starts it through SYSTEMD_WANTS, which eudev ignores. build.sh adds two pokes for the two moments a controller can appear, each a D-Bus Ping to org.freedesktop.bolt, which activates boltd when it is not running and is answered by it when it is, so neither can start a second daemon:
91-kdos-bolt.rules, a udev rule that sends the ping on everyaddin thethunderboltsubsystem once the bus is up;/etc/init.d/43_boltd.sh, which sends it at boot when/sys/bus/thunderbolt/devicesis not empty. The coldplug replays theaddevents before the system bus has started, so the rule’sdbus-sendhas nothing to talk to then.
The udev rule cannot start the daemon itself: udevd kills whatever a rule runs once the event is handled. The init script’s stop does nothing, since the bus started the daemon, and its status reports whether the bus name has an owner.