Bug 1297794 - Fix SetEntriesInAcl failure on non-English Windows version. r=aklotz, a=ritu
authorKacper Michajlow <kasper93@gmail.com>
Wed, 24 Aug 2016 20:57:16 +0200
changeset 350193 696a981b6d534a7015d6f2ba3d2379af620e9b26
parent 350192 fd095a122f65c56fd1198468adbf280e59c6cfa7
child 350194 79429ecdadfa79a101cff2add3d5c1eac5b07e7f
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz, ritu
bugs1297794
milestone50.0a2
Bug 1297794 - Fix SetEntriesInAcl failure on non-English Windows version. r=aklotz, a=ritu MozReview-Commit-ID: 4FJBtUBjPEu
ipc/mscom/MainThreadRuntime.cpp
--- a/ipc/mscom/MainThreadRuntime.cpp
+++ b/ipc/mscom/MainThreadRuntime.cpp
@@ -116,24 +116,38 @@ MainThreadRuntime::InitializeSecurity()
     return HRESULT_FROM_WIN32(::GetLastError());
   }
 
   SECURITY_DESCRIPTOR sd;
   if (!::InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) {
     return HRESULT_FROM_WIN32(::GetLastError());
   }
 
+  BYTE systemSid[SECURITY_MAX_SID_SIZE];
+  DWORD systemSidSize = sizeof(systemSid);
+  if (!::CreateWellKnownSid(WinLocalSystemSid, nullptr, systemSid,
+                            &systemSidSize)) {
+    return HRESULT_FROM_WIN32(::GetLastError());
+  }
+
+  BYTE adminSid[SECURITY_MAX_SID_SIZE];
+  DWORD adminSidSize = sizeof(adminSid);
+  if (!::CreateWellKnownSid(WinBuiltinAdministratorsSid, nullptr, adminSid,
+                            &adminSidSize)) {
+    return HRESULT_FROM_WIN32(::GetLastError());
+  }
+
   // Grant access to SYSTEM, Administrators, and the user.
   EXPLICIT_ACCESS entries[] = {
     {COM_RIGHTS_EXECUTE, GRANT_ACCESS, NO_INHERITANCE,
-      {nullptr, NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_NAME, TRUSTEE_IS_USER,
-       L"SYSTEM"}},
+      {nullptr, NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_SID, TRUSTEE_IS_USER,
+       reinterpret_cast<LPWSTR>(systemSid)}},
     {COM_RIGHTS_EXECUTE, GRANT_ACCESS, NO_INHERITANCE,
-      {nullptr, NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_NAME, TRUSTEE_IS_WELL_KNOWN_GROUP,
-       L"ADMINISTRATORS"}},
+      {nullptr, NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_SID, TRUSTEE_IS_WELL_KNOWN_GROUP,
+       reinterpret_cast<LPWSTR>(adminSid)}},
     {COM_RIGHTS_EXECUTE, GRANT_ACCESS, NO_INHERITANCE,
       {nullptr, NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_SID, TRUSTEE_IS_USER,
        reinterpret_cast<LPWSTR>(tokenUser.User.Sid)}}
   };
 
   PACL rawDacl = nullptr;
   win32Error = ::SetEntriesInAcl(ArrayLength(entries), entries, nullptr,
                                  &rawDacl);