fix: reconcile configured APT effect without retroactive acceptance and retain host reboot evidence
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 20:00:20 +01:00
parent 34d695a778
commit b08734065a
26 changed files with 2006 additions and 36 deletions
+53
View File
@@ -1,5 +1,58 @@
# Typed RootHelper bridge contract (implementation, not native acceptance)
## Host reboot evidence and historical configured effect (Spec 1.13)
An ambient `reboot_required=true` is honest pending evidence, not an implicit
reboot request or a failed package postcondition. Future fixture effects must
prove equal HOST flags before/after, unchanged boot and no private-worker flag.
The parent captures `active/host-reboot-before.json` **before unshare/private
`/run`**. Schema 1 fields are `transaction_sha256`, `job_payload_sha256`,
`effect_armed_ledger_id`, `grant_id`, `boot_id`, `host_reboot_required` (bool),
and `observed_at_ms`, plus `schema_version`. Creation is exclusive and fsynced;
its observation must belong to the original grant window. New native prechecks
use schema 2, retaining the old exact checks and adding
`host_reboot_before_sha256` and `host_reboot_required_before`. The child binds the
saved host observation; its private `/run` never measures the host flag.
After real APT success the parent verifies the current host flag equals the
saved value, boot is unchanged and `sandbox-result.reboot_required` is false.
False/false and true/true are valid; either change or a private-worker flag
vetoes acceptance. Outcome evidence includes `host_reboot_required_before`,
`host_reboot_required_after`, `host_reboot_before_sha256`,
`reboot_required_introduced:false`; `reboot_required` truthfully retains ambient
true. Ordinary acceptance record **schema 3** explicitly binds those fields and
`native_prechecks_schema_version:2`. The reader rejects old record schemas or
inconsistent values. Separate future recovery records use schema 2 and retain
their distinct `rmm.apt.native-recovery` type. Noop observations remain effect-free
and report their actual current reboot flag. Fresh planning adds the required
public bool `host_reboot_required`; known ambient true is shown in the fixed
WebUI plan reason.
Historical grant `33775478-15b0-46ec-b059-44f500dbb0b6` had **no host-before
sample**. It must never acquire retroactive success or an acceptance record.
Fixed mode `verify-configured-recovery` receives the same eight original binding
fields as `verify-partial`. Only its signed schema-4 configure-only job, old
provider `5ff260…`, old schema-1 prechecks, original partial grant `31ef5e5e…` /
proof `dc3bf387…`, preserved recovery once marker, exact Configure hook, APT exit
0 and private-worker false are eligible. It checks complete stable installed
1.0 state, clean audit, actual payload, unchanged boot, idle locks and current
host marker contents twice, rechecking all thirteen immutable witnesses.
Output is `known_failed` /
`APT_RECOVERY_CONFIGURED_ACCEPTANCE_REBOOT_FLAG_VERIFIED`. Its 24-field proof
contains the original eight bindings, type/schema, original evidence digest,
partial proof hash, original baseline and current snapshot hashes/fingerprint,
payload hash, full snapshot, check time, `effect_complete:true`,
`partial_effect:false`, `postconditions_passed:false`, `reboot_required:true`,
`host_reboot_required:true` and `host_reboot_marker_sha256`. No ctime-based
inference becomes a before measurement. It writes nothing and runs no package
mutation. Rust independently verifies the saved signature/old unknown code,
appends a separate immutable proof, and leaves consumption locked until normal
signed RootSync. Native classification and future 1.1 acceptance remain pending
until actually executed; **81 local Python tests passed**, including both actual
APT argument regressions under the readonly unprivileged offline container.
## Configure-only partial recovery (schema 4, local implementation)
This is a **new, separately WebUI-approved** dev-test native action. Schema 4
+18 -1
View File
@@ -1,6 +1,23 @@
# Root-helper APT transaction provider / explicit first native acceptance
**Current 2026-11-13:** The Cloud fixture retry reached armed hook and APT exit 0,
**Latest 2026-11-13:** The separately WebUI-approved configure-only attempt
`33775478…` reached APT 0 and completely installed fixture 1.0, but old provider
`5ff260…` rejected acceptance on the actual host reboot flag. Its private worker
reported false; the historical job had no HOST-before sample. It remains
**unknown** (`FIXTURE_UNEXPECTED_REBOOT_REQUIRED`), with no acceptance record,
Root scope closed and APT endpoint stopped. No before measurement or successful
acceptance is inferred retrospectively.
New source implements an original-bound readonly failed-effect classification
and a parent-namespace host-before/after contract for future jobs, matching
Spec 1.13. Ambient true/true is reported honestly; changed host flags, private
worker flags or changed boot reject acceptance. All **81 Python tests passed**
in the readonly unprivileged offline container, including actual APT argument
regressions with guarded fake effects and unchanged real/copied status. Native
classification/new-runtime 1.1 acceptance remain pending. See
[`HELPER-CONTRACT.md`](HELPER-CONTRACT.md) for the exact versioned contract.
**Earlier 2026-11-13:** The Cloud fixture retry reached armed hook and APT exit 0,
leaving fixture 1.0 unpacked/unconfigured. An original-bound readonly proof and
normal signed RootSync now classified that original attempt as **failed**
(`APT_PARTIAL_UNCONFIGURED_VERIFIED`), preserving all histories/tombstones.
+242 -12
View File
@@ -41,6 +41,12 @@ FIXTURE_RECIPES = {'rmm-apt-fixture-install-1.0': (None, '1.0'),
# dpkg-deb control/payload inspection. No runtime-supplied fixture hash is trusted.
FIXTURE_SHA256 = {'1.0': '74036ae81223deab3aae994fd2a2a695af408741777e1ce17dcb4e32f1235867',
'1.1': 'ef67c9fe0ba1443fcfe465768e1204763063c369a2a1da04af6027d8a9c00491'}
HISTORICAL_CONFIGURED_RECOVERY = {
'grant_id': '33775478-15b0-46ec-b059-44f500dbb0b6',
'previous_grant_id': '31ef5e5e-5dbd-4428-a9a1-cbd15de2f5a0',
'partial_proof_sha256': 'dc3bf3870ea77c12f9291bac712c53ae72194eaec980a8646155a7fb5c0dbe21',
'provider_sha256': '5ff260f75cb2959678f6be729d3a806a4ea29febd5ae4003317fed41afc25327',
}
ENV = {'PATH': '/usr/sbin:/usr/bin:/sbin:/bin', 'LC_ALL': 'C',
'DEBIAN_FRONTEND': 'noninteractive', 'HOME': '/root'}
NAME = re.compile(r'[a-z0-9][a-z0-9+.-]{1,127}\Z')
@@ -453,17 +459,22 @@ def validate_acceptance_record(proof, scope, runtime):
exact(proof, 'schema_version scope runtime test_acceptance noProductionEvidence '
'test_result_id transaction_sha256 job_payload_sha256 grant_id job_id attempt_id '
'authorization_id plan_sha256 native_prechecks_sha256 hook_marker_sha256 '
'postconditions_sha256 completed_at_ms')
require(type(proof['schema_version']) is int and proof['schema_version'] == 2 and
'postconditions_sha256 completed_at_ms native_prechecks_schema_version host_reboot_before_sha256 '
'host_reboot_required_before host_reboot_required_after reboot_required_introduced')
require(type(proof['schema_version']) is int and proof['schema_version'] == 3 and
proof['scope'] == scope and proof['runtime'] == runtime and
proof['test_acceptance'] is True and proof['noProductionEvidence'] is True,
'NATIVE_PROOF_SCOPE_OR_RUNTIME')
for key in ('transaction_sha256', 'job_payload_sha256', 'plan_sha256',
'native_prechecks_sha256', 'hook_marker_sha256', 'postconditions_sha256'):
'native_prechecks_sha256', 'hook_marker_sha256', 'postconditions_sha256', 'host_reboot_before_sha256'):
token(proof[key], HASH, 'NATIVE_PROOF_HASH')
for key in ('test_result_id', 'grant_id', 'job_id', 'attempt_id', 'authorization_id'):
token(proof[key], IDENT, 'NATIVE_PROOF_ID')
require(type(proof['completed_at_ms']) is int and proof['completed_at_ms'] > 0, 'NATIVE_PROOF_TIME')
require(type(proof['native_prechecks_schema_version']) is int and proof['native_prechecks_schema_version'] == 2 and
type(proof['host_reboot_required_before']) is bool and type(proof['host_reboot_required_after']) is bool and
proof['host_reboot_required_before'] == proof['host_reboot_required_after'] and
proof['reboot_required_introduced'] is False, 'NATIVE_PROOF_BOUND_HOST_REBOOT')
def runtime_identity():
@@ -744,11 +755,63 @@ def sandbox_checks(workspace=None):
def native_prechecks(context):
checks = sandbox_checks()
context.check_deadline()
return {'schema_version': 1, 'transaction_sha256': context.transaction_sha256,
before, before_sha = load_host_reboot_before(context)
return {'schema_version': 2, 'transaction_sha256': context.transaction_sha256,
'job_payload_sha256': context.job_payload_sha256, 'boot_id': context.boot_id,
'host_reboot_before_sha256': before_sha,
'host_reboot_required_before': before['host_reboot_required'],
'checks': checks}
def capture_host_reboot_before(context):
"""Parent namespace only, BEFORE unshare replaces /run with private tmpfs."""
context.check_deadline()
record = {'schema_version': 1, 'transaction_sha256': context.transaction_sha256,
'job_payload_sha256': context.job_payload_sha256,
'effect_armed_ledger_id': context.effect_armed_ledger_id,
'grant_id': context.grant_id, 'boot_id': context.boot_id,
'host_reboot_required': Path('/run/reboot-required').exists(),
'observed_at_ms': time.time_ns() // 1000000}
durable_once(ACTIVE / 'host-reboot-before.json', record)
context.check_deadline()
def load_host_reboot_before(context):
raw = sealed_read(ACTIVE / 'host-reboot-before.json')
record = json_bytes(raw)
exact(record, 'schema_version transaction_sha256 job_payload_sha256 effect_armed_ledger_id '
'grant_id boot_id host_reboot_required observed_at_ms')
require(raw == canonical(record) and type(record['schema_version']) is int and record['schema_version'] == 1 and
all(record[key] == getattr(context, key) for key in
('transaction_sha256', 'job_payload_sha256', 'effect_armed_ledger_id', 'grant_id', 'boot_id')) and
type(record['host_reboot_required']) is bool and type(record['observed_at_ms']) is int and
context.not_before_ms <= record['observed_at_ms'] < context.start_before_ms and
record['observed_at_ms'] <= time.time_ns() // 1000000, 'HOST_REBOOT_BEFORE_BINDING')
return record, digest(raw)
def verify_host_reboot_after(context, evidence):
"""Parent namespace observation; ambient true is honest pending evidence.
The private worker must never introduce a reboot request. Equal HOST flags
(including true/true) do not imply that a reboot was requested or performed.
"""
before, before_sha = load_host_reboot_before(context)
after = Path('/run/reboot-required').exists()
require(Path('/proc/sys/kernel/random/boot_id').read_text().strip() == context.boot_id,
'BOOT_CHANGED_DURING_TRANSACTION')
child = json_bytes(sealed_read(ACTIVE / 'sandbox-result.json'))
exact(child, 'transaction_sha256 apt_exit_code reboot_required')
require(child['transaction_sha256'] == context.transaction_sha256 and
type(child['apt_exit_code']) is int and child['apt_exit_code'] == 0 and
child['reboot_required'] is False, 'FIXTURE_PRIVATE_REBOOT_FLAG_INTRODUCED')
require(after == before['host_reboot_required'] and evidence['reboot_required'] is after,
'HOST_REBOOT_STATE_CHANGED_DURING_TRANSACTION')
return {'host_reboot_required_before': before['host_reboot_required'],
'host_reboot_required_after': after, 'host_reboot_before_sha256': before_sha,
'reboot_required_introduced': False}
def complete_acceptance(transaction, context, action, runtime, evidence):
"""Called only after real child success, armed hook AND independent verify."""
require(context.action == 'apt-native-acceptance' and context.execution_profile == 'dev-test',
@@ -761,12 +824,15 @@ def complete_acceptance(transaction, context, action, runtime, evidence):
'invalid_kexec_load_flags': 'EPERM',
'invalid_kexec_file_fds_flags': 'EPERM'},
'frontend_lock': 'native-apt-check-conflict'}
require(prechecks == {'schema_version': 1, 'transaction_sha256': context.transaction_sha256,
before, before_sha = load_host_reboot_before(context)
require(prechecks == {'schema_version': 2, 'transaction_sha256': context.transaction_sha256,
'job_payload_sha256': context.job_payload_sha256,
'boot_id': context.boot_id, 'checks': expected_checks}, 'NATIVE_PRECHECKS_REQUIRED')
require(not evidence['reboot_required'], 'FIXTURE_UNEXPECTED_REBOOT_REQUIRED')
'boot_id': context.boot_id, 'host_reboot_before_sha256': before_sha,
'host_reboot_required_before': before['host_reboot_required'],
'checks': expected_checks}, 'NATIVE_PRECHECKS_REQUIRED')
evidence.update(verify_host_reboot_after(context, evidence))
require(runtime_identity() == runtime, 'RUNTIME_CHANGED_DURING_ACCEPTANCE')
proof = {'schema_version': 2, 'scope': fixture_scope(transaction), 'runtime': runtime,
proof = {'schema_version': 3, 'scope': fixture_scope(transaction), 'runtime': runtime,
'test_acceptance': True, 'noProductionEvidence': True,
'test_result_id': action['test_result_id'],
'transaction_sha256': context.transaction_sha256,
@@ -774,6 +840,11 @@ def complete_acceptance(transaction, context, action, runtime, evidence):
'job_id': context.job_id, 'attempt_id': context.attempt_id,
'authorization_id': context.authorization_id, 'plan_sha256': context.plan_sha256,
'native_prechecks_sha256': digest(canonical(prechecks)),
'native_prechecks_schema_version': 2,
'host_reboot_before_sha256': before_sha,
'host_reboot_required_before': evidence['host_reboot_required_before'],
'host_reboot_required_after': evidence['host_reboot_required_after'],
'reboot_required_introduced': False,
'hook_marker_sha256': digest(sealed_read(ACTIVE / 'hook-armed.json')),
'postconditions_sha256': digest(canonical(evidence)),
'completed_at_ms': time.time_ns() // 1000000}
@@ -782,7 +853,7 @@ def complete_acceptance(transaction, context, action, runtime, evidence):
recovery = action.get('native_recovery')
if recovery is not None:
verify_recovery_reference(transaction, context, action)
proof.update(schema_version=1, type='rmm.apt.native-recovery', operation='configure_only',
proof.update(schema_version=2, type='rmm.apt.native-recovery', operation='configure_only',
native_recovery=recovery)
path = BASE / ('recovery-' + recovery['previous_grant_id'] + '.json')
staged = BASE / ('pending-recovery-' + recovery['previous_grant_id'] + '.json')
@@ -1532,6 +1603,157 @@ def verify_partial(request):
return result
def verify_configured_recovery(request):
"""Readonly classification of the ONE historical schema-4 attempt.
Rust independently checks the original signed Request, immutable ledger
unknown code and the closed original partial proof. No host-before sample
exists for this old runtime: even complete package effects NEVER become a
retroactive acceptance or success. No package mutation or metadata write.
"""
require(os.geteuid() == 0, 'ROOT_REQUIRED')
fields = ('transaction_sha256 job_payload_sha256 effect_armed_ledger_id grant_id '
'job_id attempt_id authorization_id plan_sha256')
exact(request, fields)
for key in ('transaction_sha256', 'job_payload_sha256', 'plan_sha256'):
token(request[key], HASH, 'CONFIGURED_REQUEST_HASH')
token(request['effect_armed_ledger_id'], IDENT, 'CONFIGURED_REQUEST_LEDGER')
for key in ('grant_id', 'job_id', 'attempt_id', 'authorization_id'):
value = request[key]
require(type(value) is str and str(uuid.UUID(value)) == value and uuid.UUID(value).int != 0,
'CONFIGURED_REQUEST_ID')
pin = HISTORICAL_CONFIGURED_RECOVERY
require(request['grant_id'] == pin['grant_id'], 'CONFIGURED_HISTORICAL_GRANT_ONLY')
secure_path(BASE, directory=True, private=True)
secure_path(ACTIVE, directory=True, private=True)
names = ('context.json', 'signed-action.json', 'expectation.json', 'baseline.json',
'launch.json', 'native-prechecks.json', 'sandbox-ready.json', 'sandbox-result.json',
'hook-armed.json', 'partial-proof.json')
raw = {name: sealed_read(ACTIVE / name) for name in names}
for name in ('bootstrap-attempt-rmm-apt-fixture-install-1.0.json',
'bootstrap-retry-rmm-apt-fixture-install-1.0.json',
'recovery-attempt-' + pin['previous_grant_id'] + '.json'):
raw[name] = sealed_read(BASE / name)
require(not os.path.lexists(ACTIVE / 'host-reboot-before.json'),
'CONFIGURED_HISTORICAL_BEFORE_SAMPLE_ABSENT')
context = VerifiedHelperContext.parse(json_bytes(raw['context.json']))
require(context.action == 'apt-native-acceptance' and context.execution_profile == 'dev-test' and
all(getattr(context, key) == request[key] for key in fields.split()), 'CONFIGURED_CONTEXT_BINDING')
require(Path('/proc/sys/kernel/random/boot_id').read_text().strip() == context.boot_id,
'CONFIGURED_BOOT_CHANGED')
require(digest(raw['signed-action.json']) == context.job_payload_sha256 and
digest(raw['expectation.json']) == context.transaction_sha256, 'CONFIGURED_SIGNED_BYTES')
transaction = ResolvedAptTransaction.parse(json_bytes(raw['expectation.json']))
fixture_scope(transaction)
require(transaction.schema_version == 2 and transaction.operation == 'configure_only',
'CONFIGURED_FIXED_OPERATION')
baseline = json_bytes(raw['baseline.json'])
require(type(baseline) is dict and raw['baseline.json'] == canonical(baseline) and
digest(raw['baseline.json']) == transaction.baseline_sha256 and
baseline.get('rmm-mvp-test:all') == {'version': '1.0', 'status': 'install ok unpacked'},
'CONFIGURED_ORIGINAL_PARTIAL_BASELINE')
job = json_bytes(raw['signed-action.json'])
exact(job, 'schema_version tenant_id asset_id agent_id enrollment_generation assignment_version '
'job_id attempt_id action execution_identity not_before start_before max_runtime_seconds max_output_bytes')
require(type(job['schema_version']) is int and job['schema_version'] == 1 and
job['execution_identity'] == 'root' and job['job_id'] == context.job_id and
job['attempt_id'] == context.attempt_id, 'CONFIGURED_ORIGINAL_JOB')
outer = job['action']; exact(outer, 'action recipe_id recipe_version apt_manifest')
require(outer['action'] == 'apt_native_acceptance' and outer['recipe_id'] == transaction.recipe_id and
outer['recipe_version'] == transaction.recipe_version, 'CONFIGURED_ORIGINAL_ACTION')
action = outer['apt_manifest']
exact(action, 'type schema_version action execution_profile transaction_sha256 '
'resolved_apt_transaction provider_sha256 hook_sha256 apt_config_sha256 runtime_sha256 '
'test_result_id transaction_bytes native_recovery')
require(action['type'] == 'rmm.apt.helper-action' and type(action['schema_version']) is int and
action['schema_version'] == 4 and action['action'] == context.action and
action['execution_profile'] == context.execution_profile and
action['provider_sha256'] == pin['provider_sha256'] and
action['transaction_sha256'] == context.transaction_sha256 and
canonical(action['resolved_apt_transaction']) == canonical(json_bytes(raw['expectation.json'])) and
type(action['transaction_bytes']) is list and
all(type(value) is int and 0 <= value <= 255 for value in action['transaction_bytes']) and
bytes(action['transaction_bytes']) == raw['expectation.json'], 'CONFIGURED_ORIGINAL_MANIFEST')
for key in ('provider_sha256', 'hook_sha256', 'apt_config_sha256', 'runtime_sha256'):
token(action[key], HASH, 'CONFIGURED_ORIGINAL_RUNTIME_HASH')
token(action['test_result_id'], IDENT, 'CONFIGURED_ORIGINAL_TEST_ID')
require(digest(sealed_read(ACTIVE / 'apt.conf')) == action['apt_config_sha256'],
'CONFIGURED_ORIGINAL_APT_CONFIG')
reference = action['native_recovery']; validate_recovery_reference(reference)
require(reference['previous_grant_id'] == pin['previous_grant_id'] and
reference['partial_proof_sha256'] == pin['partial_proof_sha256'], 'CONFIGURED_ORIGINAL_PARTIAL_REFERENCE')
verify_recovery_reference(transaction, context, action)
check_bootstrap_attempt(transaction, context, action)
require(canonical(json_bytes(raw['launch.json'])) == canonical({
'transaction_sha256': context.transaction_sha256,
'effect_armed_ledger_id': context.effect_armed_ledger_id}) and
canonical(json_bytes(raw['sandbox-ready.json'])) == canonical({
'transaction_sha256': context.transaction_sha256, 'sandbox_version': 1}) and
canonical(json_bytes(raw['sandbox-result.json'])) == canonical({
'transaction_sha256': context.transaction_sha256, 'apt_exit_code': 0, 'reboot_required': False}),
'CONFIGURED_NATIVE_COMPLETION')
checks = {'schema_version': 1, 'transaction_sha256': context.transaction_sha256,
'job_payload_sha256': context.job_payload_sha256, 'boot_id': context.boot_id,
'checks': {'namespaces_caps_nnp_seccomp': True, 'readonly_controlpaths': True,
'private_tmpfs_sockets': True,
'control_syscalls': {'invalid_reboot_magic': 'EPERM',
'invalid_kexec_load_flags': 'EPERM',
'invalid_kexec_file_fds_flags': 'EPERM'},
'frontend_lock': 'native-apt-check-conflict'}}
require(canonical(json_bytes(raw['native-prechecks.json'])) == canonical(checks),
'CONFIGURED_HISTORICAL_PRECHECKS')
marker = json_bytes(raw['hook-armed.json'])
exact(marker, 'armed_at_ms effect_armed_ledger_id grant_id protocol_sha256 transaction_sha256')
require(marker['effect_armed_ledger_id'] == context.effect_armed_ledger_id and
marker['grant_id'] == context.grant_id and marker['transaction_sha256'] == context.transaction_sha256 and
type(marker['armed_at_ms']) is int and
context.not_before_ms <= marker['armed_at_ms'] < context.start_before_ms,
'CONFIGURED_HOOK_BINDING')
token(marker['protocol_sha256'], HASH, 'CONFIGURED_HOOK_PROTOCOL_HASH')
require(marker['protocol_sha256'] == digest(canonical([
Action('rmm-mvp-test', '1.0', 'all', 'none', '=', '1.0', 'all', 'none', '**CONFIGURE**').__dict__])),
'CONFIGURED_EXACT_CONFIGURE_PROTOCOL')
for name in ('acceptance-rmm-apt-fixture-install-1.0.json', 'pending-acceptance-rmm-apt-fixture-install-1.0.json',
'recovery-' + pin['previous_grant_id'] + '.json', 'pending-recovery-' + pin['previous_grant_id'] + '.json'):
require(not os.path.lexists(BASE / name), 'CONFIGURED_NO_RETROACTIVE_ACCEPTANCE')
require(not observe_host_frontend_lock() and not observe_host_frontend_lock(Path('/var/lib/dpkg/lock')),
'FOREIGN_PACKAGE_LOCK')
fingerprint = status_fingerprint(); observed = installed_snapshot()
expected = dict(baseline); expected['rmm-mvp-test:all'] = {'version': '1.0', 'status': 'install ok installed'}
require(observed == expected, 'CONFIGURED_UNEXPECTED_PACKAGE_CHANGE')
verify_archive(transaction.packages[0])
require(run_read(['/usr/bin/dpkg', '--audit']) == b'', 'CONFIGURED_DPKG_AUDIT')
payload = sealed_read(Path('/usr/share/rmm-mvp-test/version'), limit=32)
require(payload == b'1.0\n', 'CONFIGURED_FIXTURE_PAYLOAD')
host_marker = sealed_read(Path('/run/reboot-required'), limit=4096)
require(Path('/run/reboot-required').exists(), 'CONFIGURED_ACTUAL_HOST_REBOOT_FLAG')
require(status_fingerprint() == fingerprint and installed_snapshot() == observed and
run_read(['/usr/bin/dpkg', '--audit']) == b'' and
sealed_read(Path('/usr/share/rmm-mvp-test/version'), limit=32) == payload and
sealed_read(Path('/run/reboot-required'), limit=4096) == host_marker and
Path('/run/reboot-required').exists() and
Path('/proc/sys/kernel/random/boot_id').read_text().strip() == context.boot_id and
not observe_host_frontend_lock() and not observe_host_frontend_lock(Path('/var/lib/dpkg/lock')),
'CONFIGURED_CURRENT_STATE_CHANGED')
verify_recovery_reference(transaction, context, action)
for name, data in raw.items():
require(sealed_read(ACTIVE / name if name in names else BASE / name) == data,
'CONFIGURED_HISTORICAL_EVIDENCE_CHANGED')
require(not os.path.lexists(ACTIVE / 'host-reboot-before.json'),
'CONFIGURED_HISTORICAL_BEFORE_SAMPLE_ABSENT')
proof = dict(schema_version=1, type='rmm.apt.configured-recovery-reconciliation', **request,
original_evidence_sha256=digest(canonical({name: digest(data) for name, data in raw.items()})),
partial_proof_sha256=reference['partial_proof_sha256'],
original_baseline_sha256=transaction.baseline_sha256,
observed_snapshot_sha256=digest(canonical(observed)), status_fingerprint=fingerprint,
fixture_payload_sha256=digest(payload), snapshot=observed, checked_at_ms=time.time_ns() // 1000000,
effect_complete=True, partial_effect=False, postconditions_passed=False,
reboot_required=True, host_reboot_required=True, host_reboot_marker_sha256=digest(host_marker))
result = dict(effect_state='known_failed', code='APT_RECOVERY_CONFIGURED_ACCEPTANCE_REBOOT_FLAG_VERIFIED', proof=proof)
require(len(canonical(result)) <= MAX_INPUT, 'CONFIGURED_PROOF_LIMIT')
return result
def verified_no_change(transaction, baseline, context):
"""Independently verify the full selected postcondition, never run APT."""
fixture_scope(transaction) # Cannot promote unknown catalog recipes.
@@ -1585,7 +1807,7 @@ def execute(request, native_acceptance=False):
not list(secure_path(ACTIVE / 'lists', directory=True).iterdir()), 'ISOLATED_APT_DIRS')
secure_path(ACTIVE / 'cache', directory=True, private=True)
for path in ('hook-armed.json', 'sandbox-ready.json', 'sandbox-result.json', 'native-prechecks.json',
'host-namespaces.json', 'launch.json'):
'host-namespaces.json', 'host-reboot-before.json', 'launch.json'):
require(not (ACTIVE / path).exists(), 'PRIOR_ATTEMPT_UNKNOWN')
check_current_baseline(transaction, baseline)
for package in transaction.packages:
@@ -1609,6 +1831,7 @@ def execute(request, native_acceptance=False):
# create-once tombstone, never a reset of the original attempt.
path, binding = bootstrap_binding(transaction, context, action)
durable_once(path, binding)
capture_host_reboot_before(context)
durable_once(ACTIVE / 'host-namespaces.json', {
name: os.readlink('/proc/self/ns/' + name) for name in ('pid', 'mnt', 'net')})
durable_once(ACTIVE / 'launch.json', {'transaction_sha256': context.transaction_sha256,
@@ -1641,6 +1864,7 @@ def execute(request, native_acceptance=False):
type(child_result['reboot_required']) is bool, 'SANDBOX_RESULT_BINDING')
evidence['reboot_required'] |= child_result['reboot_required']
evidence['effect_armed_ledger_id'] = context.effect_armed_ledger_id
evidence.update(verify_host_reboot_after(context, evidence))
if native_acceptance:
evidence.update(complete_acceptance(transaction, context, action, runtime, evidence))
# This recipe has version/consistency postconditions, not post-boot
@@ -1756,6 +1980,7 @@ def _planning_status(recovery_proof=None):
fingerprint = status_fingerprint() # Vetoes dirty updates/pending triggers.
snapshot_reader = partial_installed_snapshot if recovery_proof is not None else installed_snapshot
snapshot = snapshot_reader()
host_reboot_required = Path('/run/reboot-required').exists()
if recovery_proof is not None:
require(snapshot == recovery_proof['snapshot'] and fingerprint == recovery_proof['status_fingerprint'],
'RECOVERY_PLANNING_STATE_CHANGED')
@@ -1774,7 +1999,8 @@ def _planning_status(recovery_proof=None):
type(receipt['sealed_at_ms']) is int and 0 < receipt['sealed_at_ms'] <= time.time_ns() // 1000000,
'PREFETCH_RECEIPT')
prefetch[sha] = receipt
require(status_fingerprint() == fingerprint and snapshot_reader() == snapshot,
require(status_fingerprint() == fingerprint and snapshot_reader() == snapshot and
Path('/run/reboot-required').exists() == host_reboot_required,
'PLANNING_STATE_CHANGED')
require(not observe_host_frontend_lock() and
not observe_host_frontend_lock(Path('/var/lib/dpkg/lock')), 'FOREIGN_PACKAGE_LOCK')
@@ -1799,9 +2025,11 @@ def _planning_status(recovery_proof=None):
else:
durable_once(path, snapshot)
# Do not publish a stale baseline if state changed during fsync.
require(status_fingerprint() == fingerprint and snapshot_reader() == snapshot,
require(status_fingerprint() == fingerprint and snapshot_reader() == snapshot and
Path('/run/reboot-required').exists() == host_reboot_required,
'PLANNING_STATE_CHANGED')
return {'observed_at': time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),
'host_reboot_required': host_reboot_required,
'fixture_package': snapshot.get('rmm-mvp-test:all'),
'baseline_sha256': baseline_sha, 'sealed_baseline_sha256': baseline_sha,
'status_fingerprint': fingerprint, 'dpkg_updates_empty': True, 'pending_triggers_empty': True,
@@ -2033,6 +2261,8 @@ def main():
sys.stdout.buffer.write(canonical(readiness_status()) + b'\n')
elif mode == 'verify-partial':
sys.stdout.buffer.write(canonical(verify_partial(json_bytes(sys.stdin.buffer.read(MAX_INPUT + 1)))) + b'\n')
elif mode == 'verify-configured-recovery':
sys.stdout.buffer.write(canonical(verify_configured_recovery(json_bytes(sys.stdin.buffer.read(MAX_INPUT + 1)))) + b'\n')
elif mode == 'verify-controller':
verify_controller_profile()
elif mode == 'inspect-sandbox':