[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 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 | // This file is used to handle differences in Mach message IDs and structures | ||||
6 | // that occur between different OS versions. The Mach messages that the sandbox | ||||
7 | // is interested in are decoded using information derived from the open-source | ||||
8 | // libraries, i.e. <http://www.opensource.apple.com/source/launchd/>. While | ||||
9 | // these messages definitions are open source, they are not considered part of | ||||
10 | // the stable OS API, and so differences do exist between OS versions. | ||||
11 | |||||
12 | #ifndef SANDBOX_MAC_OS_COMPATIBILITY_H_ | ||||
13 | #define SANDBOX_MAC_OS_COMPATIBILITY_H_ | ||||
14 | |||||
15 | #include <mach/mach.h> | ||||
avi | 74a1875f | 2015-12-22 02:10:03 | [diff] [blame] | 16 | #include <stdint.h> |
[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 17 | |
mostynb | d521b63 | 2016-04-06 13:22:08 | [diff] [blame] | 18 | #include <memory> |
[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 19 | #include <string> |
20 | |||||
[email protected] | 168bdd4a | 2014-07-01 00:06:11 | [diff] [blame] | 21 | #include "sandbox/mac/message_server.h" |
22 | |||||
[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 23 | namespace sandbox { |
24 | |||||
rsesek | 05baf19 | 2015-07-22 16:13:44 | [diff] [blame] | 25 | class OSCompatibility { |
26 | public: | ||||
27 | // Creates an OSCompatibility instance for the current OS X version. | ||||
mostynb | d521b63 | 2016-04-06 13:22:08 | [diff] [blame] | 28 | static std::unique_ptr<OSCompatibility> CreateForPlatform(); |
[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 29 | |
rsesek | 05baf19 | 2015-07-22 16:13:44 | [diff] [blame] | 30 | virtual ~OSCompatibility(); |
[email protected] | 168bdd4a | 2014-07-01 00:06:11 | [diff] [blame] | 31 | |
rsesek | 7d60b3f | 2015-07-17 14:40:04 | [diff] [blame] | 32 | // Gets the message and subsystem ID of an IPC message. |
rsesek | 05baf19 | 2015-07-22 16:13:44 | [diff] [blame] | 33 | virtual uint64_t GetMessageSubsystem(const IPCMessage message) = 0; |
34 | virtual uint64_t GetMessageID(const IPCMessage message) = 0; | ||||
[email protected] | 168bdd4a | 2014-07-01 00:06:11 | [diff] [blame] | 35 | |
rsesek | 7d60b3f | 2015-07-17 14:40:04 | [diff] [blame] | 36 | // Returns true if the message is a Launchd look up request. |
rsesek | 05baf19 | 2015-07-22 16:13:44 | [diff] [blame] | 37 | virtual bool IsServiceLookUpRequest(const IPCMessage message) = 0; |
[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 38 | |
rsesek | 7d60b3f | 2015-07-17 14:40:04 | [diff] [blame] | 39 | // Returns true if the message is a Launchd vproc swap_integer request. |
rsesek | 05baf19 | 2015-07-22 16:13:44 | [diff] [blame] | 40 | virtual bool IsVprocSwapInteger(const IPCMessage message) = 0; |
rsesek | 7d60b3f | 2015-07-17 14:40:04 | [diff] [blame] | 41 | |
42 | // Returns true if the message is an XPC domain management message. | ||||
rsesek | 05baf19 | 2015-07-22 16:13:44 | [diff] [blame] | 43 | virtual bool IsXPCDomainManagement(const IPCMessage message) = 0; |
[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 44 | |
45 | // A function to take a look_up2 message and return the string service name | ||||
46 | // that was requested via the message. | ||||
rsesek | 05baf19 | 2015-07-22 16:13:44 | [diff] [blame] | 47 | virtual std::string GetServiceLookupName(const IPCMessage message) = 0; |
[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 48 | |
49 | // A function to formulate a reply to a look_up2 message, given the reply | ||||
50 | // message and the port to return as the service. | ||||
rsesek | 05baf19 | 2015-07-22 16:13:44 | [diff] [blame] | 51 | virtual void WriteServiceLookUpReply(IPCMessage reply, |
52 | mach_port_t service_port) = 0; | ||||
[email protected] | 795989f2 | 2014-05-16 02:05:42 | [diff] [blame] | 53 | |
54 | // A function to take a swap_integer message and return true if the message | ||||
55 | // is only getting the value of a key, neither setting it directly, nor | ||||
56 | // swapping two keys. | ||||
rsesek | 05baf19 | 2015-07-22 16:13:44 | [diff] [blame] | 57 | virtual bool IsSwapIntegerReadOnly(const IPCMessage message) = 0; |
[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 58 | }; |
59 | |||||
[email protected] | 7573951 | 2014-05-13 00:40:58 | [diff] [blame] | 60 | } // namespace sandbox |
61 | |||||
62 | #endif // SANDBOX_MAC_OS_COMPATIBILITY_H_ |