Apply the script-only capability and start contract to every Windows profile
This commit is contained in:
@@ -34,7 +34,6 @@ struct Qualification {
|
||||
pub fn qualified(
|
||||
pin: &Pin,
|
||||
clock_qualified: bool,
|
||||
reboot_privilege_available: Option<bool>,
|
||||
) -> Result<Vec<String>> {
|
||||
if !clock_qualified {
|
||||
return Ok(vec![]);
|
||||
@@ -92,67 +91,21 @@ pub fn qualified(
|
||||
&& settings.enable_effects,
|
||||
"system qualification effective policy"
|
||||
);
|
||||
if !q.actions.iter().any(|action| action == "run_script") {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
let general = settings.allowed_script_profiles.as_deref() ==
|
||||
Some(&[rmm_domain::jobs::PrivilegedScriptProfile::FullMaintenanceV1]);
|
||||
let windows_update = settings.windows_update_max_runtime_seconds.is_some();
|
||||
ensure!(settings.schema_version >= 3 && (general || windows_update), "system script qualification policy");
|
||||
let mut caps = vec![
|
||||
"helper.system.v1".into(),
|
||||
format!("helper.binary.sha256:{}", pin.helper.binary_sha256),
|
||||
format!("helper.policy.sha256:{}", pin.policy_sha256),
|
||||
"system:run_script".into(),
|
||||
];
|
||||
for action in q.actions {
|
||||
match action.as_str() {
|
||||
"run_script" => {
|
||||
let general = settings.allowed_script_profiles.as_deref() ==
|
||||
Some(&[rmm_domain::jobs::PrivilegedScriptProfile::FullMaintenanceV1]);
|
||||
let windows_update = settings.windows_update_max_runtime_seconds.is_some();
|
||||
ensure!(settings.schema_version >= 3 && (general || windows_update), "system script qualification policy");
|
||||
caps.push("system:run_script".into());
|
||||
if general { caps.push(rmm_domain::jobs::FULL_MAINTENANCE_CAPABILITY.to_owned()); }
|
||||
if windows_update { caps.push(rmm_domain::jobs::WINDOWS_UPDATE_LONG_CAPABILITY.to_owned()); }
|
||||
}
|
||||
"set_service_state" => {
|
||||
ensure!(
|
||||
!settings.allowed_services.is_empty(),
|
||||
"system SCM qualification policy"
|
||||
);
|
||||
caps.extend(["set_service_state", "system:set_service_state"].map(str::to_string));
|
||||
}
|
||||
"ensure_package" => {
|
||||
ensure!(
|
||||
settings.schema_version >= 2
|
||||
&& settings
|
||||
.allowed_msi_recipe_sha256
|
||||
.as_ref()
|
||||
.is_some_and(|v| !v.is_empty())
|
||||
&& crate::msi_cache::stage_configured(),
|
||||
"system MSI qualification policy"
|
||||
);
|
||||
caps.extend(
|
||||
[
|
||||
"ensure_package",
|
||||
"system:ensure_package",
|
||||
rmm_domain::windows_execution::MSI_CAPABILITY,
|
||||
]
|
||||
.map(str::to_string),
|
||||
);
|
||||
}
|
||||
"reboot" => {
|
||||
ensure!(
|
||||
settings.schema_version == 4
|
||||
&& settings.allow_reboot
|
||||
&& reboot_privilege_available == Some(true),
|
||||
"system reboot qualification policy or live token"
|
||||
);
|
||||
caps.extend(
|
||||
[
|
||||
"reboot",
|
||||
"system:reboot",
|
||||
rmm_domain::windows_reboot::CAPABILITY,
|
||||
]
|
||||
.map(str::to_string),
|
||||
);
|
||||
}
|
||||
_ => unreachable!("validated qualification action"),
|
||||
}
|
||||
}
|
||||
if general { caps.push(rmm_domain::jobs::FULL_MAINTENANCE_CAPABILITY.into()); }
|
||||
if windows_update { caps.push(rmm_domain::jobs::WINDOWS_UPDATE_LONG_CAPABILITY.into()); }
|
||||
Ok(caps)
|
||||
}
|
||||
fn read(path: &Path, max: u64) -> Result<Vec<u8>> {
|
||||
|
||||
Reference in New Issue
Block a user