Keep legacy Windows starter worker pins outside official GNU enrollments
This commit is contained in:
@@ -23,6 +23,11 @@ struct TenantPins { current: Pin, previous: Vec<Previous> }
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub(super) struct UpdaterQuery { platform: Platform, sha256: Option<String> }
|
||||
|
||||
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<Config, Error> {
|
||||
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");
|
||||
|
||||
@@ -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?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user