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
3 // found in the LICENSE file.
5 #ifndef SANDBOX_SRC_FILESYSTEM_POLICY_H__
6 #define SANDBOX_SRC_FILESYSTEM_POLICY_H__
10 #include "base/basictypes.h"
11 #include "sandbox/win/src/crosscall_server.h"
12 #include "sandbox/win/src/nt_internals.h"
13 #include "sandbox/win/src/policy_low_level.h"
14 #include "sandbox/win/src/sandbox_policy.h"
20 // This class centralizes most of the knowledge related to file system policy
21 class FileSystemPolicy
{
23 // Creates the required low-level policy rules to evaluate a high-level
24 // policy rule for File IO, in particular open or create actions.
25 // 'name' is the file or directory name.
26 // 'semantics' is the desired semantics for the open or create.
27 // 'policy' is the policy generator to which the rules are going to be added.
28 static bool GenerateRules(const wchar_t* name
,
29 TargetPolicy::Semantics semantics
,
30 LowLevelPolicy
* policy
);
32 // Add basic file system rules.
33 static bool SetInitialRules(LowLevelPolicy
* policy
);
35 // Performs the desired policy action on a create request with an
36 // API that is compatible with the IPC-received parameters.
37 // 'client_info' : the target process that is making the request.
38 // 'eval_result' : The desired policy action to accomplish.
39 // 'file' : The target file or directory.
40 static bool CreateFileAction(EvalResult eval_result
,
41 const ClientInfo
& client_info
,
42 const std::wstring
&file
,
44 uint32 desired_access
,
45 uint32 file_attributes
,
47 uint32 create_disposition
,
48 uint32 create_options
,
51 ULONG_PTR
* io_information
);
53 // Performs the desired policy action on an open request with an
54 // API that is compatible with the IPC-received parameters.
55 // 'client_info' : the target process that is making the request.
56 // 'eval_result' : The desired policy action to accomplish.
57 // 'file' : The target file or directory.
58 static bool OpenFileAction(EvalResult eval_result
,
59 const ClientInfo
& client_info
,
60 const std::wstring
&file
,
62 uint32 desired_access
,
67 ULONG_PTR
* io_information
);
69 // Performs the desired policy action on a query request with an
70 // API that is compatible with the IPC-received parameters.
71 static bool QueryAttributesFileAction(EvalResult eval_result
,
72 const ClientInfo
& client_info
,
73 const std::wstring
&file
,
75 FILE_BASIC_INFORMATION
* file_info
,
78 // Performs the desired policy action on a query request with an
79 // API that is compatible with the IPC-received parameters.
80 static bool QueryFullAttributesFileAction(
81 EvalResult eval_result
,
82 const ClientInfo
& client_info
,
83 const std::wstring
&file
,
85 FILE_NETWORK_OPEN_INFORMATION
* file_info
,
88 // Performs the desired policy action on a set_info request with an
89 // API that is compatible with the IPC-received parameters.
90 static bool SetInformationFileAction(EvalResult eval_result
,
91 const ClientInfo
& client_info
,
92 HANDLE target_file_handle
,
96 IO_STATUS_BLOCK
* io_block
,
100 // 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 // the path cannot be trusted.
103 bool PreProcessName(const std::wstring
& path
, std::wstring
* new_path
);
105 } // namespace sandbox
107 #endif // SANDBOX_SRC_FILESYSTEM_POLICY_H__