Build and serve signed Linux ARM64 agent releases

This commit is contained in:
2026-11-18 17:58:12 +01:00
parent c599baa494
commit 247646a2ba
27 changed files with 151 additions and 88 deletions
+1 -1
View File
@@ -418,7 +418,7 @@ async fn issue(
&& snapshot.sha256 == hex::decode(hash(&snapshot.data)).map_err(|_| denied())?,
)?;
let scope = match action.manifest().map_err(|_| denied())?.platform {
update::Platform::LinuxX64 => "linux.base",
update::Platform::LinuxX64 | update::Platform::LinuxArm64 => "linux.base",
update::Platform::WindowsX64 | update::Platform::WindowsGnuX64 => "windows.base",
};
// Health requires a fresh real base inventory of the restarted platform;
+19 -22
View File
@@ -17,7 +17,7 @@ use axum::{
use chrono::{DateTime, Utc};
use futures_util::StreamExt;
use rmm_domain::{
agent_update::{ArtifactDescriptor, Platform, ReleaseEnvelope, ReleaseManifest},
agent_update::{ArtifactDescriptor, LINUX_ARM64_RELEASE_CAPABILITY, Platform, ReleaseEnvelope, ReleaseManifest},
jobs::{ArtifactReference, encode, hash},
};
use serde::Deserialize;
@@ -139,13 +139,6 @@ pub fn store() -> Result<UpdateArtifacts, Error> {
metadata.uid(),
)?)
}
fn verifier_platform(platform: Platform) -> rmm_updater::Platform {
match platform {
Platform::LinuxX64 => rmm_updater::Platform::LinuxX64,
Platform::WindowsX64 => rmm_updater::Platform::WindowsX64,
Platform::WindowsGnuX64 => rmm_updater::Platform::WindowsGnuX64,
}
}
/// Network input can choose only among statically named protected
/// configuration slots. It never supplies a path or introduces update trust.
fn keyring_path_with(
@@ -154,6 +147,7 @@ fn keyring_path_with(
) -> Result<std::path::PathBuf, Error> {
let name = match platform {
Platform::LinuxX64 => "RMM_AGENT_UPDATE_LINUX_KEYRING_FILE",
Platform::LinuxArm64 => "RMM_AGENT_UPDATE_LINUX_ARM64_KEYRING_FILE",
Platform::WindowsX64 => "RMM_AGENT_UPDATE_WINDOWS_KEYRING_FILE",
Platform::WindowsGnuX64 => {
// The shared device gateway and both management APIs must select the same
@@ -177,7 +171,7 @@ fn keyring_path_with(
}
// Exact legacy compatibility only when the platform-specific slot is
// absent. An invalid explicit slot must never silently choose other trust.
if platform == Platform::WindowsGnuX64 {
if matches!(platform, Platform::LinuxArm64 | Platform::WindowsGnuX64) {
return Err(fail("AGENT_UPDATE_NOT_CONFIGURED"));
}
lookup("RMM_AGENT_UPDATE_KEYRING_FILE")?
@@ -239,7 +233,7 @@ fn verify_envelope_with_keyring(
rmm_updater::TrustedUpdateKey::new(
raw.try_into()
.map_err(|_| fail("AGENT_UPDATE_TRUST_INVALID"))?,
verifier_platform(key.platform),
key.platform.into(),
key.first_sequence,
key.last_sequence,
key.revoked,
@@ -250,7 +244,7 @@ fn verify_envelope_with_keyring(
let keyring = rmm_updater::UpdateKeyring::new(config.generation, keys)
.map_err(|_| fail("AGENT_UPDATE_TRUST_INVALID"))?;
let context = rmm_updater::TrustedContext {
platform: verifier_platform(decoded.manifest.platform),
platform: decoded.manifest.platform.into(),
now_utc_seconds,
keyring_generation: config.generation,
protocol_major: 1,
@@ -658,18 +652,21 @@ async fn check_device_platform(
.fetch_one(&mut **tx)
.await?;
let caps: Vec<String> = serde_json::from_value(caps)?;
let expected = match platform {
Platform::LinuxX64 => "linux.base/1",
Platform::WindowsX64 if caps.iter().any(|c| c == "agent.release.windows.gnu/1") => {
return Err(missing());
}
Platform::WindowsX64 => "windows.base/1",
Platform::WindowsGnuX64 => "agent.release.windows.gnu/1",
};
if !caps.iter().any(|c| c == expected) {
return Err(missing());
if device_supports_release(platform, &caps) {
Ok(())
} else {
Err(missing())
}
}
fn device_supports_release(platform: Platform, caps: &[String]) -> bool {
let has = |expected: &str| caps.iter().any(|capability| capability == expected);
match platform {
Platform::LinuxX64 => has("linux.base/1") && !has(LINUX_ARM64_RELEASE_CAPABILITY),
Platform::LinuxArm64 => has("linux.base/1") && has(LINUX_ARM64_RELEASE_CAPABILITY),
Platform::WindowsX64 => has("windows.base/1") && !has("agent.release.windows.gnu/1"),
Platform::WindowsGnuX64 => has("agent.release.windows.gnu/1"),
}
Ok(())
}
/// A published release grants access to its two fixed binaries for authenticated
+1 -1
View File
@@ -1,5 +1,5 @@
#!/bin/sh
# Usage: sudo sh linux.sh https://bootstrap.example [--enable-admin-scripts]
# Linux x86-64 / ARM64. Usage: sudo sh linux.sh https://bootstrap.example [--enable-admin-scripts]
set -eu
umask 077
file=$(mktemp)
+16 -7
View File
@@ -32,7 +32,6 @@ TIMER = 'rmm-discovery-update.timer'
HELPER = 'rmm-discovery-managed-script-helper.service'
HELPER_SOCKET = Path('/run/rmm-discovery-script-helper/control.sock')
OLD_HELPER_CONFIG = Path('/etc/rmm-discovery-managed-scripts')
PLATFORM = 'x86_64-unknown-linux-gnu'
MAX_BINARY = 256 * 1024 * 1024
UNIT_DIR = Path('/etc/systemd/system')
@@ -42,6 +41,13 @@ def require(condition, message):
raise ValueError(message)
def release_platform():
machine = platform.machine()
require(platform.system() == 'Linux' and machine in ('x86_64', 'aarch64'),
'Linux x86-64 or ARM64 required')
return machine + '-unknown-linux-gnu'
def origin(value):
parsed = urlsplit(value)
require(parsed.scheme == 'https' and parsed.hostname and parsed.username is None
@@ -151,7 +157,9 @@ def pair(folder, doc, source, updater):
manifest = doc['manifest']
release_id = canonical_id(manifest['release_id'])
prefix = '/agent/v1/bootstrap/releases' if source else '/agent/v1/releases'
suffix = '?platform=' + PLATFORM if source else ''
target = release_platform()
require(manifest['platform'] == target, 'release architecture differs from this device')
suffix = '?platform=' + target if source else ''
save(folder / 'envelope.json', doc['release_envelope'])
for artifact, role in zip(manifest['artifacts'], ('agent', 'helper'), strict=True):
require(artifact['role'] == role, 'incorrect artifact role')
@@ -481,7 +489,7 @@ def save_token(base, token, gid):
def install(base, token_file, enable_admin_scripts=False):
require(platform.machine() == 'x86_64', 'Linux x86-64 required')
target = release_platform()
base = origin(base)
if ROOT.exists():
config = read(ROOT / 'config.json')
@@ -491,7 +499,7 @@ def install(base, token_file, enable_admin_scripts=False):
token = enrollment_token(token_file)
with tempfile.TemporaryDirectory() as work:
metadata = Path(work) / 'bootstrap.json'
remote((base, token), '/agent/v1/bootstrap/current?platform=' + PLATFORM, metadata)
remote((base, token), '/agent/v1/bootstrap/current?platform=' + target, metadata)
require(read(metadata)['tenant_id'] == config['tenant'], 'different enrollment tenant')
save_token(ROOT, token, pwd.getpwnam('rmm-discovery').pw_gid)
# An operator rerunning the HTTPS installer can update the lifecycle
@@ -524,7 +532,7 @@ def install(base, token_file, enable_admin_scripts=False):
with tempfile.TemporaryDirectory(prefix='.rmm-', dir=ROOT.parent) as work:
staging = Path(work) / 'installation'
staging.mkdir()
remote((base, token), '/agent/v1/bootstrap/current?platform=' + PLATFORM, staging / 'bootstrap.json')
remote((base, token), '/agent/v1/bootstrap/current?platform=' + target, staging / 'bootstrap.json')
doc = read(staging / 'bootstrap.json')
require(doc['schema_version'] == 1, 'unknown bootstrap profile')
save(staging / 'keyring.json', doc['keyring'])
@@ -532,7 +540,7 @@ def install(base, token_file, enable_admin_scripts=False):
save(staging / 'config.json', {'bootstrap': base, 'gateway': origin(doc['gateway_origin']),
'tenant': canonical_id(doc['tenant_id'])})
updater = staging / 'updater'
remote((base, token), '/agent/v1/bootstrap/updater?platform=' + PLATFORM + '&sha256=' + doc['updater']['sha256'], updater, doc['updater'])
remote((base, token), '/agent/v1/bootstrap/updater?platform=' + target + '&sha256=' + doc['updater']['sha256'], updater, doc['updater'])
updater.chmod(0o755)
releases = staging / 'releases'
releases.mkdir()
@@ -599,6 +607,7 @@ def revert(intent, report_failure=True):
def update():
target = release_platform()
with (ROOT / 'release.lock').open('rb') as lock:
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
pending = ROOT / 'pending.json'
@@ -608,7 +617,7 @@ def update():
with tempfile.TemporaryDirectory(prefix='.incoming-', dir=ROOT / 'releases') as work:
staging = Path(work) / 'generation'
staging.mkdir()
remote(None, '/agent/v1/releases/current?platform=' + PLATFORM, staging / 'current.json')
remote(None, '/agent/v1/releases/current?platform=' + target, staging / 'current.json')
response = read(staging / 'current.json')
if response['status'] == 'not_configured':
return
+1
View File
@@ -31,6 +31,7 @@ fn official_windows(platform: Platform) -> bool {
async fn config(s: &crate::State, platform: Platform, tenant: Uuid, wanted: Option<&str>) -> Result<Config, Error> {
let slot = match platform {
Platform::LinuxX64 => "RMM_AGENT_BOOTSTRAP_LINUX_FILE",
Platform::LinuxArm64 => "RMM_AGENT_BOOTSTRAP_LINUX_ARM64_FILE",
Platform::WindowsX64 => "RMM_AGENT_BOOTSTRAP_WINDOWS_FILE",
Platform::WindowsGnuX64 => "RMM_AGENT_BOOTSTRAP_WINDOWS_GNU_FILE",
};
+4 -1
View File
@@ -14,7 +14,9 @@ pub(super) async fn publish_missing(
tx: &mut Transaction<'_, Postgres>,
tenant: Uuid,
) -> Result<(), Error> {
let Some(slot) = std::env::var_os("RMM_AGENT_BOOTSTRAP_LINUX_FILE") else {
let Some(slot) = std::env::var_os("RMM_AGENT_BOOTSTRAP_LINUX_FILE")
.or_else(|| std::env::var_os("RMM_AGENT_BOOTSTRAP_LINUX_ARM64_FILE"))
else {
return Ok(());
};
let Some(config_dir) = FsPath::new(&slot).parent() else {
@@ -29,6 +31,7 @@ pub(super) async fn publish_missing(
}
for platform in [
Platform::LinuxX64,
Platform::LinuxArm64,
Platform::WindowsGnuX64,
Platform::WindowsX64,
] {
+5 -2
View File
@@ -3,7 +3,7 @@
use crate::{jobs::Error, root_policy::RootScope, windows_policy::SystemScope};
use axum::http::StatusCode;
use rmm_domain::{
agent_update::{ArtifactRole, Platform, ReleaseManifest, digest},
agent_update::{ArtifactRole, LINUX_ARM64_RELEASE_CAPABILITY, Platform, ReleaseManifest, digest},
jobs::{Action, FULL_MAINTENANCE_CAPABILITY, JobPayload},
};
use serde::Deserialize;
@@ -60,7 +60,7 @@ impl ReleaseAnchor {
};
let field = |name: &str, value: &str| format!(r#""{name}":"{value}""#);
match manifest.platform {
Platform::LinuxX64 => replace(
Platform::LinuxX64 | Platform::LinuxArm64 => replace(
field("helper_binary_sha256", &self.helper_sha256),
field("helper_binary_sha256", next(ArtifactRole::Helper)?),
1,
@@ -164,6 +164,9 @@ fn check_pair(
caps: &[String],
) -> Result<(), Error> {
let platform = match identity {
"root" if caps.iter().any(|cap| cap == LINUX_ARM64_RELEASE_CAPABILITY) => {
Platform::LinuxArm64
}
"root" => Platform::LinuxX64,
"system" => Platform::WindowsGnuX64,
_ => return Err(binding_error()),