From 184e30c65b55da6c825525abece998895f754734 Mon Sep 17 00:00:00 2001
From: offhub <6871698+offhub@users.noreply.github.com>
Date: Fri, 26 Jul 2024 21:24:41 +0300
Subject: [PATCH] improve chkCreateToken
The checkbox now offers three states, taking into account the global settings. (SandboxieAllGroup > UseCreateToken > Disabled)
---
SandboxiePlus/SandMan/Forms/OptionsWindow.ui | 9 ++++++-
.../SandMan/Windows/OptionsAdvanced.cpp | 25 +++++++++++++++----
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
index 325729b7..c0c0613f 100644
--- a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
+++ b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
@@ -1095,7 +1095,7 @@
-
- 3
+ 4
@@ -1922,9 +1922,16 @@
-
+
+ Checked: A local group will also be added to the newly created sandboxed token, which allows addressing all sandboxes at once. Would be useful for auditing policies.
+Partially checked: No groups will be added to the newly created sandboxed token.
+
Create a new sandboxed token instead of stripping down the original token
+
+ true
+
diff --git a/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp b/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp
index 1bc804fa..b3691a08 100644
--- a/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp
+++ b/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp
@@ -479,7 +479,19 @@ void COptionsWindow::SaveAdvanced()
WriteAdvancedCheck(ui.chkSbieLogon, "SandboxieLogon", bGlobalSbieLogon ? "" : "y", bGlobalSbieLogon ? "n" : "");
bool bGlobalSandboxGroup = m_pBox->GetAPI()->GetGlobalSettings()->GetBool("SandboxieAllGroup", false);
- WriteAdvancedCheck(ui.chkCreateToken, "UseCreateToken", bGlobalSandboxGroup ? "" : "y", "");
+ bool bGlobalCreateToken = m_pBox->GetAPI()->GetGlobalSettings()->GetBool("UseCreateToken", false);
+ if (ui.chkCreateToken->checkState() == Qt::Checked) {
+ WriteAdvancedCheck(ui.chkCreateToken, "SandboxieAllGroup", bGlobalSandboxGroup ? "" : "y");
+ m_pBox->DelValue("UseCreateToken");
+ }
+ else if (ui.chkCreateToken->checkState() == Qt::PartiallyChecked) {
+ m_pBox->SetText("SandboxieAllGroup", "n");
+ m_pBox->SetText("UseCreateToken", "y");
+ }
+ else {
+ WriteAdvancedCheck(ui.chkCreateToken, "SandboxieAllGroup", bGlobalSandboxGroup ? "" : "y", bGlobalSandboxGroup ? "n" : "");
+ WriteAdvancedCheck(ui.chkCreateToken, "UseCreateToken", bGlobalCreateToken ? "" : "y", bGlobalCreateToken ? "n" : "");
+ }
SaveOptionList();
@@ -664,10 +676,13 @@ void COptionsWindow::UpdateBoxIsolation()
}
else {
ReadGlobalCheck(ui.chkSbieLogon, "SandboxieLogon", false);
- ReadGlobalCheck(ui.chkCreateToken, "UseCreateToken", false);
- bool bGlobalSandboxGroup = m_pBox->GetAPI()->GetGlobalSettings()->GetBool("SandboxieAllGroup", false);
- if (bGlobalSandboxGroup)
- ui.chkCreateToken->setEnabled(false);
+
+ if (m_pBox->GetBool("SandboxieAllGroup", false, true))
+ ui.chkCreateToken->setCheckState(Qt::Checked);
+ else if (m_pBox->GetBool("UseCreateToken", false, true))
+ ui.chkCreateToken->setCheckState(Qt::PartiallyChecked);
+ else
+ ui.chkCreateToken->setCheckState(Qt::Unchecked);
}
}