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

Side by Side Diff: sandbox/linux/syscall_broker/broker_client.h

Issue 688843003: Linux sandbox: refactor BrokerProcess class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Lee's comments. Created 6 years, 1 month 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
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 #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 // This class can be embedded in a sandboxed process and can be
18 // used to perform certain system calls in another, presumably
19 // non-sandboxed process (which embeds BrokerHost).
20 // A key feature of this class is the ability to use some of its methods in a
21 // thread-safe and async-signal safe way. The goal is to be able to use it to
22 // replace the open() or access() system calls happening anywhere in a process
23 // (as allowed for instance by seccomp-bpf's SIGSYS mechanism).
24 class BrokerClient {
25 public:
26 // |policy| needs to match the policy used by BrokerHost. This
27 // allows to predict some of the requests which will be denied
28 // and save an IPC round trip.
29 // |ipc_channel| needs to be a suitable SOCK_SEQPACKET unix socket.
30 // |fast_check_in_client| should be set to true and
31 // |quiet_failures_for_tests| to false unless you are writing tests.
32 BrokerClient(const BrokerPolicy& policy,
33 int ipc_channel,
34 bool fast_check_in_client,
35 bool quiet_failures_for_tests);
36 ~BrokerClient();
37
38 // Can be used in place of access(). Will be async signal safe.
mdempsky 2014/10/31 22:13:43 nit: Might be clearer to say "Is async signal safe
jln (very slow on Chromium) 2014/10/31 23:15:49 Done.
39 // X_OK will always return an error in practice since the broker process
40 // doesn't support execute permissions.
41 // It's similar to the access() system call and will return -errno on errors.
42 int Access(const char* pathname, int mode) const;
43 // Can be used in place of open(). Will be async signal safe.
mdempsky 2014/10/31 22:13:43 (Here too, if you decide to change it.)
jln (very slow on Chromium) 2014/10/31 23:15:49 Done.
44 // The implementation only supports certain white listed flags and will
45 // return -EPERM on other flags.
46 // It's similar to the open() system call and will return -errno on errors.
47 int Open(const char* pathname, int flags) const;
48
49 private:
50 const BrokerPolicy& broker_policy_;
51 const int ipc_channel_;
52 const bool fast_check_in_client_; // Whether to forward a request that we
53 // know will be denied to the broker. (Used
54 // for tests).
55 const bool quiet_failures_for_tests_; // Disable certain error message when
56 // testing for failures.
57
58 int PathAndFlagsSyscall(enum IPCCommands syscall_type,
59 const char* pathname,
60 int flags) const;
61
62 DISALLOW_COPY_AND_ASSIGN(BrokerClient);
63 };
64
65 } // namespace syscall_broker
66
67 } // namespace sandbox
68
69 #endif // SANDBOX_LINUX_SYSCALL_BROKER_BROKER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698