From 9acc08a599675504ca590db7a2fc889ef976e3e1 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sun, 31 Mar 2024 14:26:01 -0400 Subject: [PATCH] Remove optional command run in limits --- backend/limits_core/src/json_v2/base.rs | 9 --------- backend/limits_core/src/json_v2/conditions.rs | 3 --- backend/limits_srv/pt_limits_v2.json | 15 +++------------ backend/src/settings/detect/auto_detect.rs | 9 --------- 4 files changed, 3 insertions(+), 33 deletions(-) diff --git a/backend/limits_core/src/json_v2/base.rs b/backend/limits_core/src/json_v2/base.rs index 72aa0f3..b47f450 100644 --- a/backend/limits_core/src/json_v2/base.rs +++ b/backend/limits_core/src/json_v2/base.rs @@ -24,7 +24,6 @@ impl Default for Base { dmi: None, cpuinfo: None, os: None, - command: None, file_exists: Some("/etc/powertools_dev_mode".into()), }, limits: super::Limits { @@ -48,7 +47,6 @@ impl Default for Base { dmi: None, cpuinfo: Some("model name\t: AMD Custom APU 0405\n".to_owned()), os: None, - command: None, file_exists: None, }, limits: super::Limits { @@ -72,7 +70,6 @@ impl Default for Base { dmi: None, cpuinfo: Some("model name\t: AMD Custom APU 0932\n".to_owned()), os: None, - command: None, file_exists: None, }, limits: super::Limits { @@ -96,7 +93,6 @@ impl Default for Base { dmi: None, cpuinfo: Some("model name\t+: AMD Ryzen 3 2300U\n".to_owned()), os: None, - command: None, file_exists: None, }, limits: super::Limits { @@ -140,7 +136,6 @@ impl Default for Base { dmi: None, cpuinfo: Some("model name\t+: AMD Ryzen 5 5560U\n".to_owned()), os: None, - command: None, file_exists: None, }, limits: super::Limits { @@ -184,7 +179,6 @@ impl Default for Base { dmi: None, cpuinfo: Some("model name\t+: AMD Ryzen 7 5825U\n".to_owned()), os: None, - command: None, file_exists: None, }, limits: super::Limits { @@ -228,7 +222,6 @@ impl Default for Base { dmi: None, cpuinfo: Some("model name\t+: AMD Ryzen 7 6800U( with Radeon Graphics)?\n".to_owned()), os: None, - command: None, file_exists: None, }, limits: super::Limits { @@ -272,7 +265,6 @@ impl Default for Base { dmi: None, cpuinfo: Some("model name\\s+: AMD Ryzen 7 7840U( w\\/ Radeon 780M Graphics)?\n".to_owned()), os: None, - command: None, file_exists: None, }, limits: super::Limits { @@ -316,7 +308,6 @@ impl Default for Base { dmi: None, cpuinfo: None, os: None, - command: None, file_exists: None, }, limits: super::Limits { diff --git a/backend/limits_core/src/json_v2/conditions.rs b/backend/limits_core/src/json_v2/conditions.rs index be08a1c..11607b9 100644 --- a/backend/limits_core/src/json_v2/conditions.rs +++ b/backend/limits_core/src/json_v2/conditions.rs @@ -9,8 +9,6 @@ pub struct Conditions { pub cpuinfo: Option, /// Regex pattern for /etc/os-release reading pub os: Option, - /// Custom command to run, where an exit code of 0 means a successful match - pub command: Option, /// Check if file exists pub file_exists: Option, } @@ -20,7 +18,6 @@ impl Conditions { self.dmi.is_none() && self.cpuinfo.is_none() && self.os.is_none() - && self.command.is_none() && self.file_exists.is_none() } } diff --git a/backend/limits_srv/pt_limits_v2.json b/backend/limits_srv/pt_limits_v2.json index 9250956..0fd8033 100644 --- a/backend/limits_srv/pt_limits_v2.json +++ b/backend/limits_srv/pt_limits_v2.json @@ -6,7 +6,6 @@ "dmi": null, "cpuinfo": null, "os": null, - "command": null, "file_exists": "/etc/powertools_dev_mode" }, "limits": { @@ -391,7 +390,6 @@ "dmi": null, "cpuinfo": "model name\t: AMD Custom APU 0405\n", "os": null, - "command": null, "file_exists": null }, "limits": { @@ -604,8 +602,8 @@ "extras": { "experiments": false, "quirks": [ - "pp_dpm_fclk-not-updated-on-LCD", - "pp_dpm_fclk-reversed" + "pp_dpm_fclk-reversed", + "pp_dpm_fclk-not-updated-on-LCD" ] } } @@ -641,7 +639,6 @@ "dmi": null, "cpuinfo": "model name\t: AMD Custom APU 0932\n", "os": null, - "command": null, "file_exists": null }, "limits": { @@ -870,8 +867,8 @@ "extras": { "experiments": false, "quirks": [ - "pp_dpm_fclk-not-updated-on-LCD", "pp_dpm_fclk-reversed", + "pp_dpm_fclk-not-updated-on-LCD", "clock-autodetect" ] } @@ -908,7 +905,6 @@ "dmi": null, "cpuinfo": "model name\t+: AMD Ryzen 3 2300U\n", "os": null, - "command": null, "file_exists": null }, "limits": { @@ -1062,7 +1058,6 @@ "dmi": null, "cpuinfo": "model name\t+: AMD Ryzen 5 5560U\n", "os": null, - "command": null, "file_exists": null }, "limits": { @@ -1376,7 +1371,6 @@ "dmi": null, "cpuinfo": "model name\t+: AMD Ryzen 7 5825U\n", "os": null, - "command": null, "file_exists": null }, "limits": { @@ -1770,7 +1764,6 @@ "dmi": null, "cpuinfo": "model name\t+: AMD Ryzen 7 6800U( with Radeon Graphics)?\n", "os": null, - "command": null, "file_exists": null }, "limits": { @@ -2164,7 +2157,6 @@ "dmi": null, "cpuinfo": "model name\\s+: AMD Ryzen 7 7840U( w\\/ Radeon 780M Graphics)?\n", "os": null, - "command": null, "file_exists": null }, "limits": { @@ -2552,7 +2544,6 @@ "dmi": null, "cpuinfo": null, "os": null, - "command": null, "file_exists": null }, "limits": { diff --git a/backend/src/settings/detect/auto_detect.rs b/backend/src/settings/detect/auto_detect.rs index 256f97a..5773f12 100644 --- a/backend/src/settings/detect/auto_detect.rs +++ b/backend/src/settings/detect/auto_detect.rs @@ -111,15 +111,6 @@ pub fn auto_detect0( .expect("Invalid OS regex"); matches &= pattern.is_match(&os_info); } - if let Some(cmd) = &conditions.command { - match std::process::Command::new("bash") - .args(["-c", cmd]) - .status() - { - Ok(status) => matches &= status.code().map(|c| c == 0).unwrap_or(false), - Err(e) => log::warn!("Ignoring bash limits error: {}", e), - } - } if let Some(file_exists) = &conditions.file_exists { let exists = std::path::Path::new(file_exists).exists(); matches &= exists;