tools: register the updater in the normal command path #24

Merged
schmidt.florian merged 1 commits from 23-updater-path into master 2026-11-15 15:10:58 +01:00
8 changed files with 52 additions and 7 deletions
Showing only changes of commit afa6d83f2a - Show all commits
+1
View File
@@ -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
+2 -2
View File
@@ -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.
+1 -1
View File
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.2.1</Version>
<Version>1.2.2</Version>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>14</LangVersion>
<Nullable>enable</Nullable>
+14 -1
View File
@@ -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 |
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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")
+31
View File
@@ -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:
+1 -1
View File
@@ -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: