This commit is contained in:
DavidXanatos 2023-01-29 10:49:41 +01:00
parent e6090835b2
commit 083e0c36a9
9 changed files with 78 additions and 21 deletions

View File

@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
-- use OpenClsid={00000000-0000-0000-0000-000000000000} to open all
- the SandMan UI now indicates if a sandboxed process has a Elevated(Admin) or System token
- DropAdminRights can now be configured per process [#2293](https://github.com/sandboxie-plus/Sandboxie/issues/2293)
- added self removing boxes [#1936](https://github.com/sandboxie-plus/Sandboxie/issues/1936)
### Changed
- refactored network blocking code in driver

View File

@ -30,6 +30,13 @@ SB_PROGRESS CCleanUpJob::Start()
return Status;
}
void CCleanUpJob::Finished()
{
CSandBoxPlus* pBox = GetBox();
emit theAPI->BoxCleaned(pBox);
}
///////////////////////////////////////////////////////////////////////////////
// COnDeleteJob
//

View File

@ -12,6 +12,7 @@ public:
CBoxJob(QObject* parent = NULL) : QObject(parent) { }
virtual SB_PROGRESS Start() = 0;
virtual void Finished() = 0;
CSbieProgressPtr GetProgress() { return m_pProgress; }
QString GetDescription(){ return m_Description; }
@ -38,6 +39,7 @@ protected:
}
virtual SB_PROGRESS Start();
virtual void Finished();
protected:
bool m_DeleteShapshots;
@ -58,6 +60,7 @@ protected:
}
virtual SB_PROGRESS Start();
virtual void Finished() {}
protected:
QString m_Command;

View File

@ -170,6 +170,7 @@ CSandMan::CSandMan(QWidget *parent)
connect(theAPI, SIGNAL(BoxAdded(const CSandBoxPtr&)), this, SLOT(OnBoxAdded(const CSandBoxPtr&)));
connect(theAPI, SIGNAL(BoxClosed(const CSandBoxPtr&)), this, SLOT(OnBoxClosed(const CSandBoxPtr&)));
connect(theAPI, SIGNAL(BoxCleaned(CSandBoxPlus*)), this, SLOT(OnBoxCleaned(CSandBoxPlus*)));
QString appTitle = tr("Sandboxie-Plus v%1").arg(GetVersion());
@ -1522,7 +1523,7 @@ SB_STATUS CSandMan::DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, boo
Ret = Status;
if (Status.GetStatus() == OP_ASYNC) {
Ret = AddAsyncOp(Status.GetValue(), true, tr("Auto Deleting %1 Content").arg(pBox->GetName()));
pBox.objectCast<CSandBoxPlus>()->UpdateSize();
OnBoxCleaned(qobject_cast<CSandBoxPlus*>(pBox.data()));
}
}
@ -1671,27 +1672,43 @@ void CSandMan::OnStartMenuChanged()
void CSandMan::OnBoxClosed(const CSandBoxPtr& pBox)
{
if (!pBox->GetBool("NeverDelete", false) && pBox->GetBool("AutoDelete", false) && !pBox->IsEmpty())
if (!pBox->GetBool("NeverDelete", false))
{
bool DeleteShapshots = false;
// if this box auto deletes first show the recovry dialog with the option to abort deletion
if(!theGUI->OpenRecovery(pBox, DeleteShapshots, true)) // unless no files are found than continue silently
return;
if(theConf->GetBool("Options/AutoBoxOpsNotify", false))
OnLogMessage(tr("Auto deleting content of %1").arg(pBox->GetName()), true);
if (theConf->GetBool("Options/UseAsyncBoxOps", false) || IsSilentMode())
if (pBox->GetBool("AutoDelete", false))
{
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
SB_STATUS Status = pBoxEx->DeleteContentAsync(DeleteShapshots);
CheckResults(QList<SB_STATUS>() << Status);
bool DeleteShapshots = false;
// if this box auto deletes first show the recovry dialog with the option to abort deletion
if (!theGUI->OpenRecovery(pBox, DeleteShapshots, true)) // unless no files are found than continue silently
return;
if (theConf->GetBool("Options/AutoBoxOpsNotify", false))
OnLogMessage(tr("Auto deleting content of %1").arg(pBox->GetName()), true);
if (theConf->GetBool("Options/UseAsyncBoxOps", false) || IsSilentMode())
{
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
SB_STATUS Status = pBoxEx->DeleteContentAsync(DeleteShapshots);
CheckResults(QList<SB_STATUS>() << Status);
}
else
DeleteBoxContent(pBox, eAuto, DeleteShapshots);
}
else
DeleteBoxContent(pBox, eAuto, DeleteShapshots);
}
}
void CSandMan::OnBoxCleaned(CSandBoxPlus* pBoxEx)
{
if (pBoxEx->GetBool("AutoRemove", false))
{
if (theConf->GetBool("Options/AutoBoxOpsNotify", false))
OnLogMessage(tr("Auto removing sandbox %1").arg(pBoxEx->GetName()), true);
pBoxEx->RemoveBox();
return;
}
pBoxEx->UpdateSize();
}
void CSandMan::OnStatusChanged()
{
QString appTitle = tr("Sandboxie-Plus v%1").arg(GetVersion());

View File

@ -170,6 +170,7 @@ public slots:
void OnBoxAdded(const CSandBoxPtr& pBox);
void OnBoxClosed(const CSandBoxPtr& pBox);
void OnBoxCleaned(CSandBoxPlus* pBoxEx);
void OnStartMenuChanged();

View File

@ -957,11 +957,11 @@ void CSandBoxPlus::OnAsyncFinished()
theGUI->CheckResults(QList<SB_STATUS>() << Status);
return;
}
else
pJob->Finished();
if (!m_JobQueue.isEmpty())
StartNextJob();
else
UpdateSize();
}
void CSandBoxPlus::OnAsyncMessage(const QString& Text)

View File

@ -38,6 +38,9 @@ private slots:
virtual void OnStartFinished();
virtual void SbieIniSetSection(const QString& Section, const QString& Value) { SbieIniSet(Section, "", Value); }
signals:
void BoxCleaned(CSandBoxPlus* pBoxEx);
protected:
friend class CSandBoxPlus;

View File

@ -100,6 +100,7 @@ void CFileView::OnAboutToBeCleaned()
#define MENU_RECOVER 1
#define MENU_RECOVER_TO_ANY 2
#define MENU_CREATE_SHORTCUT 3
#define MENU_CHECK_FILE 4
void addSeparatorToShellContextMenu(HMENU hMenu)
{
@ -166,6 +167,11 @@ int openShellContextMenu(const QStringList& Files, void * parentWindow, const CS
std::wstring Str3 = CFileView::tr("Recover to Same Folder").toStdWString();
addItemToShellContextMenu(hMenu, Str3.c_str(), MENU_RECOVER);
if (!pBox->GetTextList("OnFileRecovery", true, false, true).isEmpty()) {
std::wstring Str4 = CFileView::tr("Run Recovery Checks").toStdWString();
addItemToShellContextMenu(hMenu, Str4.c_str(), MENU_CHECK_FILE);
}
POINT point;
GetCursorPos(&point);
int iCmd = TrackPopupMenuEx(hMenu, TPM_RETURNCMD, point.x, point.y, (HWND)parentWindow, NULL);
@ -260,6 +266,13 @@ void CFileView::OnFileMenu(const QPoint&)
break;
}
case MENU_CHECK_FILE:
{
SB_PROGRESS Status = theGUI->CheckFiles(m_pBox->GetName(), Files);
if (Status.GetStatus() == OP_ASYNC)
theGUI->AddAsyncOp(Status.GetValue());
break;
}
case MENU_CREATE_SHORTCUT:
{
QString BoxName = m_pBox->GetName();

View File

@ -98,7 +98,11 @@ SB_STATUS CNewBoxWizard::TryToCreateBox()
if(field("useVolumeSN").toBool())
pBox->SetBool("UseVolumeSerialNumbers", true);
if(field("autoDelete").toBool())
if (field("autoRemove").toBool()) {
pBox->SetBool("AutoDelete", true);
pBox->SetBool("AutoRemove", true);
}
else if(field("autoDelete").toBool())
pBox->SetBool("AutoDelete", true);
if(field("autoRecover").toBool())
pBox->SetBool("AutoRecover", true);
@ -189,11 +193,15 @@ CBoxTypePage::CBoxTypePage(QWidget *parent)
m_pBoxType->setCurrentIndex(3); // default
QWidget* pSpacer = new QWidget();
pSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layout->addWidget(pSpacer, row++, 1);
QCheckBox* pTemp = new QCheckBox(tr("Remove after use"));
pTemp->setToolTip(tr("After the last process in the box terminates, all data in the box will be deleted and the box itself will be removed."));
layout->addWidget(pTemp, row, 0, 1, 2);
registerField("autoRemove", pTemp);
m_pAdvanced = new QCheckBox(tr("Configure advanced options"));
layout->addWidget(m_pAdvanced, row++, 2);
connect(m_pAdvanced, SIGNAL(toggled(bool)), this, SLOT(OnAdvanced()));
@ -321,6 +329,8 @@ CFilesPage::CFilesPage(QWidget *parent)
QCheckBox* pAutoDelete = new QCheckBox(tr("Auto delete content when last process terminates"));
pAutoDelete->setChecked(theConf->GetBool("BoxDefaults/AutoDelete", false));
layout->addWidget(pAutoDelete, row++, 1, 1, 3);
if (field("autoRemove").toBool())
pAutoDelete->setEnabled(false);
registerField("autoDelete", pAutoDelete);
QCheckBox* pAutoRecover = new QCheckBox(tr("Enable Immediate Recovery of files from recovery locations"));
@ -514,7 +524,9 @@ void CSummaryPage::initializePage()
Location = ((CNewBoxWizard*)wizard())->GetDefaultLocation();
m_pSummary->append(tr("\nThis Sandbox will be saved to: %1").arg(Location));
if (field("autoDelete").toBool())
if (field("autoRemove").toBool())
m_pSummary->append(tr("\nThis box's content will be DISCARDED when its closed, and the box will be removed."));
else if (field("autoDelete").toBool())
m_pSummary->append(tr("\nThis box will DISCARD its content when its closed, its suitable only for temporary data."));
if (field("blockNetwork").toInt())
m_pSummary->append(tr("\nProcesses in this box will not be able to access the internet or the local network, this ensures all accessed data to stay confidential."));