Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: sandbox/mac/launchd_interception_server.h

Issue 264923003: Initial implementation of the Mac Bootstrap Sandbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_
6 #define SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_
7
8 #include <dispatch/dispatch.h>
9 #include <mach/mach.h>
10
11 #include "base/mac/scoped_mach_port.h"
12 #include "sandbox/mac/os_compatibility.h"
13
14 namespace sandbox {
15
16 class BootstrapSandbox;
17
18 // This class is used to run a Mach IPC message server. This server can
19 // hold the receive right for a bootstrap_port of a process, and it filters
20 // a subset of the launchd/bootstrap IPC call set for sandboxing. It permits
21 // or rejects requests based on the per-process policy specified in the
22 // BootstrapSandbox.
23 class LaunchdInterceptionServer {
24 public:
25 LaunchdInterceptionServer(const BootstrapSandbox* sandbox);
Mark Mentovai 2014/05/06 20:51:50 explicit
Robert Sesek 2014/05/08 20:58:12 Done.
26 ~LaunchdInterceptionServer();
27
28 // Initializes the class and starts running the message server.
29 bool Initialize();
Mark Mentovai 2014/05/06 20:51:50 Yeah, see, here you used Initialize instead of hav
Robert Sesek 2014/05/08 20:58:12 Yes, because this class is only instantiated by th
30
31 mach_port_t server_port() const { return server_port_.get(); }
32
33 private:
34 // Event handler for the |server_source_| that reads a message from the queue
35 // and processes it.
36 void ReceiveMessage();
37
38 // Decodes a message header and handles it by either servicing the request
39 // itself, forwarding the message on to the real launchd, or rejecting the
40 // message with an error.
41 void DemuxMessage(mach_msg_header_t* request, mach_msg_header_t* reply);
42
43 // Given a look_up2 request message, this looks up the appropriate sandbox
44 // policy for the service name then formulates and sends the reply message.
45 void HandleLookUp(mach_msg_header_t* request_header,
46 mach_msg_header_t* reply_header,
47 pid_t sender_pid);
48
49 // Sends a reply message.
50 void SendReply(mach_msg_header_t* reply);
51
52 // Forwards the original |request| on to real bootstrap server for handling.
53 void ForwardMessage(mach_msg_header_t* request, mach_msg_header_t* reply);
54
55 // Replies to the message with the specified |error_code| as a MIG
56 // error_reply RetCode.
57 void RejectMessage(mach_msg_header_t* request,
58 mach_msg_header_t* reply,
59 int error_code);
60
61 // The sandbox for which this message server is running.
62 const BootstrapSandbox* sandbox_;
63
64 // The Mach port on which the server is receiving requests.
65 base::mac::ScopedMachPort server_port_;
66
67 // The dispatch queue used to service the server_source_.
68 dispatch_queue_t server_queue_;
69
70 // A MACH_RECV dispatch source for the server_port_.
71 dispatch_source_t server_source_;
72
73 // The Mach port handed out in reply to denied look up requests. All denied
74 // requests share the same port, though nothing reads messages from it.
75 base::mac::ScopedMachPort sandbox_port_;
76
77 // The compatiblity shim that handles differences in message header IDs and
78 // request/reply structures between different OS X versions.
79 const LaunchdCompatibilityShim compat_shim_;
80 };
81
82 } // namespace sandbox
83
84 #endif // SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698