Repository navigation
Description
Why
Setting up a new host today is a long list of commands (users, directories, units, the listener config with the owner's IDs, the bot token, a deploy key, the instance config). Each step can go wrong, and pasted blocks that read the keyboard eat the lines after them. Worse, if the person pastes a script that someone else wrote, that script decides the owner ID: a planted owner_id would give the bot to someone else.
Proposal
pullgate bootstrap (as root, after install.sh), in this order:
- Makes the users, directories and units as the README says (same code as
pullgate doctor, feat: pullgate doctor, read-back of modes, and no silent "asked" when a question was not delivered #28, checks). - Asks for the bot token with
systemd-ask-password(no echo, not in shell history, not an argument), checks it withgetMe, and stores it as/etc/pullgate/bot-token(0600). - Pairing: prints a one-time code (for example 6 words or 8 digits, valid 10 minutes) on the console and waits. The owner sends that code to the bot. pullgate takes
owner_idandchat_idfrom that message (private chat only) and writeslistener.toml. Nobody types or pastes the IDs, so a script cannot plant them. A wrong code, a group chat or a timeout writes nothing. - For each instance given (
--instance NAME --repo URL): makes the deploy key on the host (ssh-keygen, the private key never leaves), prints the public key to add to the repo as read-only, pins the git host key (for GitHub: from GitHub's published keys, shown with fingerprint for the owner to compare), writes a minimal instance config, and waits untilgit ls-remoteworks. - Runs
pullgate doctorand enables the units.
The README "Install" becomes: install.sh, then pullgate bootstrap. A one-paste form serves the script from a public tag with its SHA-256 printed in the release notes, so a person checks it against GitHub, not against what the person who sent the command wrote.
pullgate's own files (listener.toml, the token, the instance mode, the units) are pullgate's: a later config tool (for example Ansible run by an instance) must not write them; DESIGN.md says so and doctor warns when they changed outside pullgate.
Done when
-
pullgate bootstrapdoes steps 1–5 with tests (fake Telegram for the pairing: right code, wrong code, group chat, timeout; fake git host for the key step). - The pairing writes the IDs only from the message that carries the code; a test proves a config file or argument cannot set them in bootstrap.
- The token is read without echo and never appears in logs, arguments or the environment of child processes (a test).
- The install CI job (test: CI installs pullgate as the README says and runs a full loop under the real units #27) uses
pullgate bootstrapon a fake Telegram. - README and DESIGN.md describe it; THREAT-MODEL.md covers planted IDs, the token entry and the pairing code.
Activity
groupsky commentedon Nov 19, 2026
Done in #48 (squash commit 4ab136a), except steps 1 and 5.
pullgate bootstrapdoes steps 1–5 with tests. Steps 2, 3 and 4 are done:TestPairRightCode,TestPairWrongCode,TestPairGroupChat,TestPairTimeout(fake Telegram),TestWaitRemoteandTestKeptConfigIsProbedWithItsOwnRepo(a fake git host),TestGitHubKey,TestOtherHostNeedsKnownHosts,TestExistingKeyMustBeRootsFile,TestAPIURLOnlyTelegramOrLoopback, all ininternal/bootstrap/bootstrap_test.go. Steps 1 and 5 (make the users, directories and units; runpullgate doctorand enable the units) needpullgate doctor(feat: pullgate doctor, read-back of modes, and no silent "asked" when a question was not delivered #28). feat: pullgate bootstrap makes the users and units, runs doctor and enables the units #49 takes them, and feat: pullgate doctor, read-back of modes, and no silent "asked" when a question was not delivered #28 blocks it. This box stays open for that reason.TestPlantedIDsAreNotUsed(a plantedlistener.toml,--owner-id,--chat-id,--configand a variable are refused or not used),TestPlantedFileStaysWhenPairingFails.systemd-ask-password, or--token-stdin) and never appears in logs, arguments or the environment of child processes:TestTokenNeverLeaks(fakesystemd-ask-passwordandssh-keygenlog their arguments and environment),TestBadToken.pullgate bootstrapon a fake Telegram:test/units/full-loop.shstep "3a" (the code goes throughfaketg.py, and the job checksowner_id,chat_idand the file modes). CI passed on feat: pullgate bootstrap with pairing, so nobody types or pastes the owner ID #48.--api-url.Not done, and not in "Done when": the one-paste form with a SHA-256 in the release notes.