Bind Windows maintenance permission to update template and device identity probe
This commit is contained in:
@@ -59,6 +59,8 @@ pub const WINDOWS_UPDATE_SCRIPT_UTF8: &str = include_str!("windows_update.ps1");
|
||||
pub const WINDOWS_UPDATE_SCRIPT_SHA256: &str =
|
||||
"0fa5f513a06b6cf902a3f9ac1989987642c181eedd6c305b3912771bd10f2ebf";
|
||||
pub const WINDOWS_UPDATE_MAX_SECONDS: u32 = 3600;
|
||||
pub const WINDOWS_UPDATE_IDENTITY_PROBE: &str =
|
||||
"Write-Output ([System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value)\n";
|
||||
pub const WINDOWS_UPDATE_LONG_CAPABILITY: &str = "script.windows_update.long/1";
|
||||
pub fn valid_windows_update_limit(limit: Option<u32>) -> bool {
|
||||
limit.is_none_or(|seconds| (121..=WINDOWS_UPDATE_MAX_SECONDS).contains(&seconds))
|
||||
@@ -412,11 +414,18 @@ impl Action {
|
||||
)
|
||||
}
|
||||
pub fn is_windows_update_template(&self) -> bool {
|
||||
self.exact_windows_maintenance_script(WINDOWS_UPDATE_SCRIPT_UTF8)
|
||||
}
|
||||
pub fn windows_update_or_identity_probe(&self) -> bool {
|
||||
self.is_windows_update_template()
|
||||
|| self.exact_windows_maintenance_script(WINDOWS_UPDATE_IDENTITY_PROBE)
|
||||
}
|
||||
fn exact_windows_maintenance_script(&self, text: &str) -> bool {
|
||||
matches!(self, Self::RunScript {
|
||||
interpreter, script_utf8, arguments, expected_stdout: None,
|
||||
windows_execution_profile: Some(WindowsExecutionProfile::PowerShell51RemoteSigned),
|
||||
privileged_script_profile: Some(PrivilegedScriptProfile::FullMaintenanceV1),
|
||||
} if interpreter == "powershell" && arguments.is_empty() && script_utf8 == WINDOWS_UPDATE_SCRIPT_UTF8)
|
||||
} if interpreter == "powershell" && arguments.is_empty() && script_utf8 == text)
|
||||
}
|
||||
pub fn windows_system_runtime_limit(&self, normal: u32, windows_update: Option<u32>) -> u32 {
|
||||
if self.is_windows_update_template() {
|
||||
@@ -483,7 +492,9 @@ impl Action {
|
||||
let has = |cap: &str| capabilities.iter().any(|c| c == cap);
|
||||
if !has(self.name())
|
||||
|| (self.full_maintenance()
|
||||
&& !((has(FULL_MAINTENANCE_CAPABILITY) || (self.is_windows_update_template() && has(WINDOWS_UPDATE_LONG_CAPABILITY)))
|
||||
&& !((has(FULL_MAINTENANCE_CAPABILITY)
|
||||
|| (self.windows_update_or_identity_probe()
|
||||
&& has(WINDOWS_UPDATE_LONG_CAPABILITY)))
|
||||
&& has("rmm.sync.v1")
|
||||
&& has(&format!("{}:run_script", identity))
|
||||
&& has(if identity == "root" {
|
||||
|
||||
Reference in New Issue
Block a user