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

Side by Side Diff: chrome/browser/policy/browser_policy_connector.cc

Issue 12183017: Verify the signature on user cloud policy downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment Created 7 years, 10 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/policy/browser_policy_connector.h" 5 #include "chrome/browser/policy/browser_policy_connector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h"
11 #include "base/message_loop.h" 10 #include "base/message_loop.h"
12 #include "base/path_service.h" 11 #include "base/path_service.h"
13 #include "base/string_util.h" 12 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/policy/async_policy_provider.h" 15 #include "chrome/browser/policy/async_policy_provider.h"
17 #include "chrome/browser/policy/cloud_policy_client.h" 16 #include "chrome/browser/policy/cloud_policy_client.h"
18 #include "chrome/browser/policy/cloud_policy_service.h" 17 #include "chrome/browser/policy/cloud_policy_service.h"
19 #include "chrome/browser/policy/configuration_policy_provider.h" 18 #include "chrome/browser/policy/configuration_policy_provider.h"
20 #include "chrome/browser/policy/device_management_service.h" 19 #include "chrome/browser/policy/device_management_service.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 namespace policy { 69 namespace policy {
71 70
72 namespace { 71 namespace {
73 72
74 // Subdirectory in the user's profile for storing user policies. 73 // Subdirectory in the user's profile for storing user policies.
75 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); 74 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management");
76 // File in the above directory for stroing user policy dmtokens. 75 // File in the above directory for stroing user policy dmtokens.
77 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); 76 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token");
78 // File in the above directory for storing user policy data. 77 // File in the above directory for storing user policy data.
79 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); 78 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy");
79 // Path that contains the user policy keys after the user's vault is mounted.
80 // This is appended to |g_root_path|.
81 const FilePath::CharType kUserPolicyKeyDir[] =
82 FILE_PATH_LITERAL("var/run/user_policy");
80 83
81 // The following constants define delays applied before the initial policy fetch 84 // The following constants define delays applied before the initial policy fetch
82 // on startup. (So that displaying Chrome's GUI does not get delayed.) 85 // on startup. (So that displaying Chrome's GUI does not get delayed.)
83 // Delay in milliseconds from startup. 86 // Delay in milliseconds from startup.
84 const int64 kServiceInitializationStartupDelay = 5000; 87 const int64 kServiceInitializationStartupDelay = 5000;
85 88
86 // Default policy refresh rate. 89 // Default policy refresh rate.
87 const int64 kDefaultPolicyRefreshRateMs = 3 * 60 * 60 * 1000; // 3 hours. 90 const int64 kDefaultPolicyRefreshRateMs = 3 * 60 * 60 * 1000; // 3 hours.
88 91
89 // The URL for the device management server. 92 // The URL for the device management server.
90 const char kDefaultDeviceManagementServerUrl[] = 93 const char kDefaultDeviceManagementServerUrl[] =
91 "https://m.google.com/devicemanagement/data/api"; 94 "https://m.google.com/devicemanagement/data/api";
92 95
93 // Used in BrowserPolicyConnector::SetPolicyProviderForTesting. 96 // Used in BrowserPolicyConnector::SetPolicyProviderForTesting.
94 ConfigurationPolicyProvider* g_testing_provider = NULL; 97 ConfigurationPolicyProvider* g_testing_provider = NULL;
95 98
99 // Used in BrowserPolicyConnector::SetRootPathForTesting.
100 const FilePath::CharType* g_root_path = FILE_PATH_LITERAL("/");
101
96 } // namespace 102 } // namespace
97 103
98 BrowserPolicyConnector::BrowserPolicyConnector() 104 BrowserPolicyConnector::BrowserPolicyConnector()
99 : is_initialized_(false), 105 : is_initialized_(false),
100 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {} 106 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {}
101 107
102 BrowserPolicyConnector::~BrowserPolicyConnector() { 108 BrowserPolicyConnector::~BrowserPolicyConnector() {
103 if (is_initialized()) { 109 if (is_initialized()) {
104 // Shutdown() wasn't invoked by our owner after having called Init(). 110 // Shutdown() wasn't invoked by our owner after having called Init().
105 // This usually means it's an early shutdown and 111 // This usually means it's an early shutdown and
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 254
249 CommandLine* command_line = CommandLine::ForCurrentProcess(); 255 CommandLine* command_line = CommandLine::ForCurrentProcess();
250 256
251 FilePath profile_dir; 257 FilePath profile_dir;
252 PathService::Get(chrome::DIR_USER_DATA, &profile_dir); 258 PathService::Get(chrome::DIR_USER_DATA, &profile_dir);
253 profile_dir = profile_dir.Append( 259 profile_dir = profile_dir.Append(
254 command_line->GetSwitchValuePath(switches::kLoginProfile)); 260 command_line->GetSwitchValuePath(switches::kLoginProfile));
255 const FilePath policy_dir = profile_dir.Append(kPolicyDir); 261 const FilePath policy_dir = profile_dir.Append(kPolicyDir);
256 const FilePath policy_cache_file = policy_dir.Append(kPolicyCacheFile); 262 const FilePath policy_cache_file = policy_dir.Append(kPolicyCacheFile);
257 const FilePath token_cache_file = policy_dir.Append(kTokenCacheFile); 263 const FilePath token_cache_file = policy_dir.Append(kTokenCacheFile);
264 const FilePath root_path(g_root_path);
265 const FilePath policy_key_dir(root_path.Append(kUserPolicyKeyDir));
258 266
259 if (wait_for_policy_fetch) 267 if (wait_for_policy_fetch)
260 device_management_service_->ScheduleInitialization(0); 268 device_management_service_->ScheduleInitialization(0);
261 if (is_public_account && device_local_account_policy_service_.get()) { 269 if (is_public_account && device_local_account_policy_service_.get()) {
262 device_local_account_policy_provider_.reset( 270 device_local_account_policy_provider_.reset(
263 new DeviceLocalAccountPolicyProvider( 271 new DeviceLocalAccountPolicyProvider(
264 user_name, device_local_account_policy_service_.get())); 272 user_name, device_local_account_policy_service_.get()));
265 273
266 device_local_account_policy_provider_->Init(); 274 device_local_account_policy_provider_->Init();
267 global_user_cloud_policy_provider_.SetDelegate( 275 global_user_cloud_policy_provider_.SetDelegate(
268 device_local_account_policy_provider_.get()); 276 device_local_account_policy_provider_.get());
269 } else if (!IsNonEnterpriseUser(user_name)) { 277 } else if (!IsNonEnterpriseUser(user_name)) {
270 scoped_ptr<CloudPolicyStore> store( 278 scoped_ptr<CloudPolicyStore> store(
271 new UserCloudPolicyStoreChromeOS( 279 new UserCloudPolicyStoreChromeOS(
280 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(),
272 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), 281 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
273 user_name, token_cache_file, policy_cache_file)); 282 user_name, policy_key_dir, token_cache_file, policy_cache_file));
274 user_cloud_policy_manager_.reset( 283 user_cloud_policy_manager_.reset(
275 new UserCloudPolicyManagerChromeOS(store.Pass(), 284 new UserCloudPolicyManagerChromeOS(store.Pass(),
276 wait_for_policy_fetch)); 285 wait_for_policy_fetch));
277 286
278 user_cloud_policy_manager_->Init(); 287 user_cloud_policy_manager_->Init();
279 user_cloud_policy_manager_->Connect(g_browser_process->local_state(), 288 user_cloud_policy_manager_->Connect(g_browser_process->local_state(),
280 device_management_service_.get(), 289 device_management_service_.get(),
281 GetUserAffiliation(user_name)); 290 GetUserAffiliation(user_name));
282 global_user_cloud_policy_provider_.SetDelegate( 291 global_user_cloud_policy_provider_.SetDelegate(
283 user_cloud_policy_manager_.get()); 292 user_cloud_policy_manager_.get());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 BrowserPolicyConnector::GetNetworkConfigurationUpdater() { 332 BrowserPolicyConnector::GetNetworkConfigurationUpdater() {
324 if (!network_configuration_updater_.get()) { 333 if (!network_configuration_updater_.get()) {
325 network_configuration_updater_.reset(new NetworkConfigurationUpdater( 334 network_configuration_updater_.reset(new NetworkConfigurationUpdater(
326 g_browser_process->policy_service(), 335 g_browser_process->policy_service(),
327 chromeos::CrosLibrary::Get()->GetNetworkLibrary())); 336 chromeos::CrosLibrary::Get()->GetNetworkLibrary()));
328 } 337 }
329 return network_configuration_updater_.get(); 338 return network_configuration_updater_.get();
330 } 339 }
331 #endif 340 #endif
332 341
342 // static
343 void BrowserPolicyConnector::SetRootPathForTesting(
344 const FilePath::CharType* root_path) {
345 g_root_path = root_path;
346 }
347
333 void BrowserPolicyConnector::SetDeviceManagementServiceForTesting( 348 void BrowserPolicyConnector::SetDeviceManagementServiceForTesting(
334 scoped_ptr<DeviceManagementService> service) { 349 scoped_ptr<DeviceManagementService> service) {
335 device_management_service_ = service.Pass(); 350 device_management_service_ = service.Pass();
336 } 351 }
337 352
338 // static 353 // static
339 void BrowserPolicyConnector::SetPolicyProviderForTesting( 354 void BrowserPolicyConnector::SetPolicyProviderForTesting(
340 ConfigurationPolicyProvider* provider) { 355 ConfigurationPolicyProvider* provider) {
341 CHECK(!g_browser_process) << "Must be invoked before the browser is created"; 356 CHECK(!g_browser_process) << "Must be invoked before the browser is created";
342 DCHECK(!g_testing_provider); 357 DCHECK(!g_testing_provider);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 return new AsyncPolicyProvider(loader.Pass()); 543 return new AsyncPolicyProvider(loader.Pass());
529 } else { 544 } else {
530 return NULL; 545 return NULL;
531 } 546 }
532 #else 547 #else
533 return NULL; 548 return NULL;
534 #endif 549 #endif
535 } 550 }
536 551
537 } // namespace policy 552 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698