Chromium Code Reviews| 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, | |
| 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 | |
| 34 // |substitute_port| must not be NULL. | |
| 35 struct Rule { | |
| 36 Rule(); | |
|
Mark Mentovai
2014/05/06 20:51:50
Do you need this? I don’t consider the only use be
Robert Sesek
2014/05/08 20:58:12
For STL containers, yes.
| |
| 37 explicit Rule(PolicyDecision result); | |
| 38 explicit Rule(mach_port_t override_port); | |
| 39 | |
| 40 Rule(const Rule& other); | |
| 41 void operator=(const Rule& other); | |
| 42 | |
| 43 PolicyDecision result; | |
| 44 mach_port_t substitute_port; | |
|
Mark Mentovai
2014/05/06 20:51:50
Comment on the ownership of this port, or it’s unc
Robert Sesek
2014/05/08 20:58:12
Done.
| |
| 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 |