This commit is contained in:
DavidXanatos 2023-05-29 20:13:22 +02:00
parent cfdc7bf0ac
commit 503f11c063
2 changed files with 21 additions and 8 deletions

View File

@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added ### Added
- added full stack trace to all trace messages - added full stack trace to all trace messages
- added Add option to launch the default notepad editor as non-admin [#2987](https://github.com/sandboxie-plus/Sandboxie/issues/2987)
### Fixed ### Fixed
- fixed an issue with token manipulation in the SbieDrv driver - fixed an issue with token manipulation in the SbieDrv driver
@ -22,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- fixed SandMan: Timestamp of the Sandboxie.ini [#2985](https://github.com/sandboxie-plus/Sandboxie/issues/2985) - fixed SandMan: Timestamp of the Sandboxie.ini [#2985](https://github.com/sandboxie-plus/Sandboxie/issues/2985)
## [1.9.5 / 5.64.5] - 2023-05-26 ## [1.9.5 / 5.64.5] - 2023-05-26
### Added ### Added

View File

@ -2841,17 +2841,15 @@ void CSandMan::OnEditIni()
{ {
QString ini = ((QAction*)sender())->property("ini").toString(); QString ini = ((QAction*)sender())->property("ini").toString();
std::wstring Editor = theConf->GetString("Options/Editor", "notepad.exe").toStdWString(); QString IniPath;
std::wstring IniPath;
bool bPlus; bool bPlus;
if (bPlus = (ini == "plus")) if (bPlus = (ini == "plus"))
{ {
IniPath = L"\"" + QString(theConf->GetConfigDir() + "/Sandboxie-Plus.ini").replace("/", "\\").toStdWString() + L"\""; IniPath = QString(theConf->GetConfigDir() + "/Sandboxie-Plus.ini").replace("/", "\\");
} }
else if (ini == "tmpl") else if (ini == "tmpl")
{ {
IniPath = L"\"" + (theAPI->GetSbiePath() + "\\Templates.ini").toStdWString() + L"\""; IniPath = theAPI->GetSbiePath() + "\\Templates.ini";
if (theConf->GetBool("Options/NoEditWarn", true)) { if (theConf->GetBool("Options/NoEditWarn", true)) {
bool State = false; bool State = false;
@ -2866,7 +2864,7 @@ void CSandMan::OnEditIni()
} }
else //if (ini == "sbie") else //if (ini == "sbie")
{ {
IniPath = L"\"" + theAPI->GetIniPath().toStdWString() + L"\""; IniPath = theAPI->GetIniPath();
if (theConf->GetBool("Options/NoEditInfo", true)) { if (theConf->GetBool("Options/NoEditInfo", true)) {
bool State = false; bool State = false;
@ -2881,13 +2879,26 @@ void CSandMan::OnEditIni()
} }
} }
bool bIsWritable = bPlus;
if (!bIsWritable) {
QFile File(IniPath);
if (File.open(QFile::ReadWrite)) {
bIsWritable = true;
File.close();
}
// todo: warn user about file not being protected
}
std::wstring Editor = theConf->GetString("Options/Editor", "notepad.exe").toStdWString();
std::wstring iniPath = L"\"" + IniPath.toStdWString() + L"\"";
SHELLEXECUTEINFO si = { 0 }; SHELLEXECUTEINFO si = { 0 };
si.cbSize = sizeof(SHELLEXECUTEINFO); si.cbSize = sizeof(SHELLEXECUTEINFO);
si.fMask = SEE_MASK_NOCLOSEPROCESS; si.fMask = SEE_MASK_NOCLOSEPROCESS;
si.hwnd = NULL; si.hwnd = NULL;
si.lpVerb = bPlus ? NULL : L"runas"; // plus ini does not require admin privileges si.lpVerb = bIsWritable ? NULL : L"runas"; // plus ini does not require admin privileges
si.lpFile = Editor.c_str(); si.lpFile = Editor.c_str();
si.lpParameters = IniPath.c_str(); si.lpParameters = iniPath.c_str();
si.lpDirectory = NULL; si.lpDirectory = NULL;
si.nShow = SW_SHOW; si.nShow = SW_SHOW;
si.hInstApp = NULL; si.hInstApp = NULL;