| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/common/sandbox_mac.h" | 5 #include "chrome/common/sandbox_mac.h" |
| 6 | 6 |
| 7 #include "base/debug_util.h" | 7 #include "base/debug_util.h" |
| 8 | 8 |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 extern "C" { | 10 extern "C" { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 { // Native Client access to /dev/random. | 239 { // Native Client access to /dev/random. |
| 240 GetUrandomFD(); | 240 GetUrandomFD(); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 // Turns on the OS X sandbox for this process. | 244 // Turns on the OS X sandbox for this process. |
| 245 bool EnableSandbox(SandboxProcessType sandbox_type, | 245 bool EnableSandbox(SandboxProcessType sandbox_type, |
| 246 const FilePath& allowed_dir) { | 246 const FilePath& allowed_dir) { |
| 247 // Name of the file containing a common prefix included at the start of | 247 // Name of the file containing a common prefix included at the start of |
| 248 // all the other sandbox profiles. | 248 // all the other sandbox profiles. |
| 249 const NSString* kCommonSandboxPrefixFileName = @"common"; | 249 NSString* kCommonSandboxPrefixFileName = @"common"; |
| 250 | 250 |
| 251 // Sanity - currently only SANDBOX_TYPE_UTILITY supports a directory being | 251 // Sanity - currently only SANDBOX_TYPE_UTILITY supports a directory being |
| 252 // passed in. | 252 // passed in. |
| 253 if (sandbox_type != SANDBOX_TYPE_UTILITY) { | 253 if (sandbox_type != SANDBOX_TYPE_UTILITY) { |
| 254 DCHECK(allowed_dir.empty()) | 254 DCHECK(allowed_dir.empty()) |
| 255 << "Only SANDBOX_TYPE_UTILITY allows a custom directory parameter."; | 255 << "Only SANDBOX_TYPE_UTILITY allows a custom directory parameter."; |
| 256 } | 256 } |
| 257 // We use a custom sandbox definition file to lock things down as | 257 // We use a custom sandbox definition file to lock things down as |
| 258 // tightly as possible. | 258 // tightly as possible. |
| 259 // TODO(jeremy): Look at using include syntax to unify common parts of sandbox | 259 // TODO(jeremy): Look at using include syntax to unify common parts of sandbox |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 bool success = (error == 0 && error_buff == NULL); | 409 bool success = (error == 0 && error_buff == NULL); |
| 410 LOG_IF(ERROR, !success) << "Failed to initialize sandbox: " | 410 LOG_IF(ERROR, !success) << "Failed to initialize sandbox: " |
| 411 << error | 411 << error |
| 412 << " " | 412 << " " |
| 413 << error_buff; | 413 << error_buff; |
| 414 sandbox_free_error(error_buff); | 414 sandbox_free_error(error_buff); |
| 415 return success; | 415 return success; |
| 416 } | 416 } |
| 417 | 417 |
| 418 } // namespace sandbox | 418 } // namespace sandbox |
| OLD | NEW |