diff options
Diffstat (limited to 'win/rfb_win32/Security.cxx')
-rw-r--r-- | win/rfb_win32/Security.cxx | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/win/rfb_win32/Security.cxx b/win/rfb_win32/Security.cxx index 8f000e1b..eededb6a 100644 --- a/win/rfb_win32/Security.cxx +++ b/win/rfb_win32/Security.cxx @@ -22,13 +22,15 @@ #include <config.h> #endif +#include <core/LogWriter.h> + #include <rfb_win32/Security.h> -#include <rfb/LogWriter.h> #include <lmcons.h> #include <accctrl.h> #include <list> +using namespace core; using namespace rfb; using namespace rfb::win32; @@ -99,7 +101,7 @@ PSID Sid::copySID(const PSID sid) { throw std::invalid_argument("Invalid SID in copyPSID"); PSID buf = (PSID)new uint8_t[GetLengthSid(sid)]; if (!CopySid(GetLengthSid(sid), buf, sid)) - throw rdr::win32_error("CopySid failed", GetLastError()); + throw core::win32_error("CopySid failed", GetLastError()); return buf; } @@ -108,7 +110,7 @@ void Sid::setSID(const PSID sid) { throw std::invalid_argument("Invalid SID in copyPSID"); resize(GetLengthSid(sid)); if (!CopySid(GetLengthSid(sid), data(), sid)) - throw rdr::win32_error("CopySid failed", GetLastError()); + throw core::win32_error("CopySid failed", GetLastError()); } void Sid::getUserNameAndDomain(char** name, char** domain) { @@ -117,12 +119,12 @@ void Sid::getUserNameAndDomain(char** name, char** domain) { SID_NAME_USE use; LookupAccountSid(nullptr, (PSID)*this, nullptr, &nameLen, nullptr, &domainLen, &use); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) - throw rdr::win32_error("Unable to determine SID name lengths", GetLastError()); + throw core::win32_error("Unable to determine SID name lengths", GetLastError()); vlog.info("nameLen=%lu, domainLen=%lu, use=%d", nameLen, domainLen, use); *name = new char[nameLen]; *domain = new char[domainLen]; if (!LookupAccountSid(nullptr, (PSID)*this, *name, &nameLen, *domain, &domainLen, &use)) - throw rdr::win32_error("Unable to lookup account SID", GetLastError()); + throw core::win32_error("Unable to lookup account SID", GetLastError()); } @@ -133,7 +135,7 @@ Sid::Administrators::Administrators() { SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &sid)) - throw rdr::win32_error("Sid::Administrators", GetLastError()); + throw core::win32_error("Sid::Administrators", GetLastError()); setSID(sid); FreeSid(sid); } @@ -144,7 +146,7 @@ Sid::SYSTEM::SYSTEM() { if (!AllocateAndInitializeSid(&ntAuth, 1, SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, &sid)) - throw rdr::win32_error("Sid::SYSTEM", GetLastError()); + throw core::win32_error("Sid::SYSTEM", GetLastError()); setSID(sid); FreeSid(sid); } @@ -154,7 +156,7 @@ Sid::FromToken::FromToken(HANDLE h) { GetTokenInformation(h, TokenUser, nullptr, 0, &required); std::vector<uint8_t> tmp(required); if (!GetTokenInformation(h, TokenUser, tmp.data(), tmp.size(), &required)) - throw rdr::win32_error("GetTokenInformation", GetLastError()); + throw core::win32_error("GetTokenInformation", GetLastError()); TOKEN_USER* tokenUser = (TOKEN_USER*)tmp.data(); setSID(tokenUser->User.Sid); } @@ -164,7 +166,7 @@ PACL rfb::win32::CreateACL(const AccessEntries& ae, PACL existing_acl) { PACL new_dacl; DWORD result; if ((result = SetEntriesInAcl(ae.entry_count, ae.entries, existing_acl, &new_dacl)) != ERROR_SUCCESS) - throw rdr::win32_error("SetEntriesInAcl", result); + throw core::win32_error("SetEntriesInAcl", result); return new_dacl; } @@ -172,18 +174,18 @@ PACL rfb::win32::CreateACL(const AccessEntries& ae, PACL existing_acl) { PSECURITY_DESCRIPTOR rfb::win32::CreateSdWithDacl(const PACL dacl) { SECURITY_DESCRIPTOR absSD; if (!InitializeSecurityDescriptor(&absSD, SECURITY_DESCRIPTOR_REVISION)) - throw rdr::win32_error("InitializeSecurityDescriptor", GetLastError()); + throw core::win32_error("InitializeSecurityDescriptor", GetLastError()); Sid::SYSTEM owner; if (!SetSecurityDescriptorOwner(&absSD, owner, FALSE)) - throw rdr::win32_error("SetSecurityDescriptorOwner", GetLastError()); + throw core::win32_error("SetSecurityDescriptorOwner", GetLastError()); Sid::Administrators group; if (!SetSecurityDescriptorGroup(&absSD, group, FALSE)) - throw rdr::win32_error("SetSecurityDescriptorGroupp", GetLastError()); + throw core::win32_error("SetSecurityDescriptorGroupp", GetLastError()); if (!SetSecurityDescriptorDacl(&absSD, TRUE, dacl, FALSE)) - throw rdr::win32_error("SetSecurityDescriptorDacl", GetLastError()); + throw core::win32_error("SetSecurityDescriptorDacl", GetLastError()); DWORD sdSize = GetSecurityDescriptorLength(&absSD); SecurityDescriptorPtr sd(sdSize); if (!MakeSelfRelativeSD(&absSD, (PSECURITY_DESCRIPTOR)sd.ptr, &sdSize)) - throw rdr::win32_error("MakeSelfRelativeSD", GetLastError()); + throw core::win32_error("MakeSelfRelativeSD", GetLastError()); return sd.takeSD(); } |