security/sandbox/win/src/filesystem_policy.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #ifndef SANDBOX_SRC_FILESYSTEM_POLICY_H__
michael@0 6 #define SANDBOX_SRC_FILESYSTEM_POLICY_H__
michael@0 7
michael@0 8 #include <string>
michael@0 9
michael@0 10 #include "base/basictypes.h"
michael@0 11 #include "sandbox/win/src/crosscall_server.h"
michael@0 12 #include "sandbox/win/src/nt_internals.h"
michael@0 13 #include "sandbox/win/src/policy_low_level.h"
michael@0 14 #include "sandbox/win/src/sandbox_policy.h"
michael@0 15
michael@0 16 namespace sandbox {
michael@0 17
michael@0 18 enum EvalResult;
michael@0 19
michael@0 20 // This class centralizes most of the knowledge related to file system policy
michael@0 21 class FileSystemPolicy {
michael@0 22 public:
michael@0 23 // Creates the required low-level policy rules to evaluate a high-level
michael@0 24 // policy rule for File IO, in particular open or create actions.
michael@0 25 // 'name' is the file or directory name.
michael@0 26 // 'semantics' is the desired semantics for the open or create.
michael@0 27 // 'policy' is the policy generator to which the rules are going to be added.
michael@0 28 static bool GenerateRules(const wchar_t* name,
michael@0 29 TargetPolicy::Semantics semantics,
michael@0 30 LowLevelPolicy* policy);
michael@0 31
michael@0 32 // Add basic file system rules.
michael@0 33 static bool SetInitialRules(LowLevelPolicy* policy);
michael@0 34
michael@0 35 // Performs the desired policy action on a create request with an
michael@0 36 // API that is compatible with the IPC-received parameters.
michael@0 37 // 'client_info' : the target process that is making the request.
michael@0 38 // 'eval_result' : The desired policy action to accomplish.
michael@0 39 // 'file' : The target file or directory.
michael@0 40 static bool CreateFileAction(EvalResult eval_result,
michael@0 41 const ClientInfo& client_info,
michael@0 42 const std::wstring &file,
michael@0 43 uint32 attributes,
michael@0 44 uint32 desired_access,
michael@0 45 uint32 file_attributes,
michael@0 46 uint32 share_access,
michael@0 47 uint32 create_disposition,
michael@0 48 uint32 create_options,
michael@0 49 HANDLE* handle,
michael@0 50 NTSTATUS* nt_status,
michael@0 51 ULONG_PTR* io_information);
michael@0 52
michael@0 53 // Performs the desired policy action on an open request with an
michael@0 54 // API that is compatible with the IPC-received parameters.
michael@0 55 // 'client_info' : the target process that is making the request.
michael@0 56 // 'eval_result' : The desired policy action to accomplish.
michael@0 57 // 'file' : The target file or directory.
michael@0 58 static bool OpenFileAction(EvalResult eval_result,
michael@0 59 const ClientInfo& client_info,
michael@0 60 const std::wstring &file,
michael@0 61 uint32 attributes,
michael@0 62 uint32 desired_access,
michael@0 63 uint32 share_access,
michael@0 64 uint32 open_options,
michael@0 65 HANDLE* handle,
michael@0 66 NTSTATUS* nt_status,
michael@0 67 ULONG_PTR* io_information);
michael@0 68
michael@0 69 // Performs the desired policy action on a query request with an
michael@0 70 // API that is compatible with the IPC-received parameters.
michael@0 71 static bool QueryAttributesFileAction(EvalResult eval_result,
michael@0 72 const ClientInfo& client_info,
michael@0 73 const std::wstring &file,
michael@0 74 uint32 attributes,
michael@0 75 FILE_BASIC_INFORMATION* file_info,
michael@0 76 NTSTATUS* nt_status);
michael@0 77
michael@0 78 // Performs the desired policy action on a query request with an
michael@0 79 // API that is compatible with the IPC-received parameters.
michael@0 80 static bool QueryFullAttributesFileAction(
michael@0 81 EvalResult eval_result,
michael@0 82 const ClientInfo& client_info,
michael@0 83 const std::wstring &file,
michael@0 84 uint32 attributes,
michael@0 85 FILE_NETWORK_OPEN_INFORMATION* file_info,
michael@0 86 NTSTATUS* nt_status);
michael@0 87
michael@0 88 // Performs the desired policy action on a set_info request with an
michael@0 89 // API that is compatible with the IPC-received parameters.
michael@0 90 static bool SetInformationFileAction(EvalResult eval_result,
michael@0 91 const ClientInfo& client_info,
michael@0 92 HANDLE target_file_handle,
michael@0 93 void* file_info,
michael@0 94 uint32 length,
michael@0 95 uint32 info_class,
michael@0 96 IO_STATUS_BLOCK* io_block,
michael@0 97 NTSTATUS* nt_status);
michael@0 98 };
michael@0 99
michael@0 100 // Expands the path and check if it's a reparse point. Returns false if
michael@0 101 // we cannot determine or if there is an unexpected error. In that case
michael@0 102 // the path cannot be trusted.
michael@0 103 bool PreProcessName(const std::wstring& path, std::wstring* new_path);
michael@0 104
michael@0 105 } // namespace sandbox
michael@0 106
michael@0 107 #endif // SANDBOX_SRC_FILESYSTEM_POLICY_H__

mercurial