hub + installer (unreleased): fixes after an independent review of the night's code — per-thing mail cooldown, a box's input bounded and checked, both off-site account types on a reset, a quiet first run, strict-mode installer
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
a044eb8c16
commit
f618c591eb
31 files changed
+796
-88
No files matched your search
@@ -1,5 +1,11 @@
|
||||
## Unreleased (2026-11-14 night) — the installer: a new box trusts Proxmox by a copy of its own root CA (R-1380, D80) — on `main`, NOT tagged, so NOT published
|
||||
|
||||
- **Installer, after review (2026-11-14, not tagged):** `resolve_pve_trust` under `set -euo pipefail` — the installer's
|
||||
own mode. A failed pipeline inside `fp=$(…)` ended the whole installer when Proxmox did not answer; now it leaves
|
||||
the fingerprint empty and goes on (test `test_pve_trust_no_answer_from_proxmox_does_not_end_the_installer`, seen
|
||||
red). The proof reads openssl's answer whole and searches it after, in place of a pipe into `grep -q` (reasoned by
|
||||
the reviewer as a way to read a good copy as „not verified”; NOT reproduced). The trust tests now run the function
|
||||
under strict mode.
|
||||
- `felhom-host-install.sh` `resolve_pve_trust` (new, called by `step_agent_config`): copy `/etc/pve/pve-root-ca.pem` to
|
||||
`/etc/felhom-agent/pve-root-ca.pem` when it is one unexpired CA certificate; prove a TLS handshake to
|
||||
`127.0.0.1:8006` with the copy alone; then write `proxmox.tls.ca_file` and NO fingerprint. Anything else: the served
|
||||
|
||||
@@ -3188,7 +3188,8 @@ resolve_pve_trust() {
|
||||
local addr="${PVE_API_ADDR:-127.0.0.1:8006}" fp why=""
|
||||
PVE_CA_FILE=""; PVE_TLS_FP=""
|
||||
# the SERVED leaf cert fingerprint (not pvesh node info — may differ): the fallback
|
||||
fp=$(echo | openssl s_client -connect "$addr" 2>/dev/null | openssl x509 -noout -fingerprint -sha256 2>/dev/null | sed 's/.*=//')
|
||||
# `|| fp=""`: under `set -euo pipefail` a failed pipeline inside the substitution would END the installer here.
|
||||
fp=$(echo | openssl s_client -connect "$addr" 2>/dev/null | openssl x509 -noout -fingerprint -sha256 2>/dev/null | sed 's/.*=//') || fp=""
|
||||
if [[ ! -r "$src" ]]; then
|
||||
why="$src is not readable"
|
||||
elif [[ "$(grep -c 'BEGIN CERTIFICATE' "$src")" != "1" ]] || grep -q 'PRIVATE KEY' "$src"; then
|
||||
@@ -3207,8 +3208,12 @@ resolve_pve_trust() {
|
||||
if install -m 0644 "$src" "$dst.felhom-new" && mv -f "$dst.felhom-new" "$dst"; then
|
||||
# THE PROOF, before the config names the copy: verified by the copy ALONE (no system roots), for the address
|
||||
# the agent calls (the IP must be in the certificate, as the agent's own check demands)
|
||||
if echo | openssl s_client -connect "$addr" -CAfile "$dst" -no-CApath -verify_return_error \
|
||||
-verify_ip "${addr%%:*}" 2>&1 | grep -q 'Verify return code: 0 (ok)'; then
|
||||
# The answer is read WHOLE into a variable and searched after: `… | grep -q` leaves at its first match while
|
||||
# s_client still writes, and under `pipefail` that broken pipe would read as "did not verify" for a good copy.
|
||||
local proof
|
||||
proof=$(echo | openssl s_client -connect "$addr" -CAfile "$dst" -no-CApath -verify_return_error \
|
||||
-verify_ip "${addr%%:*}" 2>&1) || true
|
||||
if grep -q 'Verify return code: 0 (ok)' <<<"$proof"; then
|
||||
PVE_CA_FILE="$dst"
|
||||
log_info " Proxmox trust: the box's own root CA ($dst; a handshake to $addr verified with it alone) — no pinned certificate"
|
||||
return 0
|
||||
|
||||
@@ -763,8 +763,10 @@ class _PVE:
|
||||
self.proc.kill(); self.proc.wait()
|
||||
|
||||
|
||||
def _trust_run(source, dry=False):
|
||||
"""Run resolve_pve_trust against a real TLS server. Returns (ca_file, fp, copy bytes or None, source bytes, output, leaf fp, dst)."""
|
||||
def _trust_run(source, dry=False, dead_port=False):
|
||||
"""Run resolve_pve_trust against a real TLS server — under `set -euo pipefail`, as the installer itself runs (line
|
||||
195 of the script): a function that only works without strict mode proves nothing about the installer.
|
||||
Returns (ca_file, fp, copy bytes or None, source bytes, output, leaf fp, dst)."""
|
||||
if not shutil.which("openssl"):
|
||||
return None
|
||||
sb = Sandbox()
|
||||
@@ -772,9 +774,10 @@ def _trust_run(source, dry=False):
|
||||
try:
|
||||
dst = sb.path("etc-felhom-agent", "pve-root-ca.pem")
|
||||
src = os.path.join(pve.dir, source)
|
||||
rc, out = sb.run(prelude(dry) + func("resolve_pve_trust") +
|
||||
port = 1 if dead_port else pve.port # port 1: nothing listens → the handshake cannot even start
|
||||
rc, out = sb.run(prelude(dry) + func("resolve_pve_trust") + 'set -euo pipefail\n'
|
||||
'PVE_CA_SOURCE="%s" PVE_CA_COPY="%s" PVE_API_ADDR=127.0.0.1:%d\nresolve_pve_trust\n'
|
||||
'echo "RESULT ca=[$PVE_CA_FILE] fp=[$PVE_TLS_FP]"\n' % (src, dst, pve.port))
|
||||
'echo "RESULT ca=[$PVE_CA_FILE] fp=[$PVE_TLS_FP]"\n' % (src, dst, port))
|
||||
assert rc == 0, out
|
||||
m = re.search(r"RESULT ca=\[(.*?)\] fp=\[(.*?)\]", out)
|
||||
assert m, out
|
||||
@@ -814,6 +817,18 @@ def test_pve_trust_a_source_that_is_not_a_ca_is_never_copied():
|
||||
assert why in out, "%s: the reason is not named:\n%s" % (source, out)
|
||||
|
||||
|
||||
def test_pve_trust_no_answer_from_proxmox_does_not_end_the_installer():
|
||||
"""Found by review 2026-11-14: under `set -euo pipefail` a failed pipeline inside `fp=$(…)` ended the whole installer at
|
||||
that line. Proxmox not answering (it restarts) must leave the function running to its end: no CA file (no proof), no
|
||||
fingerprint, and the two warnings — the run reaches RESULT."""
|
||||
r = _trust_run("ca.pem", dead_port=True)
|
||||
if r is None:
|
||||
print(" (skipped: no openssl here)"); return
|
||||
ca, fp, _, _, out, _, _ = r
|
||||
assert ca == "" and fp == "", "nothing answered, so nothing can be proven or pinned. Got ca=%r fp=%r\n%s" % (ca, fp, out)
|
||||
assert "did not verify" in out and "could not compute TLS fingerprint" in out, out
|
||||
|
||||
|
||||
def test_pve_trust_dry_run_writes_nothing():
|
||||
r = _trust_run("ca.pem", dry=True)
|
||||
if r is None:
|
||||
|
||||
Reference in new issue
Block a user