this worked, nice
This commit is contained in:
parent
880222dc1b
commit
5197dc4e50
|
@ -10,8 +10,6 @@ Abstract:
|
||||||
--*/
|
--*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|
||||||
// {
|
|
||||||
struct BaseApplicationState
|
struct BaseApplicationState
|
||||||
{
|
{
|
||||||
BaseApplicationState(std::filesystem::path path) noexcept;
|
BaseApplicationState(std::filesystem::path path) noexcept;
|
||||||
|
@ -33,4 +31,3 @@ protected:
|
||||||
std::filesystem::path _path;
|
std::filesystem::path _path;
|
||||||
til::throttled_func_trailing<> _throttler;
|
til::throttled_func_trailing<> _throttler;
|
||||||
};
|
};
|
||||||
// }
|
|
||||||
|
|
|
@ -107,42 +107,7 @@ namespace Microsoft::Terminal::Settings::Model
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void _setupAttributes(SECURITY_ATTRIBUTES& sa)
|
|
||||||
{
|
|
||||||
PSID pEveryoneSID = NULL;
|
|
||||||
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_NT_AUTHORITY;
|
|
||||||
BOOL success = AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID);
|
|
||||||
|
|
||||||
EXPLICIT_ACCESS ea[1];
|
|
||||||
ZeroMemory(&ea, 1 * sizeof(EXPLICIT_ACCESS));
|
|
||||||
ea[0].grfAccessPermissions = KEY_READ;
|
|
||||||
ea[0].grfAccessMode = SET_ACCESS;
|
|
||||||
ea[0].grfInheritance = NO_INHERITANCE;
|
|
||||||
ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
|
||||||
ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
|
|
||||||
ea[0].Trustee.ptstrName = (LPTSTR)pEveryoneSID;
|
|
||||||
|
|
||||||
ACL acl;
|
|
||||||
PACL pAcl = &acl;
|
|
||||||
DWORD dwRes = SetEntriesInAcl(1, ea, NULL, &pAcl);
|
|
||||||
dwRes;
|
|
||||||
|
|
||||||
SECURITY_DESCRIPTOR sd;
|
|
||||||
success = InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
|
|
||||||
success = SetSecurityDescriptorDacl(&sd,
|
|
||||||
TRUE, // bDaclPresent flag
|
|
||||||
pAcl,
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
// Initialize a security attributes structure.
|
|
||||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
|
||||||
sa.lpSecurityDescriptor = &sd;
|
|
||||||
sa.bInheritHandle = FALSE;
|
|
||||||
success;
|
|
||||||
// return sa;
|
|
||||||
// wil::unique_hfile file{ CreateFileW(testPath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr) };
|
|
||||||
// THROW_LAST_ERROR_IF(!file);
|
|
||||||
}
|
|
||||||
void WriteUTF8File(const std::filesystem::path& path,
|
void WriteUTF8File(const std::filesystem::path& path,
|
||||||
const std::string_view content,
|
const std::string_view content,
|
||||||
const bool elevatedOnly)
|
const bool elevatedOnly)
|
||||||
|
@ -152,22 +117,34 @@ namespace Microsoft::Terminal::Settings::Model
|
||||||
{
|
{
|
||||||
// sa = _setupAttributes();
|
// sa = _setupAttributes();
|
||||||
|
|
||||||
PSID pEveryoneSID = NULL;
|
PSID pSytemSid = NULL;
|
||||||
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_NT_AUTHORITY;
|
PSID pEveryoneSid = NULL;
|
||||||
BOOL success = AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID);
|
SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY;
|
||||||
|
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
|
||||||
|
BOOL success = AllocateAndInitializeSid(&SIDAuthNT, 1, SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, &pSytemSid);
|
||||||
|
THROW_LAST_ERROR_IF(!success);
|
||||||
|
success = AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSid);
|
||||||
|
THROW_LAST_ERROR_IF(!success);
|
||||||
|
|
||||||
EXPLICIT_ACCESS ea[1];
|
EXPLICIT_ACCESS ea[2];
|
||||||
ZeroMemory(&ea, 1 * sizeof(EXPLICIT_ACCESS));
|
ZeroMemory(&ea, 2 * sizeof(EXPLICIT_ACCESS));
|
||||||
ea[0].grfAccessPermissions = KEY_READ;
|
ea[0].grfAccessPermissions = GENERIC_ALL;
|
||||||
ea[0].grfAccessMode = SET_ACCESS;
|
ea[0].grfAccessMode = SET_ACCESS;
|
||||||
ea[0].grfInheritance = NO_INHERITANCE;
|
ea[0].grfInheritance = NO_INHERITANCE;
|
||||||
ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
||||||
ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
|
ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
|
||||||
ea[0].Trustee.ptstrName = (LPTSTR)pEveryoneSID;
|
ea[0].Trustee.ptstrName = (LPTSTR)pSytemSid;
|
||||||
|
|
||||||
|
ea[1].grfAccessPermissions = GENERIC_READ;
|
||||||
|
ea[1].grfAccessMode = SET_ACCESS;
|
||||||
|
ea[1].grfInheritance = NO_INHERITANCE;
|
||||||
|
ea[1].Trustee.TrusteeForm = TRUSTEE_IS_SID;
|
||||||
|
ea[1].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
|
||||||
|
ea[1].Trustee.ptstrName = (LPTSTR)pEveryoneSid;
|
||||||
|
|
||||||
ACL acl;
|
ACL acl;
|
||||||
PACL pAcl = &acl;
|
PACL pAcl = &acl;
|
||||||
DWORD dwRes = SetEntriesInAcl(1, ea, NULL, &pAcl);
|
DWORD dwRes = SetEntriesInAcl(2, ea, NULL, &pAcl);
|
||||||
dwRes;
|
dwRes;
|
||||||
|
|
||||||
SECURITY_DESCRIPTOR sd;
|
SECURITY_DESCRIPTOR sd;
|
||||||
|
|
Loading…
Reference in a new issue