From f45e065994d3f714b1ce7bdfa9d191d9b0f3a542 Mon Sep 17 00:00:00 2001 From: Florian Schmidt Date: Sun, 15 Nov 2026 15:10:56 +0100 Subject: [PATCH] tools: register the updater in the normal command path (#24) Use /usr/local/bin for container updater discovery and print an absolute command path for custom shells. Preserve managed links and operator files; cover shell lookup without sbin. Closes #23 --- .agents/mind/gotchas.md | 1 + .agents/mind/index.md | 4 ++-- Directory.Build.props | 2 +- docs/proxmox.md | 15 ++++++++++++++- tools/lxc_update.py | 2 +- tools/proxmox/guest.py | 2 +- tools/proxmox/test_installer.py | 31 +++++++++++++++++++++++++++++++ tools/proxmox/test_update.py | 2 +- 8 files changed, 52 insertions(+), 7 deletions(-) diff --git a/.agents/mind/gotchas.md b/.agents/mind/gotchas.md index 53f687c..e20f249 100644 --- a/.agents/mind/gotchas.md +++ b/.agents/mind/gotchas.md @@ -17,5 +17,6 @@ - [2026-11-15] Compare copied/archived license bytes with source bytes. `read_text()` normalizes Windows CRLF while ZIP reads retain it; explicit LF/CRLF fixtures cover both checkouts. - [2026-11-15] Do not assume a bundled proxy or host-driven updates for LXC deployments. Use the operator's existing proxy and an in-container updater; preserve the public Host/Origin when the private backend uses HTTP. - [2026-11-15] A build-owned source/output cannot supply code later executed as root. Capture updater bytes from the verified archive before build handoff and atomically install them in the root-owned release, excluding build-supplied updater files. +- [2026-11-15] Container shells can omit `/usr/local/sbin`. Register the updater in `/usr/local/bin`, print an absolute-path fallback, and test real shell lookup with sbin excluded. ## Archive diff --git a/.agents/mind/index.md b/.agents/mind/index.md index 6e0b7a1..00b1f85 100644 --- a/.agents/mind/index.md +++ b/.agents/mind/index.md @@ -2,7 +2,7 @@ > Always-loaded. Everything else is on-demand. Update TOC when files change. ## Current Focus -- [2026-11-15] Validate live Linux/LXC and official provider login. 1.2.1 corrects deployment to use the existing HTTPS proxy and updates inside the CT. +- [2026-11-15] User report confirms Debian 13 NativeAOT server publish and legacy proxy disable. 1.2.2 fixes updater discovery; external proxy and official provider flows still need live verification. ## Invariants - Provider access/refresh tokens, API keys and cookies stay with the CLIs; only a pending login's authorization response may be relayed transiently (D2, D14). @@ -11,5 +11,5 @@ - Desktop/Stream Deck retain `snapshot.json` (D9); the optional authenticated server/worker transport is separate (D14). ## Table of Contents -- `gotchas.md` — 12 entries — CLI login, in-container updater trust boundaries, publication checks and Avalonia tooltips. +- `gotchas.md` — 13 entries — CLI login, updater trust/PATH boundaries, publication checks and Avalonia tooltips. - `architecture.md` — 7 entries — Fleet analysis, attribution, migration, authentication, durability, Proxmox and publication. diff --git a/Directory.Build.props b/Directory.Build.props index 858ab57..3eabeff 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 1.2.1 + 1.2.2 net10.0 14 enable diff --git a/docs/proxmox.md b/docs/proxmox.md index 649add1..ba0b0ae 100644 --- a/docs/proxmox.md +++ b/docs/proxmox.md @@ -56,6 +56,19 @@ CLI profiles and history. Official provider CLIs keep their own update/login lif The updater is included in each binary release, so switching/rolling back releases updates it too. Its root-executed code comes directly from the verified source archive; build-user modifications to extracted source or build output cannot replace the installed updater. +The command is installed in `/usr/local/bin`; the updater also prints its absolute path for +shells with a custom PATH. Version 1.2.1 used `/usr/local/sbin`, which some container shells omit. +For that version you can invoke `/usr/local/sbin/finaltoken-update` directly, or add the normal +command without rebuilding: + +```bash +mkdir -p /usr/local/bin +ln -s /opt/finaltoken/current/finaltoken-update /usr/local/bin/finaltoken-update +finaltoken-update --dry-run +``` + +This does not overwrite an existing file. Later updates preserve the matching managed link; +the old valid sbin link can remain for compatibility. ```bash finaltoken-update --dry-run @@ -141,7 +154,7 @@ credentials and runtime data independently of Git ignore rules, rejects symlinks | `/etc/finaltoken/server.json`, `worker.json` | Operator account/profile configuration | | `/etc/finaltoken/server.env`, `worker.env` | Root-only service environment and transport keys | | `/opt/finaltoken/releases/`, `/opt/finaltoken/current` | Root-owned native releases and updater | -| `/usr/local/sbin/finaltoken-update` | Link to the active release's in-container updater | +| `/usr/local/bin/finaltoken-update` | Link to the active release's in-container updater | | `/var/lib/finaltoken-server/`, `/var/lib/finaltoken-worker/` | Metadata, history and CLI-owned profiles | | `/var/cache/finaltoken-build/` | Separate build user's cache; temporary source is removed | diff --git a/tools/lxc_update.py b/tools/lxc_update.py index 8635965..618ea67 100644 --- a/tools/lxc_update.py +++ b/tools/lxc_update.py @@ -71,7 +71,7 @@ def main(argv=None): guest = load("finaltoken_guest_update", source / "tools/proxmox/guest.py") guest.provision({"installer": marker["installer"], "action": "update", "ctid": marker["ctid"], "sourceSha256": checksum}, archive) - print("Update complete. Future updates: finaltoken-update") + print("Update complete. Future updates: " + str(guest.UPDATER)) return 0 diff --git a/tools/proxmox/guest.py b/tools/proxmox/guest.py index 53ff48a..d81c482 100644 --- a/tools/proxmox/guest.py +++ b/tools/proxmox/guest.py @@ -22,7 +22,7 @@ APP = Path("/opt/finaltoken") BUILD = Path("/var/cache/finaltoken-build") SERVER_HOME = Path("/var/lib/finaltoken-server") WORKER_HOME = Path("/var/lib/finaltoken-worker") -UPDATER = Path("/usr/local/sbin/finaltoken-update") +UPDATER = Path("/usr/local/bin/finaltoken-update") SYSTEMD = Path("/etc/systemd/system") diff --git a/tools/proxmox/test_installer.py b/tools/proxmox/test_installer.py index 24fb227..4c3557c 100644 --- a/tools/proxmox/test_installer.py +++ b/tools/proxmox/test_installer.py @@ -299,6 +299,37 @@ class GuestTests(unittest.TestCase): guest.install_updater() self.assertEqual(b"operator file", path.read_bytes()) + def test_updater_is_discoverable_without_sbin_in_shell_path(self): + git = shutil.which("git") + windows_bash = Path(git).resolve().parents[1] / "bin/bash.exe" if git else Path("missing") + bash = str(windows_bash) if os.name == "nt" and windows_bash.is_file() else shutil.which("bash") + self.assertIsNotNone(bash, "Bash is required for container command lookup verification") + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + app = root / "app" + target = app / "current/finaltoken-update" + target.parent.mkdir(parents=True) + target.write_bytes(b"#!/bin/sh\nprintf 'synthetic updater executed\\n'\n") + target.chmod(0o755) + registered = root / guest.UPDATER.as_posix().lstrip("/") + searched = root / "usr/local/bin" + searched.mkdir(parents=True) + with contextlib.ExitStack() as stack: + stack.enter_context(patch.object(guest, "APP", app)) + stack.enter_context(patch.object(guest, "UPDATER", registered)) + if os.name == "nt": + # Windows may deny symlink creation; only substitute that OS operation. + # The real Bash lookup/execution still uses the actual installed path. + stack.enter_context(patch.object(Path, "symlink_to", lambda path, destination: shutil.copy2(destination, path))) + guest.install_updater() + env = dict(os.environ, PATH=str(searched)) + env.pop("BASH_ENV", None) + result = subprocess.run([bash, "--noprofile", "--norc", "-c", + "command -v finaltoken-update && finaltoken-update"], env=env, + text=True, capture_output=True, timeout=10) + self.assertEqual(0, result.returncode, result.stderr) + self.assertIn("synthetic updater executed", result.stdout) + def test_codex_npm_install_creates_the_configured_launcher(self): node, npm = shutil.which("node"), shutil.which("npm") if not node or not npm: diff --git a/tools/proxmox/test_update.py b/tools/proxmox/test_update.py index dbb3218..fcb97fb 100644 --- a/tools/proxmox/test_update.py +++ b/tools/proxmox/test_update.py @@ -63,7 +63,7 @@ class ContainerUpdateTests(unittest.TestCase): text=True, capture_output=True, check=True) def publish(self, version, failure=False): - code = "import hashlib, json, tarfile\nfrom pathlib import Path\n" + code = "import hashlib, json, tarfile\nfrom pathlib import Path\nUPDATER = Path('/usr/local/bin/finaltoken-update')\n" code += "def provision(manifest, archive):\n" code += " assert hashlib.sha256(archive.read_bytes()).hexdigest() == manifest['sourceSha256']\n" if failure: