OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ipc/ipc_channel_win.h" | 5 #include "ipc/ipc_channel_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <sddl.h> | 8 #include <sddl.h> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/win/scoped_handle.h" |
16 #include "ipc/ipc_logging.h" | 17 #include "ipc/ipc_logging.h" |
17 #include "ipc/ipc_message_utils.h" | 18 #include "ipc/ipc_message_utils.h" |
18 | 19 |
19 namespace IPC { | 20 namespace IPC { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Creates a security descriptor with a DACL that has one ace giving full | 24 // Creates a security descriptor with a DACL that has one ace giving full |
24 // access to the current logon session. | 25 // access to the current logon session. |
25 // The security descriptor returned must be freed using LocalFree. | 26 // The security descriptor returned must be freed using LocalFree. |
26 // The function returns true if it succeeds, false otherwise. | 27 // The function returns true if it succeeds, false otherwise. |
27 bool GetLogonSessionOnlyDACL(SECURITY_DESCRIPTOR** security_descriptor) { | 28 bool GetLogonSessionOnlyDACL(SECURITY_DESCRIPTOR** security_descriptor) { |
28 // Get the current token. | 29 // Get the current token. |
29 HANDLE token = NULL; | 30 HANDLE token = NULL; |
30 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) | 31 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) |
31 return false; | 32 return false; |
32 ScopedHandle token_scoped(token); | 33 base::win::ScopedHandle token_scoped(token); |
33 | 34 |
34 // Get the size of the TokenGroups structure. | 35 // Get the size of the TokenGroups structure. |
35 DWORD size = 0; | 36 DWORD size = 0; |
36 BOOL result = GetTokenInformation(token, TokenGroups, NULL, 0, &size); | 37 BOOL result = GetTokenInformation(token, TokenGroups, NULL, 0, &size); |
37 if (result != FALSE && GetLastError() != ERROR_INSUFFICIENT_BUFFER) | 38 if (result != FALSE && GetLastError() != ERROR_INSUFFICIENT_BUFFER) |
38 return false; | 39 return false; |
39 | 40 |
40 // Get the data. | 41 // Get the data. |
41 scoped_array<char> token_groups_chars(new char[size]); | 42 scoped_array<char> token_groups_chars(new char[size]); |
42 TOKEN_GROUPS* token_groups = | 43 TOKEN_GROUPS* token_groups = |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 504 |
504 void Channel::set_listener(Listener* listener) { | 505 void Channel::set_listener(Listener* listener) { |
505 channel_impl_->set_listener(listener); | 506 channel_impl_->set_listener(listener); |
506 } | 507 } |
507 | 508 |
508 bool Channel::Send(Message* message) { | 509 bool Channel::Send(Message* message) { |
509 return channel_impl_->Send(message); | 510 return channel_impl_->Send(message); |
510 } | 511 } |
511 | 512 |
512 } // namespace IPC | 513 } // namespace IPC |
OLD | NEW |