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/xpc_message_server.h" | 5 #include "sandbox/mac/xpc_message_server.h" |
6 | 6 |
7 #include <bsm/libbsm.h> | 7 #include <bsm/libbsm.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 std::string label = base::StringPrintf( | 42 std::string label = base::StringPrintf( |
43 "org.chromium.sandbox.XPCMessageServer.%p", demuxer_); | 43 "org.chromium.sandbox.XPCMessageServer.%p", demuxer_); |
44 dispatch_source_.reset(new base::DispatchSourceMach( | 44 dispatch_source_.reset(new base::DispatchSourceMach( |
45 label.c_str(), server_port_.get(), ^{ ReceiveMessage(); })); | 45 label.c_str(), server_port_.get(), ^{ ReceiveMessage(); })); |
46 dispatch_source_->Resume(); | 46 dispatch_source_->Resume(); |
47 | 47 |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
| 51 void XPCMessageServer::Shutdown() { |
| 52 dispatch_source_.reset(); |
| 53 } |
| 54 |
51 pid_t XPCMessageServer::GetMessageSenderPID(IPCMessage request) { | 55 pid_t XPCMessageServer::GetMessageSenderPID(IPCMessage request) { |
52 audit_token_t token; | 56 audit_token_t token; |
53 xpc_dictionary_get_audit_token(request.xpc, &token); | 57 xpc_dictionary_get_audit_token(request.xpc, &token); |
54 // TODO(rsesek): In the 10.7 SDK, there's audit_token_to_pid(). | 58 // TODO(rsesek): In the 10.7 SDK, there's audit_token_to_pid(). |
55 pid_t sender_pid; | 59 pid_t sender_pid; |
56 audit_token_to_au32(token, | 60 audit_token_to_au32(token, |
57 NULL, NULL, NULL, NULL, NULL, &sender_pid, NULL, NULL); | 61 NULL, NULL, NULL, NULL, NULL, &sender_pid, NULL, NULL); |
58 return sender_pid; | 62 return sender_pid; |
59 } | 63 } |
60 | 64 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 demuxer_->DemuxMessage(request); | 117 demuxer_->DemuxMessage(request); |
114 | 118 |
115 xpc_release(request.xpc); | 119 xpc_release(request.xpc); |
116 if (reply_message_) { | 120 if (reply_message_) { |
117 xpc_release(reply_message_); | 121 xpc_release(reply_message_); |
118 reply_message_ = NULL; | 122 reply_message_ = NULL; |
119 } | 123 } |
120 } | 124 } |
121 | 125 |
122 } // namespace sandbox | 126 } // namespace sandbox |
OLD | NEW |