Skip to content

Commit

Permalink
SEBWIN-401: Implemented fix for VMware issue: The registry values wil…
Browse files Browse the repository at this point in the history
…l now only be set if the active configuration explicity says so.
  • Loading branch information
dbuechel committed May 20, 2020
1 parent 87882c3 commit 7b8c69c
Show file tree
Hide file tree
Showing 10 changed files with 962 additions and 834 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ internal override void Map(string key, object value, AppSettings settings)
case Keys.Service.EnableUserSwitch:
MapEnableUserSwitch(settings, value);
break;
case Keys.Service.EnableVmWareOverlay:
MapEnableVmWareOverlay(settings, value);
case Keys.Service.EnableVmwareOverlay:
MapEnableVmwareOverlay(settings, value);
break;
case Keys.Service.EnableWindowsUpdate:
MapEnableWindowsUpdate(settings, value);
break;
case Keys.Service.SetVmwareConfiguration:
MapSetVmwareConfiguration(settings, value);
break;
}
}

Expand Down Expand Up @@ -135,7 +138,7 @@ private void MapEnableUserSwitch(AppSettings settings, object value)
}
}

private void MapEnableVmWareOverlay(AppSettings settings, object value)
private void MapEnableVmwareOverlay(AppSettings settings, object value)
{
if (value is bool enable)
{
Expand All @@ -150,5 +153,13 @@ private void MapEnableWindowsUpdate(AppSettings settings, object value)
settings.Service.DisableWindowsUpdate = !enable;
}
}

private void MapSetVmwareConfiguration(AppSettings settings, object value)
{
if (value is bool set)
{
settings.Service.SetVmwareConfiguration = set;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ internal AppSettings LoadDefaultSettings()
settings.Service.DisableVmwareOverlay = true;
settings.Service.DisableWindowsUpdate = true;
settings.Service.Policy = ServicePolicy.Mandatory;
settings.Service.SetVmwareConfiguration = false;

settings.Taskbar.EnableTaskbar = true;
settings.Taskbar.ShowApplicationInfo = false;
Expand Down
3 changes: 2 additions & 1 deletion SafeExamBrowser.Configuration/ConfigurationData/Keys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ internal static class Service
internal const string EnableTaskManager = "insideSebEnableStartTaskManager";
internal const string EnableUserLock = "insideSebEnableLockThisComputer";
internal const string EnableUserSwitch = "insideSebEnableSwitchUser";
internal const string EnableVmWareOverlay = "insideSebEnableVmWareClientShade";
internal const string EnableVmwareOverlay = "insideSebEnableVmWareClientShade";
internal const string EnableWindowsUpdate = "enableWindowsUpdate";
internal const string SetVmwareConfiguration = "setVmwareConfiguration";
}

internal static class UserInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SafeExamBrowser.Configuration.Contracts;
using SafeExamBrowser.Settings;
using SafeExamBrowser.Core.Contracts.OperationModel;
using SafeExamBrowser.Lockdown.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.Service.Operations;
using SafeExamBrowser.Settings;

namespace SafeExamBrowser.Service.UnitTests.Operations
{
Expand Down Expand Up @@ -58,6 +58,7 @@ public void Perform_MustSetConfigurationsCorrectly()
settings.Service.DisableChromeNotifications = true;
settings.Service.DisableEaseOfAccessOptions = true;
settings.Service.DisableSignout = true;
settings.Service.SetVmwareConfiguration = true;

var result = sut.Perform();

Expand All @@ -72,6 +73,28 @@ public void Perform_MustSetConfigurationsCorrectly()
Assert.AreEqual(OperationResult.Success, result);
}

[TestMethod]
public void Perform_MustOnlySetVmwareConfigurationIfEnabled()
{
var configuration = new Mock<IFeatureConfiguration>();

configuration.SetReturnsDefault(true);
factory.SetReturnsDefault(configuration.Object);
settings.Service.SetVmwareConfiguration = true;

sut.Perform();

factory.Verify(f => f.CreateVmwareOverlayConfiguration(It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once);

factory.Reset();
factory.SetReturnsDefault(configuration.Object);
settings.Service.SetVmwareConfiguration = false;

sut.Perform();

factory.Verify(f => f.CreateVmwareOverlayConfiguration(It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
}

[TestMethod]
public void Perform_MustUseSameGroupForAllConfigurations()
{
Expand All @@ -84,6 +107,7 @@ public void Perform_MustUseSameGroupForAllConfigurations()
.Returns(configuration.Object)
.Callback<Guid, string, string>((id, name, sid) => groupId = id);
factory.SetReturnsDefault(configuration.Object);
settings.Service.SetVmwareConfiguration = true;

sut.Perform();

Expand Down
9 changes: 7 additions & 2 deletions SafeExamBrowser.Service/Operations/LockdownOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

using System;
using System.Collections.Generic;
using SafeExamBrowser.Core.Contracts.OperationModel;
using SafeExamBrowser.Lockdown.Contracts;
using SafeExamBrowser.Logging.Contracts;
Expand Down Expand Up @@ -41,7 +42,7 @@ public override OperationResult Perform()
var success = true;
var sid = Context.Configuration.UserSid;
var userName = Context.Configuration.UserName;
var configurations = new []
var configurations = new List<(IFeatureConfiguration, bool)>
{
(factory.CreateChangePasswordConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisablePasswordChange),
(factory.CreateChromeNotificationConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisableChromeNotifications),
Expand All @@ -54,10 +55,14 @@ public override OperationResult Perform()
(factory.CreateSwitchUserConfiguration(groupId), Context.Configuration.Settings.Service.DisableUserSwitch),
(factory.CreateTaskManagerConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisableTaskManager),
(factory.CreateUserPowerOptionsConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisablePowerOptions),
(factory.CreateVmwareOverlayConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisableVmwareOverlay),
(factory.CreateWindowsUpdateConfiguration(groupId), Context.Configuration.Settings.Service.DisableWindowsUpdate)
};

if (Context.Configuration.Settings.Service.SetVmwareConfiguration)
{
configurations.Add((factory.CreateVmwareOverlayConfiguration(groupId, sid, userName), Context.Configuration.Settings.Service.DisableVmwareOverlay));
}

logger.Info($"Attempting to perform lockdown (feature configuration group: {groupId})...");

foreach (var (configuration, disable) in configurations)
Expand Down
5 changes: 5 additions & 0 deletions SafeExamBrowser.Settings/Service/ServiceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,10 @@ public class ServiceSettings
/// The active policy for the service component.
/// </summary>
public ServicePolicy Policy { get; set; }

/// <summary>
/// Determines whether the VMware configuration will be set by the service.
/// </summary>
public bool SetVmwareConfiguration { get; set; }
}
}
2 changes: 2 additions & 0 deletions SebWindowsConfig/SEBSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ public class SEBSettings
public const String KeyInsideSebEnableEaseOfAccess = "insideSebEnableEaseOfAccess";
public const String KeyInsideSebEnableVmWareClientShade = "insideSebEnableVmWareClientShade";
public const String KeyInsideSebEnableNetworkConnectionSelector = "insideSebEnableNetworkConnectionSelector";
public const String KeySetVmwareConfiguration = "setVmwareConfiguration";

// Group "Hooked Keys"
public const String KeyHookKeys = "hookKeys";
Expand Down Expand Up @@ -929,6 +930,7 @@ public static void CreateDefaultAndCurrentSettingsFromScratch()
SEBSettings.settingsDefault.Add(SEBSettings.KeyInsideSebEnableEaseOfAccess , false);
SEBSettings.settingsDefault.Add(SEBSettings.KeyInsideSebEnableVmWareClientShade, false);
SEBSettings.settingsDefault.Add(SEBSettings.KeyInsideSebEnableNetworkConnectionSelector, false);
SEBSettings.settingsDefault.Add(SEBSettings.KeySetVmwareConfiguration, false);

// Default settings for group "Hooked Keys"
SEBSettings.settingsDefault.Add(SEBSettings.KeyHookKeys, true);
Expand Down
37 changes: 27 additions & 10 deletions SebWindowsConfig/SebWindowsConfigForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions SebWindowsConfig/SebWindowsConfigForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,8 @@ private void UpdateAllWidgetsOfProgram()
checkBoxInsideSebEnableLogOff .Checked = (Boolean)SEBSettings.settingsCurrent[SEBSettings.KeyInsideSebEnableLogOff];
checkBoxInsideSebEnableShutDown .Checked = (Boolean)SEBSettings.settingsCurrent[SEBSettings.KeyInsideSebEnableShutDown];
checkBoxInsideSebEnableEaseOfAccess .Checked = (Boolean)SEBSettings.settingsCurrent[SEBSettings.KeyInsideSebEnableEaseOfAccess];
checkBoxSetVmwareConfiguration.Checked = (Boolean)SEBSettings.settingsCurrent[SEBSettings.KeySetVmwareConfiguration];
checkBoxInsideSebEnableVmWareClientShade.Enabled = checkBoxSetVmwareConfiguration.Checked;
checkBoxInsideSebEnableVmWareClientShade.Checked = (Boolean)SEBSettings.settingsCurrent[SEBSettings.KeyInsideSebEnableVmWareClientShade];
checkBoxInsideSebEnableNetworkConnectionSelector.Checked = (Boolean)SEBSettings.settingsCurrent[SEBSettings.KeyInsideSebEnableNetworkConnectionSelector];

Expand Down Expand Up @@ -4550,5 +4552,11 @@ private void checkBoxAllowPdfReaderToolbar_CheckedChanged(object sender, EventAr
{
SEBSettings.settingsCurrent[SEBSettings.KeyAllowPDFReaderToolbar] = checkBoxAllowPdfReaderToolbar.Checked;
}

private void checkBoxSetVmwareConfiguration_CheckedChanged(object sender, EventArgs e)
{
SEBSettings.settingsCurrent[SEBSettings.KeySetVmwareConfiguration] = checkBoxSetVmwareConfiguration.Checked;
checkBoxInsideSebEnableVmWareClientShade.Enabled = checkBoxSetVmwareConfiguration.Checked;
}
}
}
Loading

0 comments on commit 7b8c69c

Please sign in to comment.