| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/win/security_descriptor.h" | 5 #include "remoting/host/win/security_descriptor.h" |
| 6 | 6 |
| 7 #include <sddl.h> | 7 #include <sddl.h> |
| 8 #include <stdint.h> |
| 8 | 9 |
| 9 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 | 12 |
| 12 namespace remoting { | 13 namespace remoting { |
| 13 | 14 |
| 14 ScopedSd ConvertSddlToSd(const std::string& sddl) { | 15 ScopedSd ConvertSddlToSd(const std::string& sddl) { |
| 15 PSECURITY_DESCRIPTOR raw_sd = nullptr; | 16 PSECURITY_DESCRIPTOR raw_sd = nullptr; |
| 16 ULONG length = 0; | 17 ULONG length = 0; |
| 17 if (!ConvertStringSecurityDescriptorToSecurityDescriptor( | 18 if (!ConvertStringSecurityDescriptorToSecurityDescriptor( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 43 DWORD length = 0; | 44 DWORD length = 0; |
| 44 if (GetTokenInformation(token, TokenGroups, nullptr, 0, &length) || | 45 if (GetTokenInformation(token, TokenGroups, nullptr, 0, &length) || |
| 45 GetLastError() != ERROR_INSUFFICIENT_BUFFER) { | 46 GetLastError() != ERROR_INSUFFICIENT_BUFFER) { |
| 46 return ScopedSid(); | 47 return ScopedSid(); |
| 47 } | 48 } |
| 48 | 49 |
| 49 TypedBuffer<TOKEN_GROUPS> groups(length); | 50 TypedBuffer<TOKEN_GROUPS> groups(length); |
| 50 if (!GetTokenInformation(token, TokenGroups, groups.get(), length, &length)) | 51 if (!GetTokenInformation(token, TokenGroups, groups.get(), length, &length)) |
| 51 return ScopedSid(); | 52 return ScopedSid(); |
| 52 | 53 |
| 53 for (uint32 i = 0; i < groups->GroupCount; ++i) { | 54 for (uint32_t i = 0; i < groups->GroupCount; ++i) { |
| 54 if ((groups->Groups[i].Attributes & SE_GROUP_LOGON_ID) == | 55 if ((groups->Groups[i].Attributes & SE_GROUP_LOGON_ID) == |
| 55 SE_GROUP_LOGON_ID) { | 56 SE_GROUP_LOGON_ID) { |
| 56 length = GetLengthSid(groups->Groups[i].Sid); | 57 length = GetLengthSid(groups->Groups[i].Sid); |
| 57 ScopedSid logon_sid(length); | 58 ScopedSid logon_sid(length); |
| 58 if (!CopySid(length, logon_sid.get(), groups->Groups[i].Sid)) | 59 if (!CopySid(length, logon_sid.get(), groups->Groups[i].Sid)) |
| 59 return ScopedSid(); | 60 return ScopedSid(); |
| 60 | 61 |
| 61 return logon_sid.Pass(); | 62 return logon_sid.Pass(); |
| 62 } | 63 } |
| 63 } | 64 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 117 |
| 117 absolute_sd->Swap(local_absolute_sd); | 118 absolute_sd->Swap(local_absolute_sd); |
| 118 dacl->Swap(local_dacl); | 119 dacl->Swap(local_dacl); |
| 119 group->Swap(local_group); | 120 group->Swap(local_group); |
| 120 owner->Swap(local_owner); | 121 owner->Swap(local_owner); |
| 121 sacl->Swap(local_sacl); | 122 sacl->Swap(local_sacl); |
| 122 return true; | 123 return true; |
| 123 } | 124 } |
| 124 | 125 |
| 125 } // namespace remoting | 126 } // namespace remoting |
| OLD | NEW |