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

Side by Side Diff: content/common/sandbox_mac.h

Issue 8589001: Load mac sandbox definitions from resources instead of the bundle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_SANDBOX_MAC_H_ 5 #ifndef CONTENT_COMMON_SANDBOX_MAC_H_
6 #define CONTENT_COMMON_SANDBOX_MAC_H_ 6 #define CONTENT_COMMON_SANDBOX_MAC_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "content/public/common/sandbox_process_type_mac.h"
14 15
15 class FilePath; 16 class FilePath;
16 17
17 #if __OBJC__ 18 #if __OBJC__
18 @class NSArray; 19 @class NSArray;
19 @class NSString; 20 @class NSString;
20 #else 21 #else
21 class NSArray; 22 class NSArray;
22 class NSString; 23 class NSString;
23 #endif 24 #endif
(...skipping 26 matching lines...) Expand all
50 std::string value_; 51 std::string value_;
51 SandboxSubstringType type_; 52 SandboxSubstringType type_;
52 }; 53 };
53 54
54 class Sandbox { 55 class Sandbox {
55 public: 56 public:
56 // A map of variable name -> string to substitute in its place. 57 // A map of variable name -> string to substitute in its place.
57 typedef base::hash_map<std::string, SandboxSubstring> 58 typedef base::hash_map<std::string, SandboxSubstring>
58 SandboxVariableSubstitions; 59 SandboxVariableSubstitions;
59 60
60 enum SandboxProcessType {
61 SANDBOX_TYPE_FIRST_TYPE, // Placeholder to ease iteration.
62
63 SANDBOX_TYPE_RENDERER = SANDBOX_TYPE_FIRST_TYPE,
64
65 // The worker process uses the most restrictive sandbox which has almost
66 // *everything* locked down. Only a couple of /System/Library/ paths and
67 // some other very basic operations (e.g., reading metadata to allow
68 // following symlinks) are permitted.
69 SANDBOX_TYPE_WORKER,
70
71 // Utility process is as restrictive as the worker process except full
72 // access is allowed to one configurable directory.
73 SANDBOX_TYPE_UTILITY,
74
75 // Native Client sandbox for the user's untrusted code.
76 SANDBOX_TYPE_NACL_LOADER,
77
78 // GPU process.
79 SANDBOX_TYPE_GPU,
80
81 // The PPAPI plugin process.
82 SANDBOX_TYPE_PPAPI,
83
84 SANDBOX_AFTER_TYPE_LAST_TYPE, // Placeholder to ease iteration.
85 };
86
87 // Warm up System APIs that empirically need to be accessed before the Sandbox 61 // Warm up System APIs that empirically need to be accessed before the Sandbox
88 // is turned on. |sandbox_type| is the type of sandbox to warm up. 62 // is turned on. |sandbox_type| is the type of sandbox to warm up.
jeremy 2011/11/24 12:20:19 Could you add a reference in the comment to the en
jochen (gone - plz use gerrit) 2011/11/24 16:23:22 Done.
89 static void SandboxWarmup(SandboxProcessType sandbox_type); 63 static void SandboxWarmup(int sandbox_type);
90 64
91 // Turns on the OS X sandbox for this process. 65 // Turns on the OS X sandbox for this process.
92 // |sandbox_type| - type of Sandbox to use. 66 // |sandbox_type| - type of Sandbox to use.
93 // |allowed_dir| - directory to allow access to, currently the only sandbox 67 // |allowed_dir| - directory to allow access to, currently the only sandbox
94 // profile that supports this is SANDBOX_TYPE_UTILITY . 68 // profile that supports this is SANDBOX_PROCESS_TYPE_UTILITY .
95 // 69 //
96 // Returns true on success, false if an error occurred enabling the sandbox. 70 // Returns true on success, false if an error occurred enabling the sandbox.
97 static bool EnableSandbox(SandboxProcessType sandbox_type, 71 static bool EnableSandbox(int sandbox_type,
98 const FilePath& allowed_dir); 72 const FilePath& allowed_dir);
99 73
100 74
101 // Exposed for testing purposes, used by an accessory function of our tests 75 // Exposed for testing purposes, used by an accessory function of our tests
102 // so we can't use FRIEND_TEST. 76 // so we can't use FRIEND_TEST.
103 77
104 // Build the Sandbox command necessary to allow access to a named directory 78 // Build the Sandbox command necessary to allow access to a named directory
105 // indicated by |allowed_dir|. 79 // indicated by |allowed_dir|.
106 // Returns a string containing the sandbox profile commands necessary to allow 80 // Returns a string containing the sandbox profile commands necessary to allow
107 // access to that directory or nil if an error occured. 81 // access to that directory or nil if an error occured.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 FRIEND_TEST(MacDirAccessSandboxTest, StringEscape); 148 FRIEND_TEST(MacDirAccessSandboxTest, StringEscape);
175 FRIEND_TEST(MacDirAccessSandboxTest, RegexEscape); 149 FRIEND_TEST(MacDirAccessSandboxTest, RegexEscape);
176 FRIEND_TEST(MacDirAccessSandboxTest, DISABLED_SandboxAccess); 150 FRIEND_TEST(MacDirAccessSandboxTest, DISABLED_SandboxAccess);
177 151
178 DISALLOW_IMPLICIT_CONSTRUCTORS(Sandbox); 152 DISALLOW_IMPLICIT_CONSTRUCTORS(Sandbox);
179 }; 153 };
180 154
181 } // namespace sandbox 155 } // namespace sandbox
182 156
183 #endif // CONTENT_COMMON_SANDBOX_MAC_H_ 157 #endif // CONTENT_COMMON_SANDBOX_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698