Restore SEBPatch
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
* Copyright (c) 2025 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -29,6 +29,7 @@ namespace SafeExamBrowser.Monitoring.System.Components
|
||||
internal void StartMonitoring()
|
||||
{
|
||||
registry.ValueChanged += Registry_ValueChanged;
|
||||
registry.StartMonitoring(RegistryValue.MachineHive.EaseOfAccess_Key, RegistryValue.MachineHive.EaseOfAccess_Name);
|
||||
|
||||
logger.Info("Started monitoring ease of access.");
|
||||
}
|
||||
@@ -36,6 +37,7 @@ namespace SafeExamBrowser.Monitoring.System.Components
|
||||
internal void StopMonitoring()
|
||||
{
|
||||
registry.ValueChanged -= Registry_ValueChanged;
|
||||
registry.StopMonitoring(RegistryValue.MachineHive.EaseOfAccess_Key, RegistryValue.MachineHive.EaseOfAccess_Name);
|
||||
|
||||
logger.Info("Stopped monitoring ease of access.");
|
||||
}
|
||||
@@ -43,14 +45,36 @@ namespace SafeExamBrowser.Monitoring.System.Components
|
||||
internal bool Verify()
|
||||
{
|
||||
logger.Info($"Starting ease of access verification...");
|
||||
logger.Info("Ease of access configuration successfully verified.");
|
||||
|
||||
return true;
|
||||
var success = registry.TryRead(RegistryValue.MachineHive.EaseOfAccess_Key, RegistryValue.MachineHive.EaseOfAccess_Name, out var value);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (value is string s && string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
logger.Info("Ease of access configuration successfully verified.");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Warn($"Ease of access configuration is compromised: '{value}'!");
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = true;
|
||||
logger.Info("Ease of access configuration successfully verified (value does not exist).");
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private void Registry_ValueChanged(string key, string name, object oldValue, object newValue)
|
||||
{
|
||||
|
||||
if (key == RegistryValue.MachineHive.EaseOfAccess_Key)
|
||||
{
|
||||
HandleEaseOfAccessChange(key, name, oldValue, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleEaseOfAccessChange(string key, string name, object oldValue, object newValue)
|
||||
|
Reference in New Issue
Block a user