Files
microduck/btd/systemd/sysusers.d
Pierre Rouanet 5162d4bba2 The app may update the robot, and pairing is the PIN alone
Two decisions, recorded in code and in the tests that keep them.

## An owner may start an update from their phone

`update.apply` over Bluetooth returned PERMISSION_DENIED, because updaterd's
change authority was root-only. That was the safe default while btd did not
exist; btd exists now, and M6's headline is a non-developer updating the robot
from the phone.

deploy/updater.toml now says `allow_users = ["btd"]`. Note how narrow the claim
is: "btd may relay an update request from the app", not "anything in the robot
group may replace the firmware". Reaching the socket and being allowed to change
the robot stay separate permissions.

By name, not by uid, and updaterd gained the same name resolution configd has:
systemd-sysusers allocates dynamically, so a number written into a shipped config
is right on the board it was written for and wrong on the next one. The numeric
`allow_uids`/`allow_gids` remain for a bench override.

`shipped_config_is_safe_for_a_client_robot` changed from "grant nobody" to three
sharper assertions: the shipped config grants by name and never by number, `btd`
must be present or the phone button is dead, and `allow_groups` must never contain
`robot` — which is the layering the whole design rests on.

The resolver is duplicated between updaterd and configd rather than shared. The
obvious home would be duck-ipc-proto, and that crate is types only: every service
speaks it, including the ones on the recovery path, so it may not grow a libc
dependency for two callers.

## Pairing is the PIN, and there is no button

Recorded as a decision rather than left as an open question. A per-robot PIN
already carries what a pairing window would add: if it is unique and printed under
the robot, knowing it requires physical access, and anyone who can read the sticker
can pick the robot up. A window would only defend against someone in range while
the factory default is still in place, and the answer to that is a real PIN.

A button would add a visible consent moment, a recovery path when the PIN is lost,
and defence in depth if a sticker is photographed. None is needed for v1, and each
stays additive: an enclosure with a button can gate `set_pairable` without changing
anything here.

The consequence is that security rests entirely on the PIN being per-robot, which
makes it a provisioning obligation rather than a software one — something must
generate it, print it, and record what was printed. That is updater-design.md
§5.7's per-device state, the same slot that owes us a serial number, and two things
wanting one home is a reason to define it once.

340 tests pass, clippy clean, aarch64 cross-compiles with no warnings. The name
resolution in updaterd is the same code verified in configd; the shipped config is
asserted by test rather than by hand.

Assisted-by: Claude:claude-opus-5
2026-08-04 17:16:53 +02:00
..