| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "sandbox/mac/seatbelt.h" | 5 #include "sandbox/mac/seatbelt.h" |
| 6 | 6 |
| 7 #include <unistd.h> |
| 8 |
| 7 extern "C" { | 9 extern "C" { |
| 8 #include <sandbox.h> | 10 #include <sandbox.h> |
| 9 | 11 |
| 10 int sandbox_init_with_parameters(const char* profile, | 12 int sandbox_init_with_parameters(const char* profile, |
| 11 uint64_t flags, | 13 uint64_t flags, |
| 12 const char* const parameters[], | 14 const char* const parameters[], |
| 13 char** errorbuf); | 15 char** errorbuf); |
| 16 |
| 17 // Not deprecated. The canonical usage to test if sandboxed is |
| 18 // sandbox_check(getpid(), NULL, SANDBOX_FILTER_NONE), which returns |
| 19 // 1 if sandboxed. Note `type` is actually a sandbox_filter_type enum value, but |
| 20 // it is unused currently. |
| 21 int sandbox_check(pid_t pid, const char* operation, int type, ...); |
| 14 }; | 22 }; |
| 15 | 23 |
| 16 namespace sandbox { | 24 namespace sandbox { |
| 17 | 25 |
| 18 // Initialize the static member variables. | 26 // Initialize the static member variables. |
| 19 #pragma clang diagnostic push | 27 #pragma clang diagnostic push |
| 20 #pragma clang diagnostic ignored "-Wdeprecated-declarations" | 28 #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
| 21 const char* Seatbelt::kProfileNoInternet = kSBXProfileNoInternet; | 29 const char* Seatbelt::kProfileNoInternet = kSBXProfileNoInternet; |
| 22 const char* Seatbelt::kProfileNoNetwork = kSBXProfileNoNetwork; | 30 const char* Seatbelt::kProfileNoNetwork = kSBXProfileNoNetwork; |
| 23 const char* Seatbelt::kProfileNoWrite = kSBXProfileNoWrite; | 31 const char* Seatbelt::kProfileNoWrite = kSBXProfileNoWrite; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 47 // static | 55 // static |
| 48 void Seatbelt::FreeError(char* errorbuf) { | 56 void Seatbelt::FreeError(char* errorbuf) { |
| 49 // OS X deprecated these functions, but did not provide a suitable replacement, | 57 // OS X deprecated these functions, but did not provide a suitable replacement, |
| 50 // so ignore the deprecation warning. | 58 // so ignore the deprecation warning. |
| 51 #pragma clang diagnostic push | 59 #pragma clang diagnostic push |
| 52 #pragma clang diagnostic ignored "-Wdeprecated-declarations" | 60 #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
| 53 return ::sandbox_free_error(errorbuf); | 61 return ::sandbox_free_error(errorbuf); |
| 54 #pragma clang diagnostic pop | 62 #pragma clang diagnostic pop |
| 55 } | 63 } |
| 56 | 64 |
| 65 // static |
| 66 bool Seatbelt::IsSandboxed() { |
| 67 return ::sandbox_check(getpid(), NULL, 0); |
| 68 } |
| 69 |
| 57 } // namespace sandbox | 70 } // namespace sandbox |
| OLD | NEW |