Ship Windows x64 through a separately signed official GNU release channel
This commit is contained in:
@@ -143,7 +143,7 @@ fn verifier_platform(platform: Platform) -> rmm_updater::Platform {
|
||||
Platform::WindowsGnuX64 => rmm_updater::Platform::WindowsGnuX64,
|
||||
}
|
||||
}
|
||||
/// Network input can choose only one of two statically named protected
|
||||
/// Network input can choose only among statically named protected
|
||||
/// configuration slots. It never supplies a path or introduces update trust.
|
||||
fn keyring_path_with(
|
||||
platform: Platform,
|
||||
@@ -152,7 +152,19 @@ fn keyring_path_with(
|
||||
let name = match platform {
|
||||
Platform::LinuxX64 => "RMM_AGENT_UPDATE_LINUX_KEYRING_FILE",
|
||||
Platform::WindowsX64 => "RMM_AGENT_UPDATE_WINDOWS_KEYRING_FILE",
|
||||
Platform::WindowsGnuX64 => "RMM_AGENT_UPDATE_WINDOWS_GNU_KEYRING_FILE",
|
||||
Platform::WindowsGnuX64 => {
|
||||
// The shared device gateway and both management APIs must select the same
|
||||
// official trust. A legacy development key is usable only in isolated dev.
|
||||
let official = "RMM_AGENT_UPDATE_WINDOWS_GNU_OFFICIAL_KEYRING_FILE";
|
||||
if let Some(path) = lookup(official)? {
|
||||
return FsPath::new(&path).is_absolute().then(|| path.into())
|
||||
.ok_or_else(|| fail("AGENT_UPDATE_NOT_CONFIGURED"));
|
||||
}
|
||||
if lookup("RMM_PROFILE")?.as_deref() != Some("development") {
|
||||
return Err(fail("AGENT_UPDATE_NOT_CONFIGURED"));
|
||||
}
|
||||
"RMM_AGENT_UPDATE_WINDOWS_GNU_KEYRING_FILE"
|
||||
}
|
||||
};
|
||||
if let Some(path) = lookup(name)? {
|
||||
if path.is_empty() || !FsPath::new(&path).is_absolute() {
|
||||
@@ -162,6 +174,9 @@ 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 {
|
||||
return Err(fail("AGENT_UPDATE_NOT_CONFIGURED"));
|
||||
}
|
||||
lookup("RMM_AGENT_UPDATE_KEYRING_FILE")?
|
||||
.map(Into::into)
|
||||
.ok_or_else(|| fail("AGENT_UPDATE_NOT_CONFIGURED"))
|
||||
@@ -171,21 +186,6 @@ pub fn verify_envelope(
|
||||
binding: Option<&rmm_domain::agent_update::UpdaterBinding>,
|
||||
) -> Result<ReleaseManifest, Error> {
|
||||
let platform = envelope.decode().map_err(|_| invalid())?.manifest.platform;
|
||||
if platform == Platform::WindowsGnuX64
|
||||
&& std::env::var("RMM_PROFILE").as_deref() != Ok("development")
|
||||
{
|
||||
return Err(fail("AGENT_UPDATE_DEVELOPMENT_CHANNEL_REQUIRED"));
|
||||
}
|
||||
verify_signed_envelope(envelope, platform, binding)
|
||||
}
|
||||
|
||||
// The public management process can copy an operator-selected release into an empty
|
||||
// catalog. Network-supplied publications additionally go through the profile check above.
|
||||
fn verify_signed_envelope(
|
||||
envelope: &ReleaseEnvelope,
|
||||
platform: Platform,
|
||||
binding: Option<&rmm_domain::agent_update::UpdaterBinding>,
|
||||
) -> Result<ReleaseManifest, Error> {
|
||||
let raw = keyring_bytes(platform)?;
|
||||
verify_envelope_with_keyring(
|
||||
envelope,
|
||||
@@ -1075,6 +1075,21 @@ mod tests {
|
||||
FsPath::new("legacy-relative.json")
|
||||
);
|
||||
}
|
||||
let dev_only = BTreeMap::from([
|
||||
("RMM_AGENT_UPDATE_WINDOWS_GNU_KEYRING_FILE", "/trust/dev.json"),
|
||||
("RMM_AGENT_UPDATE_KEYRING_FILE", "/trust/legacy.json"),
|
||||
]);
|
||||
assert!(choose(Platform::WindowsGnuX64, &dev_only).is_err());
|
||||
let mut mixed = dev_only;
|
||||
mixed.insert("RMM_PROFILE", "development");
|
||||
assert_eq!(choose(Platform::WindowsGnuX64, &mixed).unwrap(), FsPath::new("/trust/dev.json"));
|
||||
mixed.insert("RMM_AGENT_UPDATE_WINDOWS_GNU_OFFICIAL_KEYRING_FILE", "/trust/official.json");
|
||||
for profile in ["development", "production"] {
|
||||
mixed.insert("RMM_PROFILE", profile);
|
||||
assert_eq!(choose(Platform::WindowsGnuX64, &mixed).unwrap(), FsPath::new("/trust/official.json"));
|
||||
}
|
||||
mixed.insert("RMM_AGENT_UPDATE_WINDOWS_GNU_OFFICIAL_KEYRING_FILE", "");
|
||||
assert!(choose(Platform::WindowsGnuX64, &mixed).is_err());
|
||||
let only_linux =
|
||||
BTreeMap::from([("RMM_AGENT_UPDATE_LINUX_KEYRING_FILE", "/trust/linux.json")]);
|
||||
assert!(choose(Platform::WindowsX64, &only_linux).is_err());
|
||||
@@ -1155,6 +1170,11 @@ mod tests {
|
||||
};
|
||||
(envelope, keys)
|
||||
};
|
||||
let (official, official_keys) = make(Platform::WindowsGnuX64);
|
||||
let (development, _) = make(Platform::WindowsGnuX64);
|
||||
let official_ring = encode(&official_keys).unwrap();
|
||||
assert!(verify_envelope_with_keyring(&official, None, &official_ring, 100).is_ok());
|
||||
assert!(verify_envelope_with_keyring(&development, None, &official_ring, 100).is_err());
|
||||
let (linux, linux_keys) = make(Platform::LinuxX64);
|
||||
let (windows, windows_keys) = make(Platform::WindowsX64);
|
||||
let linux_raw = encode(&linux_keys).unwrap();
|
||||
|
||||
@@ -5,7 +5,7 @@ param(
|
||||
[Parameter(Mandatory)][Uri]$BootstrapBase,
|
||||
[Security.SecureString]$EnrollmentToken,
|
||||
[ValidateSet('x86_64-pc-windows-msvc','x86_64-pc-windows-gnu')]
|
||||
[string]$Platform = 'x86_64-pc-windows-msvc'
|
||||
[string]$Platform = 'x86_64-pc-windows-gnu'
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
@@ -42,7 +42,13 @@ pub(super) async fn publish_missing(
|
||||
if exists {
|
||||
continue;
|
||||
}
|
||||
let path = distribution.join(format!("{name}.json"));
|
||||
let path = if platform == Platform::WindowsGnuX64
|
||||
&& std::env::var_os("RMM_AGENT_UPDATE_WINDOWS_GNU_OFFICIAL_KEYRING_FILE").is_some()
|
||||
{
|
||||
distribution.join(format!("{name}-official.json"))
|
||||
} else {
|
||||
distribution.join(format!("{name}.json"))
|
||||
};
|
||||
if !path
|
||||
.try_exists()
|
||||
.map_err(|_| fail("STARTER_CONFIGURATION"))?
|
||||
@@ -64,7 +70,7 @@ pub(super) async fn publish_missing(
|
||||
continue;
|
||||
}
|
||||
let package: Starter = serde_json::from_slice(&protected_file(&path, 65536)?)?;
|
||||
let manifest = verify_signed_envelope(&package.envelope, platform, None)?;
|
||||
let manifest = verify_envelope(&package.envelope, None)?;
|
||||
if manifest.platform != platform {
|
||||
return Err(invalid());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user