X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fsandbox%2Fmac%2Flaunchd_interception_server.cc;h=06f10812e4f358384095ef92dbbd8c9052bc5fcd;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=c3d6eaac57928ff5c53ea44cde2a139b5e08c444;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/sandbox/mac/launchd_interception_server.cc b/src/sandbox/mac/launchd_interception_server.cc index c3d6eaa..06f1081 100644 --- a/src/sandbox/mac/launchd_interception_server.cc +++ b/src/sandbox/mac/launchd_interception_server.cc @@ -9,6 +9,7 @@ #include "base/logging.h" #include "base/mac/mach_logging.h" #include "sandbox/mac/bootstrap_sandbox.h" +#include "sandbox/mac/mach_message_server.h" namespace sandbox { @@ -51,9 +52,9 @@ bool LaunchdInterceptionServer::Initialize(mach_port_t server_receive_right) { return message_server_->Initialize(); } -void LaunchdInterceptionServer::DemuxMessage(mach_msg_header_t* request, - mach_msg_header_t* reply) { - VLOG(3) << "Incoming message #" << request->msgh_id; +void LaunchdInterceptionServer::DemuxMessage(IPCMessage request) { + const uint64_t message_id = compat_shim_.ipc_message_get_id(request); + VLOG(3) << "Incoming message #" << message_id; pid_t sender_pid = message_server_->GetMessageSenderPID(request); const BootstrapSandboxPolicy* policy = @@ -66,23 +67,22 @@ void LaunchdInterceptionServer::DemuxMessage(mach_msg_header_t* request, return; } - if (request->msgh_id == compat_shim_.msg_id_look_up2) { + if (message_id == compat_shim_.msg_id_look_up2) { // Filter messages sent via bootstrap_look_up to enforce the sandbox policy // over the bootstrap namespace. - HandleLookUp(request, reply, policy); - } else if (request->msgh_id == compat_shim_.msg_id_swap_integer) { + HandleLookUp(request, policy); + } else if (message_id == compat_shim_.msg_id_swap_integer) { // Ensure that any vproc_swap_integer requests are safe. - HandleSwapInteger(request, reply); + HandleSwapInteger(request); } else { // All other messages are not permitted. - VLOG(1) << "Rejecting unhandled message #" << request->msgh_id; - message_server_->RejectMessage(reply, MIG_REMOTE_ERROR); + VLOG(1) << "Rejecting unhandled message #" << message_id; + message_server_->RejectMessage(request, MIG_REMOTE_ERROR); } } void LaunchdInterceptionServer::HandleLookUp( - mach_msg_header_t* request, - mach_msg_header_t* reply, + IPCMessage request, const BootstrapSandboxPolicy* policy) { const std::string request_service_name( compat_shim_.look_up2_get_request_name(request)); @@ -106,7 +106,7 @@ void LaunchdInterceptionServer::HandleLookUp( // reply to the client. Returning a NULL or unserviced port for a look up // can cause clients to crash or hang. VLOG(1) << "Denying look_up2 with MIG error: " << request_service_name; - message_server_->RejectMessage(reply, BOOTSTRAP_UNKNOWN_SERVICE); + message_server_->RejectMessage(request, BOOTSTRAP_UNKNOWN_SERVICE); } else if (rule.result == POLICY_DENY_DUMMY_PORT || rule.result == POLICY_SUBSTITUTE_PORT) { // The policy result is to deny access to the real service port, replying @@ -121,6 +121,7 @@ void LaunchdInterceptionServer::HandleLookUp( else result_port = rule.substitute_port; + IPCMessage reply = message_server_->CreateReply(request); compat_shim_.look_up2_fill_reply(reply, result_port); // If the message was sent successfully, clear the result_port out of the // message so that it is not destroyed at the end of ReceiveMessage. The @@ -133,8 +134,7 @@ void LaunchdInterceptionServer::HandleLookUp( } } -void LaunchdInterceptionServer::HandleSwapInteger(mach_msg_header_t* request, - mach_msg_header_t* reply) { +void LaunchdInterceptionServer::HandleSwapInteger(IPCMessage request) { // Only allow getting information out of launchd. Do not allow setting // values. Two commonly observed values that are retrieved are // VPROC_GSK_MGR_PID and VPROC_GSK_TRANSACTIONS_ENABLED. @@ -143,10 +143,10 @@ void LaunchdInterceptionServer::HandleSwapInteger(mach_msg_header_t* request, ForwardMessage(request); } else { VLOG(2) << "Rejecting non-read-only swap_integer message."; - message_server_->RejectMessage(reply, BOOTSTRAP_NOT_PRIVILEGED); + message_server_->RejectMessage(request, BOOTSTRAP_NOT_PRIVILEGED); } } -void LaunchdInterceptionServer::ForwardMessage(mach_msg_header_t* request) { +void LaunchdInterceptionServer::ForwardMessage(IPCMessage request) { message_server_->ForwardMessage(request, sandbox_->real_bootstrap_port()); }