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 #ifndef SANDBOX_LINUX_SYSCALL_BROKER_BROKER_CLIENT_H_ |
| 6 #define SANDBOX_LINUX_SYSCALL_BROKER_BROKER_CLIENT_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "sandbox/linux/syscall_broker/broker_common.h" |
| 10 |
| 11 namespace sandbox { |
| 12 |
| 13 namespace syscall_broker { |
| 14 |
| 15 class BrokerPolicy; |
| 16 |
| 17 class BrokerClient { |
| 18 public: |
| 19 BrokerClient(const BrokerPolicy& broker_policy, |
| 20 int ipc_channel, |
| 21 bool fast_check_in_client = true, |
| 22 bool quiet_failures_for_tests = false); |
| 23 ~BrokerClient(); |
| 24 |
| 25 // Can be used in place of access(). Will be async signal safe. |
| 26 // X_OK will always return an error in practice since the broker process |
| 27 // doesn't support execute permissions. |
| 28 // It's similar to the access() system call and will return -errno on errors. |
| 29 int Access(const char* pathname, int mode) const; |
| 30 // Can be used in place of open(). Will be async signal safe. |
| 31 // The implementation only supports certain white listed flags and will |
| 32 // return -EPERM on other flags. |
| 33 // It's similar to the open() system call and will return -errno on errors. |
| 34 int Open(const char* pathname, int flags) const; |
| 35 |
| 36 private: |
| 37 const BrokerPolicy& broker_policy_; |
| 38 const int ipc_channel_; |
| 39 const bool fast_check_in_client_; // Whether to forward a request that we |
| 40 // know will be denied to the broker. (Used |
| 41 // for tests). |
| 42 const bool quiet_failures_for_tests_; // Disable certain error message when |
| 43 // testing for failures. |
| 44 |
| 45 int PathAndFlagsSyscall(enum IPCCommands syscall_type, |
| 46 const char* pathname, |
| 47 int flags) const; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(BrokerClient); |
| 50 }; |
| 51 |
| 52 } // namespace syscall_broker |
| 53 |
| 54 } // namespace sandbox |
| 55 |
| 56 #endif // SANDBOX_LINUX_SYSCALL_BROKER_BROKER_CLIENT_H_ |
OLD | NEW |