fix: bind offline probe to named agent and retain exact fault cleanup after unknown
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 19:50:15 +01:00
parent b3a22d464b
commit 0b581ea1c7
3 changed files with 16 additions and 5 deletions
+9 -4
View File
@@ -69,6 +69,7 @@ def vm_network(payload):
import datetime as dt
import errno
import fcntl
import grp
import sqlite3
import stat
identifier = str(uuid.UUID(payload['id']))
@@ -76,7 +77,9 @@ def vm_network(payload):
action = payload['action']; require(action in ('state','block','restore'), 'fixed network operation')
state = Path('/var/lib/rmm-agent-remote'); helper = Path('/var/lib/rmm-helper')
unit = 'rmm-agent-remote.service'; account = pwd.getpwnam('rmm-agent')
require(os.geteuid() == 0 and account.pw_uid == 993 and account.pw_gid == 993, 'fixed unprivileged Cloud agent')
require(os.geteuid() == 0 and account.pw_uid == 993 and account.pw_gid > 0
and account.pw_gid == grp.getgrnam('rmm-agent').gr_gid
and state.stat().st_uid == account.pw_uid, 'fixed unprivileged named Cloud agent')
require(json.loads((state/'identity.json').read_text())['agent_id'] == payload['agent_id'], 'fixed Cloud identity')
require(hashlib.sha256(Path('/usr/local/libexec/rmm-agent-remote').read_bytes()).hexdigest() == payload['binary_sha256'], 'reviewed current agent binary')
def properties():
@@ -124,9 +127,6 @@ def vm_network(payload):
require(not dropin.is_symlink(), 'network dropin symlink')
timer = 'rmm-offline-rollback-'+identifier+'-'+phase
before = snapshot()
require(before['agent_fault'] is None and before['helper_fault'] is None and before['helper_unresolved'] == 0 and before['other_unresolved'] == 0, 'unrelated or unknown work remains fenced')
if payload.get('helper_ledger_sha256'):
require(before['helper_ledger_sha256'] == payload['helper_ledger_sha256'], 'existing Root ledger changed')
if action == 'state': return before
if action == 'restore':
if dropin.exists():
@@ -136,6 +136,11 @@ def vm_network(payload):
subprocess.run(['systemctl','restart',unit],capture_output=True,check=True,timeout=20)
subprocess.run(['systemctl','stop',timer+'.timer'],capture_output=True,timeout=10)
return dict(restored=True,after=snapshot())
# State reads and cleanup of our exact transport fault remain possible
# after an unknown result. They never clear a journal fence or job state.
require(before['agent_fault'] is None and before['helper_fault'] is None and before['helper_unresolved'] == 0 and before['other_unresolved'] == 0, 'unrelated or unknown work remains fenced')
if payload.get('helper_ledger_sha256'):
require(before['helper_ledger_sha256'] == payload['helper_ledger_sha256'], 'existing Root ledger changed')
require(not dropin.exists() and before['agent_service']['ActiveState'] == 'active' and not before['agent_service']['IPAddressAllow'], 'clean active unit and no allow override')
require(before['count'] is None and not before['consumed'], 'no prior effect/consumption')
if phase == 'window':