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

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

Issue 721553002: sandbox: Extend BrokerPolicy to support file creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding 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_FILE_PERMISSION_H_
6 #define SANDBOX_LINUX_SYSCALL_BROKER_BROKER_FILE_PERMISSION_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11
12 namespace sandbox {
13
14 namespace syscall_broker {
15
16 class BrokerFilePermission {
Jorge Lucangeli Obes 2014/11/14 18:48:07 Maybe Julien has a point here. How would this look
leecam 2014/11/18 21:40:54 As we discussed offline, happy to change this to a
17 public:
18 BrokerFilePermission(std::string path,
19 bool recursive,
20 bool unlink,
21 bool allow_read,
22 bool allow_write,
23 bool allow_create);
24 ~BrokerFilePermission() {}
25 // Returns true if |requested_filename| is allowed to be open
26 // by this permission.
27 // If |file_to_open| is not NULL it is set to point to either
28 // the |requested_filename| in the case of a recursive match,
29 // or a pointer the matched path in the whitelist if an absolute
30 // match.
31 // Async signal safe if |file_to_open| is NULL
32 bool CheckOpen(const char* requested_filename,
33 int flags,
34 const char** file_to_open,
35 bool* unlink_after_open) const;
36 // Returns true if |requested_filename| is allowed to be accessed
37 // by this permission.
38 // If |file_to_open| is not NULL it is set to point to either
39 // the |requested_filename| in the case of a recursive match,
40 // or a pointer the matched path in the whitelist if an absolute
41 // match.
42 // Async signal safe if |file_to_open| is NULL
43 bool CheckAccess(const char* requested_filename,
44 int mode,
45 const char** file_to_access) const;
46
47 private:
Jorge Lucangeli Obes 2014/11/14 18:48:07 Don't forget DISALLOW_COPY_AND_ASSIGN(BrokerPermis
leecam 2014/11/18 21:40:54 Can't use DISALLOW_COPY_AND_ASSIGN as it is copied
mdempsky 2014/11/18 22:23:41 In that case, the style guide requires you to writ
48 bool IsPathCoveredByThisPermission(const char* requested_filename) const;
49
50 const std::string path_;
51 const bool
52 recursive_; // Allow everything under this path. |path| must be a dir.
53 const bool unlink_; // unlink after openning.
54 const bool allow_read_;
55 const bool allow_write_;
56 const bool allow_create_;
57 };
jln (very slow on Chromium) 2014/11/18 01:24:46 To add to my previous remark: don't forget that cl
leecam 2014/11/18 21:40:53 Hah this was a struct in the first CL but changed
58
59 class BrokerFilePermissionReadOnly : public BrokerFilePermission {
mdempsky 2014/11/18 22:23:41 Do we gain anything by making these subclasses ins
60 public:
61 BrokerFilePermissionReadOnly(std::string path)
62 : BrokerFilePermission(path, false, false, true, false, false) {}
63 };
64
65 class BrokerFilePermissionReadOnlyRecursive : public BrokerFilePermission {
66 public:
67 BrokerFilePermissionReadOnlyRecursive(std::string path)
68 : BrokerFilePermission(path, true, false, true, false, false) {}
69 };
70
71 class BrokerFilePermissionWriteOnly : public BrokerFilePermission {
72 public:
73 BrokerFilePermissionWriteOnly(std::string path)
74 : BrokerFilePermission(path, false, false, false, true, false) {}
75 };
76
77 class BrokerFilePermissionReadWrite : public BrokerFilePermission {
78 public:
79 BrokerFilePermissionReadWrite(std::string path)
80 : BrokerFilePermission(path, false, false, true, true, false) {}
81 };
82
83 class BrokerFilePermissionReadWriteCreate : public BrokerFilePermission {
84 public:
85 BrokerFilePermissionReadWriteCreate(std::string path)
86 : BrokerFilePermission(path, false, false, true, true, true) {}
87 };
88
89 class BrokerFilePermissionReadWriteCreateUnlink : public BrokerFilePermission {
90 public:
91 BrokerFilePermissionReadWriteCreateUnlink(std::string path)
92 : BrokerFilePermission(path, false, true, true, true, true) {}
93 };
94
95 class BrokerFilePermissionReadWriteCreateUnlinkRecursive
96 : public BrokerFilePermission {
97 public:
98 BrokerFilePermissionReadWriteCreateUnlinkRecursive(std::string path)
99 : BrokerFilePermission(path, true, true, true, true, true) {}
100 };
101
102 } // namespace syscall_broker
103
104 } // namespace sandbox
105
106 #endif // SANDBOX_LINUX_SYSCALL_BROKER_BROKER_FILE_PERMISSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698