From b81818b6ad2a2c4935c4a6679d57292069c5d48e Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 9 Jul 2021 12:43:08 +0200 Subject: [PATCH] subscription: set higher-level error to message instead of bailing While the PVE one "bails" too, it has an eval around those and moves the error to the message property, so lets do so too to ensure a user can force an update on a too old subscription Signed-off-by: Thomas Lamprecht --- src/tools/subscription.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/tools/subscription.rs b/src/tools/subscription.rs index 425468f1..1c0e379c 100644 --- a/src/tools/subscription.rs +++ b/src/tools/subscription.rs @@ -258,15 +258,27 @@ pub fn read_subscription() -> Result, Error> { let new_checksum = base64::encode(tools::md5sum(new_checksum.as_bytes())?); if checksum != new_checksum { - bail!("stored checksum doesn't matches computed one '{}' != '{}'", checksum, new_checksum); + return Ok(Some( SubscriptionInfo { + status: SubscriptionStatus::INVALID, + message: Some("checksum mismatch".to_string()), + ..info + })); } let age = proxmox::tools::time::epoch_i64() - info.checktime.unwrap_or(0); if age < -5400 { // allow some delta for DST changes or time syncs, 1.5h - bail!("Last check time to far in the future."); + return Ok(Some( SubscriptionInfo { + status: SubscriptionStatus::INVALID, + message: Some("last check date too far in the future".to_string()), + ..info + })); } else if age > MAX_LOCAL_KEY_AGE + MAX_KEY_CHECK_FAILURE_AGE { if let SubscriptionStatus::ACTIVE = info.status { - bail!("subscription information too old"); + return Ok(Some( SubscriptionInfo { + status: SubscriptionStatus::INVALID, + message: Some("subscription information too old".to_string()), + ..info + })); } }