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

Side by Side Diff: sandbox/mac/policy.cc

Issue 264923003: Initial implementation of the Mac Bootstrap Sandbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase for sandbox_export.h 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
« no previous file with comments | « sandbox/mac/policy.h ('k') | sandbox/mac/policy_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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_SUBSTITUTE_PORT),
21 substitute_port(override_port) {
22 }
23
24 bool IsPolicyValid(const BootstrapSandboxPolicy& policy) {
25 for (BootstrapSandboxPolicy::const_iterator it = policy.begin();
26 it != policy.end();
27 ++it) {
28 const Rule& rule = it->second;
29 if (!(rule.result > POLICY_DECISION_INVALID &&
30 rule.result < POLICY_DECISION_LAST)) {
31 return false;
32 }
33 if (rule.result == POLICY_SUBSTITUTE_PORT) {
34 if (rule.substitute_port == MACH_PORT_NULL)
35 return false;
36 } else {
37 if (rule.substitute_port != MACH_PORT_NULL)
38 return false;
39 }
40 }
41 return true;
42 }
43
44 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/mac/policy.h ('k') | sandbox/mac/policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698