start path: a signed package is verified with the keys this build trusts; engine-missing notices name Update engine and strata update

This commit is contained in:
Niko1221 committed 2026-10-15 17:38:20 +02:00
1 parent 10a326a90c
commit 5a8985620c
3 files changed
+49 -4

No files matched your search

+2 -1
View File
@@ -58,7 +58,8 @@ In this order, each refusal names the cause; none of them starts anything and no
If a package fails (5) or (4) and no other package fits this PC, the start ends with `EngineIntegrityError`
(exit code 5): "The engine package failed its integrity check, so it was not started: 0.1.45 linux-x86_64-cuda:
libcudart.so.13 does not match its recorded SHA-256. Repair or reinstall the engine component from the Terminal". A package
libcudart.so.13 does not match its recorded SHA-256. Repair or reinstall the engine component with Update engine in the app's
Settings or `strata update` in the Terminal". A package
for another GPU or an older driver is `EngineMissing` with its reason. A tampered newer package never falls back silently
to nothing: a good older package is used and the tampered one is listed under `problems` in `strata components engine`.
+12 -3
View File
@@ -80,8 +80,8 @@ class EngineMissing(acquisition.AcquisitionRefused):
RuntimeError.__init__(
self,
f"No engine for this PC was found{where}: {reason}. The app never downloads an engine while it "
f"starts or serves. Install the engine component for your GPU from the Terminal "
f"(`strata install`) or copy an engine package into the component folder.")
f"starts or serves. Download the engine for your GPU with Update engine in the app's Settings, or with "
f"`strata update` (or `strata install`) in the Terminal, or copy an engine package into the component folder.")
self.what = "the engine component"
self.command = "strata install"
@@ -99,7 +99,8 @@ class EngineIntegrityError(EngineMissing):
RuntimeError.__init__(
self,
f"The engine package failed its integrity check, so it was not started: {reason}. Repair or reinstall "
f"the engine component from the Terminal (`strata install`); the app never downloads one while it runs.")
f"the engine component with Update engine in the app's Settings or `strata update` in the Terminal "
f"(`strata install` also works); the app never downloads one while it runs.")
self.what = "the engine component"
self.command = "strata install"
@@ -304,6 +305,14 @@ def verify_signature(component: "EngineComponent", environ=None) -> str:
if required:
raise IntegrityProblem("the package is not signed and this PC requires signed components")
return "unsigned"
if _verifier is None:
# the keys this build trusts (update_keys.json, plus the explicit test-key file) become the verifier on first use, so
# a signed package is verified on every start without anything having to register it first
from strata_control import signing
try:
signing.ensure_component_verifier()
except signing.SignatureError as exc:
raise IntegrityProblem(f"this PC's update keys cannot be read ({exc})") from None
if _verifier is None:
if required:
raise IntegrityProblem("the package is signed but this build cannot check signatures yet")
+35
View File
@@ -406,6 +406,41 @@ class EngineUpdate(UpdaterCase):
self.assertEqual(done.stdout.strip(), "[]")
class StartPathSignature(UpdaterCase):
"""A start verifies a signed package with the keys this build trusts, without anything registering a verifier first."""
def setUp(self):
super().setUp()
self.pub = self.root / "feed-key.pub.json"
self.pub.write_text(json.dumps({"keys": [signing.public_part(self.key)]}))
patch = mock.patch.dict(os.environ, {"STRATA_UPDATE_TRUSTED_KEYS": str(self.pub)})
patch.start()
self.addCleanup(patch.stop)
ec.register_signature_verifier(None)
def test_signed_packages_verify_and_a_forged_signature_is_refused_on_every_start(self):
folder = fx.build_package(self.root / "signed", "0.1.46", key=self.key)
target = self.components / "engine" / folder.name
target.parent.mkdir(parents=True)
shutil.copytree(folder, target)
self.assertEqual(ec.verify_signature(ec.read_manifest(target)), "verified")
manifest = json.loads((target / ec.MANIFEST).read_text())
manifest["notes"] = "changed after signing"
(target / ec.MANIFEST).write_text(json.dumps(manifest))
ec.register_signature_verifier(None)
with self.assertRaises(ec.EngineMissing) as caught:
ec.resolve(self.components, backend="cuda")
self.assertIn("signature", str(caught.exception))
def test_without_trusted_keys_a_signed_package_is_unverified_and_required_signing_refuses_it(self):
folder = fx.build_package(self.root / "signed", "0.1.46", key=self.key)
with mock.patch.dict(os.environ, {"STRATA_UPDATE_TRUSTED_KEYS": ""}):
ec.register_signature_verifier(None)
self.assertEqual(ec.verify_signature(ec.read_manifest(folder)), "unverified")
with self.assertRaises(ec.IntegrityProblem):
ec.verify_signature(ec.read_manifest(folder), {ec.ENV_REQUIRE_SIGNED: "1"})
class LazyModel(UpdaterCase):
"""A server that is "ready" with its model unloaded has not generated anything yet; the test start forces the load and the probe."""