| 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 "sandbox/win/src/acl.h" | 5 #include "sandbox/win/src/acl.h" |
| 6 | 6 |
| 7 #include <aclapi.h> | 7 #include <aclapi.h> |
| 8 #include <sddl.h> | 8 #include <sddl.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 ::LocalFree(new_dacl); | 81 ::LocalFree(new_dacl); |
| 82 return (TRUE == ret); | 82 return (TRUE == ret); |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool RevokeLogonSidFromDefaultDacl(HANDLE token) { | 85 bool RevokeLogonSidFromDefaultDacl(HANDLE token) { |
| 86 DWORD size = sizeof(TOKEN_GROUPS) + SECURITY_MAX_SID_SIZE; | 86 DWORD size = sizeof(TOKEN_GROUPS) + SECURITY_MAX_SID_SIZE; |
| 87 TOKEN_GROUPS* logon_sid = reinterpret_cast<TOKEN_GROUPS*>(malloc(size)); | 87 TOKEN_GROUPS* logon_sid = reinterpret_cast<TOKEN_GROUPS*>(malloc(size)); |
| 88 | 88 |
| 89 std::unique_ptr<TOKEN_GROUPS, base::FreeDeleter> logon_sid_ptr(logon_sid); | 89 std::unique_ptr<TOKEN_GROUPS, base::FreeDeleter> logon_sid_ptr(logon_sid); |
| 90 | 90 |
| 91 if (!::GetTokenInformation(token, TokenLogonSid, logon_sid, size, &size)) | 91 if (!::GetTokenInformation(token, TokenLogonSid, logon_sid, size, &size)) { |
| 92 // If no logon sid, there's nothing to revoke. |
| 93 if (::GetLastError() == ERROR_NOT_FOUND) |
| 94 return true; |
| 92 return false; | 95 return false; |
| 96 } |
| 93 if (logon_sid->GroupCount < 1) { | 97 if (logon_sid->GroupCount < 1) { |
| 94 ::SetLastError(ERROR_INVALID_TOKEN); | 98 ::SetLastError(ERROR_INVALID_TOKEN); |
| 95 return false; | 99 return false; |
| 96 } | 100 } |
| 97 return AddSidToDefaultDacl(token, | 101 return AddSidToDefaultDacl(token, |
| 98 reinterpret_cast<SID*>(logon_sid->Groups[0].Sid), | 102 reinterpret_cast<SID*>(logon_sid->Groups[0].Sid), |
| 99 REVOKE_ACCESS, 0); | 103 REVOKE_ACCESS, 0); |
| 100 } | 104 } |
| 101 | 105 |
| 102 bool AddUserSidToDefaultDacl(HANDLE token, ACCESS_MASK access) { | 106 bool AddUserSidToDefaultDacl(HANDLE token, ACCESS_MASK access) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 ::LocalFree(new_dacl); | 141 ::LocalFree(new_dacl); |
| 138 ::LocalFree(descriptor); | 142 ::LocalFree(descriptor); |
| 139 | 143 |
| 140 if (ERROR_SUCCESS != result) | 144 if (ERROR_SUCCESS != result) |
| 141 return false; | 145 return false; |
| 142 | 146 |
| 143 return true; | 147 return true; |
| 144 } | 148 } |
| 145 | 149 |
| 146 } // namespace sandbox | 150 } // namespace sandbox |
| OLD | NEW |