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 #include "sandbox/mac/policy.h" | |
6 | |
7 namespace sandbox { | |
8 | |
9 Rule::Rule() | |
10 : result(POLICY_DECISION_INVALID), | |
11 substitute_port(MACH_PORT_NULL) { | |
12 } | |
13 | |
14 Rule::Rule(PolicyDecision result) | |
15 : result(result), | |
16 substitute_port(MACH_PORT_NULL) { | |
17 } | |
18 | |
19 Rule::Rule(mach_port_t override_port) | |
20 : result(POLICY_SUBSTITUE_PORT), | |
21 substitute_port(override_port) { | |
22 } | |
23 | |
24 Rule::Rule(const Rule& other) { | |
25 *this = other; | |
26 } | |
27 | |
28 void Rule::operator=(const Rule& other) { | |
29 result = other.result; | |
Mark Mentovai
2014/05/06 20:51:50
Did the “*this = other” form work in the construct
Robert Sesek
2014/05/08 20:58:12
Actually removed both because this is a struct.
| |
30 substitute_port = other.substitute_port; | |
31 } | |
32 | |
33 bool IsPolicyValid(const BootstrapSandboxPolicy& policy) { | |
34 for (BootstrapSandboxPolicy::const_iterator it = policy.begin(); | |
35 it != policy.end(); | |
36 ++it) { | |
37 const Rule& rule = it->second; | |
38 if (!(rule.result > POLICY_DECISION_INVALID && | |
39 rule.result < POLICY_DECISION_LAST)) { | |
40 return false; | |
41 } | |
42 if (rule.result == POLICY_SUBSTITUE_PORT) { | |
43 if (rule.substitute_port == MACH_PORT_NULL) | |
44 return false; | |
45 } else { | |
46 if (rule.substitute_port != MACH_PORT_NULL) | |
47 return false; | |
48 } | |
49 } | |
50 return true; | |
51 } | |
52 | |
53 } // namespace sandbox | |
OLD | NEW |