Build and serve signed Linux ARM64 agent releases
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user