OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/mac/mach_message_server.h" | 5 #include "sandbox/mac/mach_message_server.h" |
6 | 6 |
7 #include <bsm/libbsm.h> | 7 #include <bsm/libbsm.h> |
8 #include <servers/bootstrap.h> | 8 #include <servers/bootstrap.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Set up the dispatch queue to service the bootstrap port. | 69 // Set up the dispatch queue to service the bootstrap port. |
70 std::string label = base::StringPrintf( | 70 std::string label = base::StringPrintf( |
71 "org.chromium.sandbox.MachMessageServer.%p", demuxer_); | 71 "org.chromium.sandbox.MachMessageServer.%p", demuxer_); |
72 dispatch_source_.reset(new base::DispatchSourceMach( | 72 dispatch_source_.reset(new base::DispatchSourceMach( |
73 label.c_str(), server_port_.get(), ^{ ReceiveMessage(); })); | 73 label.c_str(), server_port_.get(), ^{ ReceiveMessage(); })); |
74 dispatch_source_->Resume(); | 74 dispatch_source_->Resume(); |
75 | 75 |
76 return true; | 76 return true; |
77 } | 77 } |
78 | 78 |
| 79 void MachMessageServer::Shutdown() { |
| 80 dispatch_source_.reset(); |
| 81 } |
| 82 |
79 pid_t MachMessageServer::GetMessageSenderPID(IPCMessage request) { | 83 pid_t MachMessageServer::GetMessageSenderPID(IPCMessage request) { |
80 // Get the PID of the task that sent this request. This requires getting at | 84 // Get the PID of the task that sent this request. This requires getting at |
81 // the trailer of the message, from the header. | 85 // the trailer of the message, from the header. |
82 mach_msg_audit_trailer_t* trailer = | 86 mach_msg_audit_trailer_t* trailer = |
83 reinterpret_cast<mach_msg_audit_trailer_t*>( | 87 reinterpret_cast<mach_msg_audit_trailer_t*>( |
84 reinterpret_cast<vm_address_t>(request.mach) + | 88 reinterpret_cast<vm_address_t>(request.mach) + |
85 round_msg(request.mach->msgh_size)); | 89 round_msg(request.mach->msgh_size)); |
86 // TODO(rsesek): In the 10.7 SDK, there's audit_token_to_pid(). | 90 // TODO(rsesek): In the 10.7 SDK, there's audit_token_to_pid(). |
87 pid_t sender_pid; | 91 pid_t sender_pid; |
88 audit_token_to_au32(trailer->msgh_audit, | 92 audit_token_to_au32(trailer->msgh_audit, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // forwarded message was sent from the process hosting this sandbox server, | 188 // forwarded message was sent from the process hosting this sandbox server, |
185 // destroying the message could also destroy rights held outside the scope of | 189 // destroying the message could also destroy rights held outside the scope of |
186 // this message server. | 190 // this message server. |
187 if (!did_forward_message_) { | 191 if (!did_forward_message_) { |
188 mach_msg_destroy(request); | 192 mach_msg_destroy(request); |
189 mach_msg_destroy(reply); | 193 mach_msg_destroy(reply); |
190 } | 194 } |
191 } | 195 } |
192 | 196 |
193 } // namespace sandbox | 197 } // namespace sandbox |
OLD | NEW |