OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef SANDBOX_SRC_FILESYSTEM_POLICY_H__ | 5 #ifndef SANDBOX_SRC_FILESYSTEM_POLICY_H__ |
6 #define SANDBOX_SRC_FILESYSTEM_POLICY_H__ | 6 #define SANDBOX_SRC_FILESYSTEM_POLICY_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/strings/string16.h" |
11 #include "sandbox/win/src/crosscall_server.h" | 12 #include "sandbox/win/src/crosscall_server.h" |
12 #include "sandbox/win/src/nt_internals.h" | 13 #include "sandbox/win/src/nt_internals.h" |
13 #include "sandbox/win/src/policy_low_level.h" | 14 #include "sandbox/win/src/policy_low_level.h" |
14 #include "sandbox/win/src/sandbox_policy.h" | 15 #include "sandbox/win/src/sandbox_policy.h" |
15 | 16 |
16 namespace sandbox { | 17 namespace sandbox { |
17 | 18 |
18 enum EvalResult; | 19 enum EvalResult; |
19 | 20 |
20 // This class centralizes most of the knowledge related to file system policy | 21 // This class centralizes most of the knowledge related to file system policy |
(...skipping 11 matching lines...) Expand all Loading... |
32 // Add basic file system rules. | 33 // Add basic file system rules. |
33 static bool SetInitialRules(LowLevelPolicy* policy); | 34 static bool SetInitialRules(LowLevelPolicy* policy); |
34 | 35 |
35 // Performs the desired policy action on a create request with an | 36 // Performs the desired policy action on a create request with an |
36 // API that is compatible with the IPC-received parameters. | 37 // API that is compatible with the IPC-received parameters. |
37 // 'client_info' : the target process that is making the request. | 38 // 'client_info' : the target process that is making the request. |
38 // 'eval_result' : The desired policy action to accomplish. | 39 // 'eval_result' : The desired policy action to accomplish. |
39 // 'file' : The target file or directory. | 40 // 'file' : The target file or directory. |
40 static bool CreateFileAction(EvalResult eval_result, | 41 static bool CreateFileAction(EvalResult eval_result, |
41 const ClientInfo& client_info, | 42 const ClientInfo& client_info, |
42 const std::wstring &file, | 43 const base::string16 &file, |
43 uint32 attributes, | 44 uint32 attributes, |
44 uint32 desired_access, | 45 uint32 desired_access, |
45 uint32 file_attributes, | 46 uint32 file_attributes, |
46 uint32 share_access, | 47 uint32 share_access, |
47 uint32 create_disposition, | 48 uint32 create_disposition, |
48 uint32 create_options, | 49 uint32 create_options, |
49 HANDLE* handle, | 50 HANDLE* handle, |
50 NTSTATUS* nt_status, | 51 NTSTATUS* nt_status, |
51 ULONG_PTR* io_information); | 52 ULONG_PTR* io_information); |
52 | 53 |
53 // Performs the desired policy action on an open request with an | 54 // Performs the desired policy action on an open request with an |
54 // API that is compatible with the IPC-received parameters. | 55 // API that is compatible with the IPC-received parameters. |
55 // 'client_info' : the target process that is making the request. | 56 // 'client_info' : the target process that is making the request. |
56 // 'eval_result' : The desired policy action to accomplish. | 57 // 'eval_result' : The desired policy action to accomplish. |
57 // 'file' : The target file or directory. | 58 // 'file' : The target file or directory. |
58 static bool OpenFileAction(EvalResult eval_result, | 59 static bool OpenFileAction(EvalResult eval_result, |
59 const ClientInfo& client_info, | 60 const ClientInfo& client_info, |
60 const std::wstring &file, | 61 const base::string16 &file, |
61 uint32 attributes, | 62 uint32 attributes, |
62 uint32 desired_access, | 63 uint32 desired_access, |
63 uint32 share_access, | 64 uint32 share_access, |
64 uint32 open_options, | 65 uint32 open_options, |
65 HANDLE* handle, | 66 HANDLE* handle, |
66 NTSTATUS* nt_status, | 67 NTSTATUS* nt_status, |
67 ULONG_PTR* io_information); | 68 ULONG_PTR* io_information); |
68 | 69 |
69 // Performs the desired policy action on a query request with an | 70 // Performs the desired policy action on a query request with an |
70 // API that is compatible with the IPC-received parameters. | 71 // API that is compatible with the IPC-received parameters. |
71 static bool QueryAttributesFileAction(EvalResult eval_result, | 72 static bool QueryAttributesFileAction(EvalResult eval_result, |
72 const ClientInfo& client_info, | 73 const ClientInfo& client_info, |
73 const std::wstring &file, | 74 const base::string16 &file, |
74 uint32 attributes, | 75 uint32 attributes, |
75 FILE_BASIC_INFORMATION* file_info, | 76 FILE_BASIC_INFORMATION* file_info, |
76 NTSTATUS* nt_status); | 77 NTSTATUS* nt_status); |
77 | 78 |
78 // Performs the desired policy action on a query request with an | 79 // Performs the desired policy action on a query request with an |
79 // API that is compatible with the IPC-received parameters. | 80 // API that is compatible with the IPC-received parameters. |
80 static bool QueryFullAttributesFileAction( | 81 static bool QueryFullAttributesFileAction( |
81 EvalResult eval_result, | 82 EvalResult eval_result, |
82 const ClientInfo& client_info, | 83 const ClientInfo& client_info, |
83 const std::wstring &file, | 84 const base::string16 &file, |
84 uint32 attributes, | 85 uint32 attributes, |
85 FILE_NETWORK_OPEN_INFORMATION* file_info, | 86 FILE_NETWORK_OPEN_INFORMATION* file_info, |
86 NTSTATUS* nt_status); | 87 NTSTATUS* nt_status); |
87 | 88 |
88 // Performs the desired policy action on a set_info request with an | 89 // Performs the desired policy action on a set_info request with an |
89 // API that is compatible with the IPC-received parameters. | 90 // API that is compatible with the IPC-received parameters. |
90 static bool SetInformationFileAction(EvalResult eval_result, | 91 static bool SetInformationFileAction(EvalResult eval_result, |
91 const ClientInfo& client_info, | 92 const ClientInfo& client_info, |
92 HANDLE target_file_handle, | 93 HANDLE target_file_handle, |
93 void* file_info, | 94 void* file_info, |
94 uint32 length, | 95 uint32 length, |
95 uint32 info_class, | 96 uint32 info_class, |
96 IO_STATUS_BLOCK* io_block, | 97 IO_STATUS_BLOCK* io_block, |
97 NTSTATUS* nt_status); | 98 NTSTATUS* nt_status); |
98 }; | 99 }; |
99 | 100 |
100 // Expands the path and check if it's a reparse point. Returns false if | 101 // Expands the path and check if it's a reparse point. Returns false if |
101 // we cannot determine or if there is an unexpected error. In that case | 102 // we cannot determine or if there is an unexpected error. In that case |
102 // the path cannot be trusted. | 103 // the path cannot be trusted. |
103 bool PreProcessName(const std::wstring& path, std::wstring* new_path); | 104 bool PreProcessName(const base::string16& path, base::string16* new_path); |
104 | 105 |
105 } // namespace sandbox | 106 } // namespace sandbox |
106 | 107 |
107 #endif // SANDBOX_SRC_FILESYSTEM_POLICY_H__ | 108 #endif // SANDBOX_SRC_FILESYSTEM_POLICY_H__ |
OLD | NEW |