| 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "sandbox/win/src/registry_policy.h" | 7 #include "sandbox/win/src/registry_policy.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "sandbox/win/src/ipc_tags.h" | 10 #include "sandbox/win/src/ipc_tags.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 return STATUS_SUCCESS; | 110 return STATUS_SUCCESS; |
| 111 } | 111 } |
| 112 | 112 |
| 113 } | 113 } |
| 114 | 114 |
| 115 namespace sandbox { | 115 namespace sandbox { |
| 116 | 116 |
| 117 bool RegistryPolicy::GenerateRules(const wchar_t* name, | 117 bool RegistryPolicy::GenerateRules(const wchar_t* name, |
| 118 TargetPolicy::Semantics semantics, | 118 TargetPolicy::Semantics semantics, |
| 119 LowLevelPolicy* policy) { | 119 LowLevelPolicy* policy) { |
| 120 std::wstring resovled_name(name); | 120 base::string16 resovled_name(name); |
| 121 if (resovled_name.empty()) { | 121 if (resovled_name.empty()) { |
| 122 return false; | 122 return false; |
| 123 } | 123 } |
| 124 | 124 |
| 125 if (!ResolveRegistryName(resovled_name, &resovled_name)) | 125 if (!ResolveRegistryName(resovled_name, &resovled_name)) |
| 126 return false; | 126 return false; |
| 127 | 127 |
| 128 name = resovled_name.c_str(); | 128 name = resovled_name.c_str(); |
| 129 | 129 |
| 130 EvalResult result = ASK_BROKER; | 130 EvalResult result = ASK_BROKER; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 159 if (!open.AddStringMatch(IF, OpenKey::NAME, name, CASE_INSENSITIVE) || | 159 if (!open.AddStringMatch(IF, OpenKey::NAME, name, CASE_INSENSITIVE) || |
| 160 !policy->AddRule(IPC_NTOPENKEY_TAG, &open)) { | 160 !policy->AddRule(IPC_NTOPENKEY_TAG, &open)) { |
| 161 return false; | 161 return false; |
| 162 } | 162 } |
| 163 | 163 |
| 164 return true; | 164 return true; |
| 165 } | 165 } |
| 166 | 166 |
| 167 bool RegistryPolicy::CreateKeyAction(EvalResult eval_result, | 167 bool RegistryPolicy::CreateKeyAction(EvalResult eval_result, |
| 168 const ClientInfo& client_info, | 168 const ClientInfo& client_info, |
| 169 const std::wstring &key, | 169 const base::string16 &key, |
| 170 uint32 attributes, | 170 uint32 attributes, |
| 171 HANDLE root_directory, | 171 HANDLE root_directory, |
| 172 uint32 desired_access, | 172 uint32 desired_access, |
| 173 uint32 title_index, | 173 uint32 title_index, |
| 174 uint32 create_options, | 174 uint32 create_options, |
| 175 HANDLE* handle, | 175 HANDLE* handle, |
| 176 NTSTATUS* nt_status, | 176 NTSTATUS* nt_status, |
| 177 ULONG* disposition) { | 177 ULONG* disposition) { |
| 178 // The only action supported is ASK_BROKER which means create the requested | 178 // The only action supported is ASK_BROKER which means create the requested |
| 179 // file as specified. | 179 // file as specified. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 193 InitObjectAttribs(key, attributes, root_directory, &obj_attributes, | 193 InitObjectAttribs(key, attributes, root_directory, &obj_attributes, |
| 194 &uni_name); | 194 &uni_name); |
| 195 *nt_status = NtCreateKeyInTarget(handle, desired_access, &obj_attributes, | 195 *nt_status = NtCreateKeyInTarget(handle, desired_access, &obj_attributes, |
| 196 title_index, NULL, create_options, | 196 title_index, NULL, create_options, |
| 197 disposition, client_info.process); | 197 disposition, client_info.process); |
| 198 return true; | 198 return true; |
| 199 } | 199 } |
| 200 | 200 |
| 201 bool RegistryPolicy::OpenKeyAction(EvalResult eval_result, | 201 bool RegistryPolicy::OpenKeyAction(EvalResult eval_result, |
| 202 const ClientInfo& client_info, | 202 const ClientInfo& client_info, |
| 203 const std::wstring &key, | 203 const base::string16 &key, |
| 204 uint32 attributes, | 204 uint32 attributes, |
| 205 HANDLE root_directory, | 205 HANDLE root_directory, |
| 206 uint32 desired_access, | 206 uint32 desired_access, |
| 207 HANDLE* handle, | 207 HANDLE* handle, |
| 208 NTSTATUS* nt_status) { | 208 NTSTATUS* nt_status) { |
| 209 // The only action supported is ASK_BROKER which means open the requested | 209 // The only action supported is ASK_BROKER which means open the requested |
| 210 // file as specified. | 210 // file as specified. |
| 211 if (ASK_BROKER != eval_result) { | 211 if (ASK_BROKER != eval_result) { |
| 212 *nt_status = STATUS_ACCESS_DENIED; | 212 *nt_status = STATUS_ACCESS_DENIED; |
| 213 return true; | 213 return true; |
| 214 } | 214 } |
| 215 | 215 |
| 216 UNICODE_STRING uni_name = {0}; | 216 UNICODE_STRING uni_name = {0}; |
| 217 OBJECT_ATTRIBUTES obj_attributes = {0}; | 217 OBJECT_ATTRIBUTES obj_attributes = {0}; |
| 218 InitObjectAttribs(key, attributes, root_directory, &obj_attributes, | 218 InitObjectAttribs(key, attributes, root_directory, &obj_attributes, |
| 219 &uni_name); | 219 &uni_name); |
| 220 *nt_status = NtOpenKeyInTarget(handle, desired_access, &obj_attributes, | 220 *nt_status = NtOpenKeyInTarget(handle, desired_access, &obj_attributes, |
| 221 client_info.process); | 221 client_info.process); |
| 222 return true; | 222 return true; |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace sandbox | 225 } // namespace sandbox |
| OLD | NEW |