Skip to content

feat: pullgate bootstrap with pairing, so nobody types or pastes the owner ID - #48

Merged
groupsky merged 2 commits into
mainfrom
feat/31-bootstrap
Nov 19, 2026
Merged

groupsky merged 2 commits into
mainfrom
feat/31-bootstrap

Conversation

@groupsky

@groupsky groupsky commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

pullgate bootstrap, as root on a console of a new host:

  1. Checks every --instance NAME --repo URL first (and --branch, --apply, --known-hosts). Nothing is asked or written before these pass.
  2. Reads the bot token with systemd-ask-password (no echo, not in the history, not an argument), or with --token-stdin from stdin. getMe checks it.
  3. Pairing: prints a one-time code of 8 digits, valid for 10 minutes. The owner sends it to the bot in the private chat. owner_id and chat_id come only from that message. 5 wrong codes, the code from a group, or a timeout stop it and write nothing. Then it writes bot-token (0600) and listener.toml (root, group of the listener, 0640).
  4. For each instance: makes the deploy key with ssh-keygen and prints the public key ("add it as a read-only deploy key"), pins the host key (the github.com ed25519 key that the binary carries, with its fingerprint; another host needs --known-hosts FILE), writes a minimal instance config when none exists, and waits until git ls-remote can read the branch.

There is no flag, key or variable for the IDs. Programs that bootstrap starts get only PATH and LC_ALL.

The CI job "README install and a full loop under the units" now writes bot-token and listener.toml with pullgate bootstrap on the fake Telegram, and checks that the IDs come from the pairing.

Not in this PR: step 1 (make the users, directories and units) and step 5 (run pullgate doctor, enable the units). They need pullgate doctor (#28). A new issue, blocked by #28, takes them.

Not in this PR: the one-paste form with a SHA-256 in the release notes (it is in the proposal, not in "Done when").

Tests

internal/bootstrap/bootstrap_test.go: TestPairRightCode, TestPairWrongCode, TestPairGroupChat, TestPairTimeout, TestPlantedIDsAreNotUsed, TestPlantedFileStaysWhenPairingFails, TestTokenNeverLeaks, TestBadToken, TestGitHubKey, TestOtherHostNeedsKnownHosts, TestWaitRemote (a fake git host that appears later).

Reviews

The security reviewer and a correctness review ran. Fixed:

  • high: --api-url could point to a server that changes the sender ID. Now only the real Bot API, or a test server on 127.0.0.1.
  • medium: http://127.0.0.1:80@host passed the prefix check, in bootstrap and in the listener config. Now config.CheckAPIURL parses the URL (tests in both packages).
  • bootstrap must run as root, and checks that /etc/pullgate is safe; listener.toml is written before the token, and the directory is synced.
  • a kept NAME.toml is probed with its own repo, key and known hosts, and nothing else is written for it.
  • an existing key must be a regular file of root; a .pub without a key is refused.
  • all old updates are skipped, not only the first 100.
  • docs: each run must name every instance of the host (listener.toml lists only the instances of the run).

Fixes #31

🤖 Generated with Claude Code

…owner ID

Fixes #31

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ecks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@groupsky
groupsky merged commit 4ab136a into main Nov 19, 2026
10 of 11 checks passed
@groupsky
groupsky deleted the feat/31-bootstrap branch November 19, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: pullgate bootstrap with pairing, so nobody types or pastes the owner ID

1 participant