This commit is contained in:
DavidXanatos 2024-01-29 09:21:13 +01:00
parent bf43dd0d43
commit 7997025f4e
3 changed files with 31 additions and 20 deletions

View File

@ -120,7 +120,7 @@ static NTSTATUS Conf_Merge_Global(
static NTSTATUS Conf_Merge_Template( static NTSTATUS Conf_Merge_Template(
CONF_DATA *data, ULONG session_id, CONF_DATA *data, ULONG session_id,
const WCHAR *tmpl_name, CONF_SECTION *section); const WCHAR *tmpl_name, CONF_SECTION *section, const WCHAR* name);
static const WCHAR *Conf_Get_Helper( static const WCHAR *Conf_Get_Helper(
const WCHAR *section_name, const WCHAR *setting_name, const WCHAR *section_name, const WCHAR *setting_name,
@ -866,7 +866,7 @@ _FX NTSTATUS Conf_Merge_Templates(CONF_DATA *data, ULONG session_id)
// //
status = Conf_Merge_Template( status = Conf_Merge_Template(
data, session_id, setting->value, sandbox); data, session_id, setting->value, sandbox, NULL);
if (! NT_SUCCESS(status)) if (! NT_SUCCESS(status))
return status; return status;
@ -955,7 +955,7 @@ _FX NTSTATUS Conf_Merge_Global(
// //
status = Conf_Merge_Template( status = Conf_Merge_Template(
data, session_id, setting->value, sandbox); data, session_id, setting->value, sandbox, L"GlobalSettings");
if (! NT_SUCCESS(status)) if (! NT_SUCCESS(status))
return status; return status;
@ -985,7 +985,7 @@ _FX NTSTATUS Conf_Merge_Global(
_FX NTSTATUS Conf_Merge_Template( _FX NTSTATUS Conf_Merge_Template(
CONF_DATA *data, ULONG session_id, CONF_DATA *data, ULONG session_id,
const WCHAR *tmpl_name, CONF_SECTION *section) const WCHAR *tmpl_name, CONF_SECTION *section, const WCHAR* name)
{ {
CONF_SECTION *tmpl = NULL; CONF_SECTION *tmpl = NULL;
@ -1036,7 +1036,7 @@ _FX NTSTATUS Conf_Merge_Template(
} else { } else {
Log_Msg_Session(MSG_CONF_MISSING_TMPL, Log_Msg_Session(MSG_CONF_MISSING_TMPL,
section->name, tmpl_name, session_id); name ? name : section->name, tmpl_name, session_id);
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;

View File

@ -1827,17 +1827,20 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
if (!m_MissingTemplates.isEmpty()) if (!m_MissingTemplates.isEmpty())
{ {
if (m_MissingTemplates[0] == "") {
m_MissingTemplates.clear();
return;
}
int CleanupTemplates = theConf->GetInt("Options/AutoCleanupTemplates", -1); int CleanupTemplates = theConf->GetInt("Options/AutoCleanupTemplates", -1);
if (CleanupTemplates == -1) if (CleanupTemplates == -1)
{ {
QStringList AllTemplates;
foreach(const QSet<QString>& Templates, m_MissingTemplates) {
foreach(const QString & Template, Templates) {
if (!AllTemplates.contains(Template))
AllTemplates.append(Template);
}
}
bool State = false; bool State = false;
CleanupTemplates = CCheckableMessageBox::question(this, "Sandboxie-Plus", tr("Some compatibility templates (%1) are missing, probably deleted, do you want to remove them from all boxes?") CleanupTemplates = CCheckableMessageBox::question(this, "Sandboxie-Plus", tr("Some compatibility templates (%1) are missing, probably deleted, do you want to remove them from all boxes?")
.arg(m_MissingTemplates.join(", ")) .arg(AllTemplates.join(", "))
, tr("Don't show this message again."), &State, QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::Yes, QMessageBox::Information) == QDialogButtonBox::Yes ? 1 : 0; , tr("Don't show this message again."), &State, QDialogButtonBox::Yes | QDialogButtonBox::No, QDialogButtonBox::Yes, QMessageBox::Information) == QDialogButtonBox::Yes ? 1 : 0;
if (State) if (State)
@ -1846,18 +1849,26 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
if (CleanupTemplates) if (CleanupTemplates)
{ {
foreach(const QString& Template, m_MissingTemplates) for(auto I = m_MissingTemplates.begin(); I != m_MissingTemplates.end(); ++I)
{ {
theAPI->GetGlobalSettings()->DelValue("Template", Template); QSharedPointer<CSbieIni> Section;
foreach(const CSandBoxPtr& pBox, theAPI->GetAllBoxes()) if (I.key() == "GlobalSettings")
pBox->DelValue("Template", Template); Section = theAPI->GetGlobalSettings();
else
Section = theAPI->GetBoxByName(I.key());
if (!Section) continue;
Section->SetRefreshOnChange(false);
foreach(const QString & Template, I.value())
Section->DelValue("Template", Template);
Section->SetRefreshOnChange(true);
} }
theAPI->CommitIniChanges();
OnLogMessage(tr("Cleaned up removed templates...")); OnLogMessage(tr("Cleaned up removed templates..."));
} }
m_MissingTemplates.clear(); m_MissingTemplates.clear();
m_MissingTemplates.append("");
} }
} }
@ -2738,8 +2749,8 @@ void CSandMan::OnLogSbieMessage(quint32 MsgCode, const QStringList& MsgData, qui
if ((MsgCode & 0xFFFF) == 1411) // removed/missing template if ((MsgCode & 0xFFFF) == 1411) // removed/missing template
{ {
if(MsgData.size() >= 3 && !m_MissingTemplates.contains(MsgData[2])) if (MsgData.size() >= 3)
m_MissingTemplates.append(MsgData[2]); m_MissingTemplates[MsgData[1]].insert(MsgData[2]);
} }
if ((MsgCode & 0xFFFF) == 6004 || (MsgCode & 0xFFFF) == 6008 || (MsgCode & 0xFFFF) == 6009) // certificate error if ((MsgCode & 0xFFFF) == 6004 || (MsgCode & 0xFFFF) == 6008 || (MsgCode & 0xFFFF) == 6009) // certificate error

View File

@ -159,7 +159,7 @@ protected:
QMap<CSbieProgress*, QPair<CSbieProgressPtr, QPointer<QWidget>>> m_pAsyncProgress; QMap<CSbieProgress*, QPair<CSbieProgressPtr, QPointer<QWidget>>> m_pAsyncProgress;
QStringList m_MissingTemplates; QMap<QString, QSet<QString>> m_MissingTemplates;
enum EBoxColors enum EBoxColors
{ {