From 0b07baf7bee0b49e736eae241ca98ec377760d37 Mon Sep 17 00:00:00 2001 From: Kevin Janssen Date: Wed, 18 Nov 2026 11:03:55 +0100 Subject: [PATCH] Keep legacy Windows starter worker pins outside official GNU enrollments --- crates/server/src/bootstrap/mod.rs | 9 +++++++-- crates/server/src/bootstrap/starter.rs | 7 +++---- migrations/0037_official_windows_starter_worker.sql | 4 ++++ tools/dev_customer_starters.py | 4 ++-- 4 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 migrations/0037_official_windows_starter_worker.sql diff --git a/crates/server/src/bootstrap/mod.rs b/crates/server/src/bootstrap/mod.rs index 5ae8db5..e0f8eb2 100644 --- a/crates/server/src/bootstrap/mod.rs +++ b/crates/server/src/bootstrap/mod.rs @@ -23,6 +23,11 @@ struct TenantPins { current: Pin, previous: Vec } #[serde(deny_unknown_fields)] pub(super) struct UpdaterQuery { platform: Platform, sha256: Option } +fn official_windows(platform: Platform) -> bool { + platform == Platform::WindowsGnuX64 + && std::env::var_os("RMM_AGENT_UPDATE_WINDOWS_GNU_OFFICIAL_KEYRING_FILE").is_some() +} + async fn config(s: &crate::State, platform: Platform, tenant: Uuid, wanted: Option<&str>) -> Result { let slot = match platform { Platform::LinuxX64 => "RMM_AGENT_BOOTSTRAP_LINUX_FILE", @@ -45,8 +50,8 @@ async fn config(s: &crate::State, platform: Platform, tenant: Uuid, wanted: Opti config.updater_bytes = selected.bytes; } else { let mut tx = rmm_persistence::tenant_tx(&s.pool, tenant).await?; - let pin = sqlx::query("SELECT sha256,size_bytes FROM customer_starter_workers WHERE platform=$1") - .bind(platform_name(platform)).fetch_optional(&mut *tx).await?; + let pin = sqlx::query("SELECT sha256,size_bytes FROM customer_starter_workers WHERE platform=$1 AND official_windows=$2") + .bind(platform_name(platform)).bind(official_windows(platform)).fetch_optional(&mut *tx).await?; tx.commit().await?; if let Some(pin) = pin { config.updater_sha256 = pin.get("sha256"); diff --git a/crates/server/src/bootstrap/starter.rs b/crates/server/src/bootstrap/starter.rs index 18eb03d..b704d8d 100644 --- a/crates/server/src/bootstrap/starter.rs +++ b/crates/server/src/bootstrap/starter.rs @@ -42,9 +42,7 @@ pub(super) async fn publish_missing( if exists { continue; } - let path = if platform == Platform::WindowsGnuX64 - && std::env::var_os("RMM_AGENT_UPDATE_WINDOWS_GNU_OFFICIAL_KEYRING_FILE").is_some() - { + let path = if official_windows(platform) { distribution.join(format!("{name}-official.json")) } else { distribution.join(format!("{name}.json")) @@ -135,11 +133,12 @@ pub(super) async fn publish_missing( .bind(tenant).bind(manifest.release_id).bind(name).bind(i64::try_from(manifest.release_sequence).map_err(|_|invalid())?) .bind(hash(&package.envelope.decode().map_err(|_|invalid())?.payload_bytes)).bind(hash(&raw)).bind(raw) .bind(a.artifact_id).bind(&a.sha256).bind(a.bytes as i64).bind(h.artifact_id).bind(&h.sha256).bind(h.bytes as i64).execute(&mut **tx).await?; - sqlx::query("INSERT INTO customer_starter_workers VALUES($1,$2,$3,$4)") + sqlx::query("INSERT INTO customer_starter_workers(tenant_id,platform,sha256,size_bytes,official_windows) VALUES($1,$2,$3,$4,$5)") .bind(tenant) .bind(name) .bind(package.worker.sha256) .bind(package.worker.bytes as i64) + .bind(official_windows(platform)) .execute(&mut **tx) .await?; } diff --git a/migrations/0037_official_windows_starter_worker.sql b/migrations/0037_official_windows_starter_worker.sql new file mode 100644 index 0000000..3a929c2 --- /dev/null +++ b/migrations/0037_official_windows_starter_worker.sql @@ -0,0 +1,4 @@ +-- Older GNU starter rows identify development workers. Keep their historical +-- pin out of an official enrollment after a catalog switches signing trust. +ALTER TABLE customer_starter_workers + ADD COLUMN official_windows boolean NOT NULL DEFAULT false; diff --git a/tools/dev_customer_starters.py b/tools/dev_customer_starters.py index 4b81633..5f53933 100644 --- a/tools/dev_customer_starters.py +++ b/tools/dev_customer_starters.py @@ -29,11 +29,11 @@ def publish(tenant, platform, release, official_windows=False, *, root=Path('/op sql = """SELECT json_build_object('envelope',convert_from(envelope,'UTF8')::json, 'agent',agent_sha256,'agent_size',agent_bytes,'helper',helper_sha256,'helper_size',helper_bytes, 'starter_worker',(SELECT json_build_object('sha256',sha256,'bytes',size_bytes) - FROM customer_starter_workers WHERE tenant_id=:'customer' AND platform=:'platform')) + FROM customer_starter_workers WHERE tenant_id=:'customer' AND platform=:'platform' AND official_windows=:'official'::boolean)) FROM agent_update_releases WHERE tenant_id=:'customer' AND platform=:'platform' AND release_id=:'release';""" raw = subprocess.check_output(['docker','exec','-i',database_container, 'psql','-XqtA','-v','ON_ERROR_STOP=1','-U','postgres','-d','rmm','-v','customer='+tenant, - '-v','platform='+platform,'-v','release='+release],input=sql.encode()) + '-v','platform='+platform,'-v','official='+str(official_windows),'-v','release='+release],input=sql.encode()) if not raw.strip(): raise ValueError('Selected release is missing from the source customer catalog') row = json.loads(raw)