feat: deploy cloud-only RMM and verify audited APT diagnostics
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-13 13:49:11 +01:00
parent 6c3203d725
commit fbef0e4e2f
48 changed files with 3125 additions and 34 deletions
+67
View File
@@ -0,0 +1,67 @@
"""Exact dev/test RMM diagnostic payload: simulation only, no host APT writes."""
import hashlib
import json
import os
from pathlib import Path
import re
import subprocess
import tempfile
def digest(data):
return hashlib.sha256(data).hexdigest()
def preserved():
base = Path('/var/lib/rmm-apt-transaction')
files = [Path('/var/lib/dpkg/status'), base / 'bootstrap-attempt-rmm-apt-fixture-install-1.0.json']
files.extend(p for p in (base / 'active').rglob('*') if p.is_file())
return {str(p): digest(p.read_bytes()) for p in files}
def main():
os.umask(0o077)
base = Path('/var/lib/rmm-apt-transaction')
archive = base / 'archives/74036ae81223deab3aae994fd2a2a695af408741777e1ce17dcb4e32f1235867.deb'
assert archive.stat().st_size == 20672 and digest(archive.read_bytes()) == archive.stem
assert not Path('/usr/share/rmm-mvp-test/version').exists()
before = preserved()
config = (base / 'active/apt.conf').read_bytes()
results = []
with tempfile.TemporaryDirectory(prefix='rmm-apt-diagnostic-') as temp:
workspace = Path(temp)
for name in ('empty', 'lists', 'cache', 'log', 'state'):
(workspace / name).mkdir(mode=0o700)
# Preserve source/hook/solver configuration. Only diagnostic scratch
# directories move into PrivateTmp; host dpkg status is read-only.
copied = config.replace(str(base / 'active').encode(), str(workspace).encode())
copied = copied.replace(str(base / 'log').encode(), str(workspace / 'log').encode())
copied = copied.replace(str(base / 'state').encode(), str(workspace / 'state').encode())
path = workspace / 'apt.conf'; path.write_bytes(copied)
env = dict(PATH='/usr/sbin:/usr/bin:/sbin:/bin', LC_ALL='C', HOME='/root',
DEBIAN_FRONTEND='noninteractive', APT_CONFIG=str(path))
for name, delimiter in (('original_argv_simulated', ['--']), ('without_separator_simulated', [])):
command = ['/usr/bin/apt-get', '--simulate', '--yes', '--no-remove', '--no-install-recommends',
'--no-download', 'install'] + delimiter + [str(archive)]
with tempfile.TemporaryFile() as out, tempfile.TemporaryFile() as err:
process = subprocess.run(command, env=env, stdin=subprocess.DEVNULL,
stdout=out, stderr=err, timeout=20)
lengths = (out.tell(), err.tell()); out.seek(0); err.seek(0)
stdout = out.read(16384); stderr = err.read(16384)
messages = []
for line in stderr.decode('utf-8', errors='replace').splitlines():
if line.startswith(('E:', 'W:')):
line = re.sub(r'[A-Za-z][A-Za-z0-9+.-]*://\S+', '<uri>', line)
line = re.sub(r'/[^\s\x27\x22,;()]+', '<path>', line)
line = re.sub(r'\b(?:\d{1,3}\.){3}\d{1,3}\b', '<address>', line)
messages.append(line[:512])
results.append(dict(case=name,exit_code=process.returncode,messages=messages[:12],
stdout_sha256=digest(stdout),stderr_sha256=digest(stderr),truncated=any(n>16384 for n in lengths),
solver_selected_fixture=b'rmm-mvp-test' in stdout))
assert preserved() == before and not Path('/usr/share/rmm-mvp-test/version').exists()
print(json.dumps(dict(schema_version=1,diagnostic_only=True,transaction_executed=False,
preserved_state=True,original_config_sha256=digest(config),results=results)))
if __name__ == '__main__':
main()
+36
View File
@@ -0,0 +1,36 @@
[Unit]
Description=RMM unprivileged client for discovery.ease-technologies.de
After=network-online.target time-sync.target
Wants=network-online.target
[Service]
Type=simple
User=rmm-agent
Group=rmm-agent
StateDirectory=rmm-agent-remote
StateDirectoryMode=0700
UMask=0077
Environment=RMM_AGENT_STATE=/var/lib/rmm-agent-remote
Environment=RMM_CA_FILE=/etc/rmm-remote/ca.pem
Environment=RMM_SERVER_NAME=discovery.ease-technologies.de
Environment=RMM_CONNECT_ADDR=88.99.80.202:443
Environment=RMM_TRANSPORT=auto
Environment=RMM_EXTENDED_INVENTORY=1
EnvironmentFile=/etc/rmm-remote/agent.env
ExecStart=/usr/local/libexec/rmm-agent-remote
Restart=on-failure
RestartSec=10
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictSUIDSGID=true
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
CapabilityBoundingSet=
AmbientCapabilities=
[Install]
WantedBy=multi-user.target
+8 -4
View File
@@ -4,7 +4,10 @@ After=local-fs.target
[Service]
Type=simple
User=root
# System services default to root. Avoid explicit User=root: systemd 255's
# seccomp setup otherwise drops CAP_SETUID and retains setup inheritable caps.
# Controller verification still requires euid 0, the exact capability sets,
# zero inherited/ambient caps, NNP and the full sandbox below.
Group=rmm-agent
Environment=RMM_HELPER_CONFIG=/etc/rmm/apt-helper.json
ExecStartPre=/usr/local/libexec/rmm-privileged-helper --probe-native
@@ -38,9 +41,10 @@ CapabilityBoundingSet=CAP_CHOWN CAP_DAC_OVERRIDE CAP_FOWNER CAP_FSETID CAP_SETGI
# Trusted setup needs mount/unshare/fork/capset/prctl/seccomp. There is deliberately
# no outer @mount deny; the irreversible worker filter denies it after setup.
SystemCallFilter=~@reboot @module @raw-io @swap @clock @debug
# Existing helper clock trust reads adjtimex(modes=0). Mutating adjtimex still
# requires CAP_SYS_TIME, absent from the bounding set; other @clock calls denied.
SystemCallFilter=adjtimex
# glibc implements the read-only adjtimex(modes=0) query via clock_adjtime on
# Ubuntu. Neither syscall can change time without CAP_SYS_TIME (not bounded).
# Keep all other @clock operations denied; never bypass trusted-clock checks.
SystemCallFilter=adjtimex clock_adjtime
SystemCallErrorNumber=EPERM
ReadWritePaths=/var/lib/dpkg /var/lib/rmm-helper /var/lib/rmm-apt-transaction /usr/share/rmm-mvp-test
Restart=on-failure
+35
View File
@@ -0,0 +1,35 @@
[Unit]
Description=RMM narrowly scoped cloud dev/test root helper
After=time-sync.target
[Service]
Type=simple
# Implicit root avoids systemd 255 seccomp/setuid capability mutation.
Group=rmm-agent
StateDirectory=rmm-helper
StateDirectoryMode=0700
RuntimeDirectory=rmm-helper-cloud
RuntimeDirectoryMode=0750
UMask=0077
Environment=RMM_HELPER_CONFIG=/etc/rmm-remote/helper-general.json
ExecStart=/usr/local/libexec/rmm-privileged-helper
Restart=no
NoNewPrivileges=true
PrivateTmp=true
PrivateNetwork=true
ProtectSystem=strict
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictSUIDSGID=true
RestrictAddressFamilies=AF_UNIX
CapabilityBoundingSet=CAP_CHOWN CAP_DAC_OVERRIDE CAP_FOWNER CAP_FSETID CAP_SETGID CAP_SETUID CAP_SETPCAP CAP_SETFCAP
AmbientCapabilities=
SystemCallFilter=~@mount @reboot @swap @raw-io @module @clock @debug
# Read-only trusted clock query; glibc may use clock_adjtime. No CAP_SYS_TIME.
SystemCallFilter=adjtimex clock_adjtime
ReadWritePaths=/etc/systemd/system/rmm-mvp-test.service
[Install]
WantedBy=multi-user.target