Hot-reload the elevated state?
This commit is contained in:
parent
58c6646132
commit
e5dc64e085
|
@ -869,9 +869,6 @@ namespace winrt::TerminalApp::implementation
|
||||||
void AppLogic::_RegisterSettingsChange()
|
void AppLogic::_RegisterSettingsChange()
|
||||||
{
|
{
|
||||||
const std::filesystem::path settingsPath{ std::wstring_view{ CascadiaSettings::SettingsPath() } };
|
const std::filesystem::path settingsPath{ std::wstring_view{ CascadiaSettings::SettingsPath() } };
|
||||||
const std::filesystem::path statePath{ std::wstring_view{ ApplicationState::SharedInstance().FilePath() } };
|
|
||||||
// const std::filesystem::path elevatedStatePath{ std::wstring_view{ ElevatedState::SharedInstance().FilePath() } };
|
|
||||||
|
|
||||||
_reader.create(
|
_reader.create(
|
||||||
settingsPath.parent_path().c_str(),
|
settingsPath.parent_path().c_str(),
|
||||||
false,
|
false,
|
||||||
|
@ -880,14 +877,17 @@ namespace winrt::TerminalApp::implementation
|
||||||
// editors, who will write a temp file, then rename it to be the
|
// editors, who will write a temp file, then rename it to be the
|
||||||
// actual file you wrote. So listen for that too.
|
// actual file you wrote. So listen for that too.
|
||||||
wil::FolderChangeEvents::FileName | wil::FolderChangeEvents::LastWriteTime,
|
wil::FolderChangeEvents::FileName | wil::FolderChangeEvents::LastWriteTime,
|
||||||
[=](wil::FolderChangeEvent, PCWSTR fileModified) {
|
[this, settingsPath](wil::FolderChangeEvent, PCWSTR fileModified) {
|
||||||
|
static const std::filesystem::path statePath{ std::wstring_view{ ApplicationState::SharedInstance().FilePath() } };
|
||||||
|
static const std::filesystem::path elevatedStatePath{ std::wstring_view{ ElevatedState::SharedInstance().FilePath() } };
|
||||||
|
|
||||||
const auto modifiedBasename = std::filesystem::path{ fileModified }.filename();
|
const auto modifiedBasename = std::filesystem::path{ fileModified }.filename();
|
||||||
|
|
||||||
if (modifiedBasename == settingsPath.filename())
|
if (modifiedBasename == settingsPath.filename())
|
||||||
{
|
{
|
||||||
_reloadSettings->Run();
|
_reloadSettings->Run();
|
||||||
}
|
}
|
||||||
else if (modifiedBasename == statePath.filename() /*|| modifiedBasename == elevatedStatePath.filename()*/)
|
else if (modifiedBasename == statePath.filename() || modifiedBasename == elevatedStatePath.filename())
|
||||||
{
|
{
|
||||||
_reloadState();
|
_reloadState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1313,25 +1313,21 @@ namespace winrt::TerminalApp::implementation
|
||||||
|
|
||||||
bool TerminalPage::_shouldPromptForCommandline(const winrt::hstring& cmdline) const
|
bool TerminalPage::_shouldPromptForCommandline(const winrt::hstring& cmdline) const
|
||||||
{
|
{
|
||||||
bool doAdminWarning = true;
|
|
||||||
if (_isElevated())
|
if (_isElevated())
|
||||||
{
|
{
|
||||||
bool commandlineWasAllowed = false;
|
|
||||||
|
|
||||||
if (const auto& allowedCommandlines{ ElevatedState::SharedInstance().AllowedCommandlines() })
|
if (const auto& allowedCommandlines{ ElevatedState::SharedInstance().AllowedCommandlines() })
|
||||||
{
|
{
|
||||||
for (const auto& approved : allowedCommandlines)
|
for (const auto& approved : allowedCommandlines)
|
||||||
{
|
{
|
||||||
if (approved == cmdline)
|
if (approved == cmdline)
|
||||||
{
|
{
|
||||||
commandlineWasAllowed = true;
|
return false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doAdminWarning = !commandlineWasAllowed;
|
|
||||||
}
|
}
|
||||||
return doAdminWarning;
|
|
||||||
|
return true; // TODO! Change this to false. This is defaulted to true for testing.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method Description:
|
// Method Description:
|
||||||
|
|
Loading…
Reference in a new issue