Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sandbox/win/src/sid.h" | 5 #include "sandbox/win/src/sid.h" |
| 6 | 6 |
| 7 #include <objbase.h> | |
|
rvargas (doing something else)
2015/02/24 01:01:49
?
| |
| 8 #include <sddl.h> | |
| 9 | |
| 7 #include "base/logging.h" | 10 #include "base/logging.h" |
| 8 | 11 |
| 9 namespace sandbox { | 12 namespace sandbox { |
| 10 | 13 |
| 11 Sid::Sid(const SID *sid) { | 14 Sid::Sid(const SID *sid) { |
| 12 ::CopySid(SECURITY_MAX_SID_SIZE, sid_, const_cast<SID*>(sid)); | 15 BOOL result = ::CopySid(SECURITY_MAX_SID_SIZE, sid_, const_cast<SID*>(sid)); |
| 16 DCHECK(result); | |
| 13 }; | 17 }; |
| 14 | 18 |
| 15 Sid::Sid(WELL_KNOWN_SID_TYPE type) { | 19 Sid::Sid(WELL_KNOWN_SID_TYPE type) { |
| 16 DWORD size_sid = SECURITY_MAX_SID_SIZE; | 20 DWORD size_sid = SECURITY_MAX_SID_SIZE; |
| 17 BOOL result = ::CreateWellKnownSid(type, NULL, sid_, &size_sid); | 21 BOOL result = ::CreateWellKnownSid(type, NULL, sid_, &size_sid); |
| 18 DCHECK(result); | 22 DCHECK(result); |
| 19 DBG_UNREFERENCED_LOCAL_VARIABLE(result); | 23 DBG_UNREFERENCED_LOCAL_VARIABLE(result); |
| 20 } | 24 } |
| 21 | 25 |
| 22 const SID *Sid::GetPSID() const { | 26 const SID *Sid::GetPSID() const { |
| 23 return reinterpret_cast<SID*>(const_cast<BYTE*>(sid_)); | 27 return reinterpret_cast<SID*>(const_cast<BYTE*>(sid_)); |
| 24 } | 28 } |
| 25 | 29 |
| 30 std::wstring Sid::GenerateUniqueSubAuthoritySid() { | |
|
rvargas (doing something else)
2015/02/24 01:01:49
I don't think this code belongs here
| |
| 31 SID_IDENTIFIER_AUTHORITY authority = SECURITY_APP_PACKAGE_AUTHORITY; | |
| 32 GUID guid = { 0 }; | |
| 33 ::CoCreateGuid(&guid); | |
| 34 unsigned long* guid_long = reinterpret_cast<unsigned long*>(&guid); | |
| 35 PSID sid = NULL; | |
| 36 DWORD sub_auth = *GetSidSubAuthority(reinterpret_cast<SID*>(sid_), 0); | |
| 37 ::AllocateAndInitializeSid(&authority, | |
| 38 8, | |
| 39 sub_auth, | |
| 40 guid_long[0], | |
| 41 guid_long[1], | |
| 42 guid_long[2], | |
| 43 guid_long[3], | |
| 44 1, | |
| 45 1, | |
| 46 1, | |
| 47 &sid); | |
| 48 LPWSTR sid_string = NULL; | |
| 49 ::ConvertSidToStringSid(sid, &sid_string); | |
| 50 std::wstring unique_sid = sid_string; | |
| 51 ::FreeSid(sid); | |
| 52 ::LocalFree(sid_string); | |
| 53 return unique_sid; | |
| 54 } | |
| 55 | |
| 26 } // namespace sandbox | 56 } // namespace sandbox |
| OLD | NEW |