OLD | NEW |
---|---|
(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_POLICY_H_ | |
6 #define SANDBOX_MAC_POLICY_H_ | |
7 | |
8 #include <mach/mach.h> | |
9 | |
10 #include <map> | |
11 #include <string> | |
12 | |
13 namespace sandbox { | |
14 | |
15 enum PolicyDecision { | |
16 POLICY_DECISION_INVALID, | |
17 // Explicitly allows the real service to be looked up from launchd. | |
18 POLICY_ALLOW, | |
19 // Deny the look up request by replying with a MIG error. This is the | |
20 // default behavior for servers not given an explicit rule. | |
21 POLICY_DENY_ERROR, | |
22 // Deny the look up request with a well-formed reply containing a | |
23 // Mach port with a send right, messages to which will be ignored. | |
24 POLICY_DENY_DUMMY_PORT, | |
25 // Reply to the look up request with a send right to the substitute_port | |
26 // specified in the Rule. | |
27 POLICY_SUBSTITUE_PORT, | |
Avi (use Gerrit)
2014/05/09 21:02:06
typo: SUBSTITUTE
Robert Sesek
2014/05/09 22:04:03
Ooof. Done.
| |
28 POLICY_DECISION_LAST, | |
29 }; | |
30 | |
31 // A Rule expresses the action to take when a service port is requested via | |
32 // bootstrap_look_up. If |result| is not POLICY_SUBSTITUE_PORT, then | |
33 // |substitute_port| must be NULL. If result is POLICY_SUBSTITUE_PORT, then | |
Avi (use Gerrit)
2014/05/09 21:02:06
Fix the constant names on this line and the line a
Robert Sesek
2014/05/09 22:04:03
Done.
| |
34 // |substitute_port| must not be NULL. | |
35 struct Rule { | |
36 Rule(); | |
37 explicit Rule(PolicyDecision result); | |
38 explicit Rule(mach_port_t override_port); | |
39 | |
40 PolicyDecision result; | |
41 | |
42 // The Rule does not take ownership of this port, but additional send rights | |
43 // will be allocated to it before it is sent to a client. | |
44 mach_port_t substitute_port; | |
45 }; | |
46 | |
47 // A SandboxPolicy maps bootstrap server names to policy Rules. | |
48 typedef std::map<std::string, Rule> BootstrapSandboxPolicy; | |
49 | |
50 // Checks that a policy is well-formed. | |
51 bool IsPolicyValid(const BootstrapSandboxPolicy& policy); | |
52 | |
53 } // namespace sandbox | |
54 | |
55 #endif // SANDBOX_MAC_POLICY_H_ | |
OLD | NEW |