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

Side by Side Diff: chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.cc

Issue 2727713003: Update FWMP in TPM (Closed)
Patch Set: Nit Created 3 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/login/enrollment/auto_enrollment_controller.h" 5 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.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/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
14 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" 14 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h"
15 #include "chromeos/chromeos_switches.h" 15 #include "chromeos/chromeos_switches.h"
16 #include "chromeos/dbus/cryptohome/rpc.pb.h"
17 #include "chromeos/dbus/cryptohome_client.h"
18 #include "chromeos/dbus/dbus_thread_manager.h"
16 #include "chromeos/system/statistics_provider.h" 19 #include "chromeos/system/statistics_provider.h"
17 #include "components/policy/core/common/cloud/device_management_service.h" 20 #include "components/policy/core/common/cloud/device_management_service.h"
18 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
19 22
20 namespace chromeos { 23 namespace chromeos {
21 24
22 namespace { 25 namespace {
23 26
24 // Maximum time to wait before forcing a decision. Note that download time for 27 // Maximum time to wait before forcing a decision. Note that download time for
25 // state key buckets can be non-negligible, especially on 2G connections. 28 // state key buckets can be non-negligible, especially on 2G connections.
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 case policy::AUTO_ENROLLMENT_STATE_PENDING: 297 case policy::AUTO_ENROLLMENT_STATE_PENDING:
295 break; 298 break;
296 case policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR: 299 case policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR:
297 case policy::AUTO_ENROLLMENT_STATE_SERVER_ERROR: 300 case policy::AUTO_ENROLLMENT_STATE_SERVER_ERROR:
298 case policy::AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT: 301 case policy::AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT:
299 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT: 302 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT:
300 safeguard_timer_.Stop(); 303 safeguard_timer_.Stop();
301 break; 304 break;
302 } 305 }
303 306
307 if (state_ == policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT) {
308 StartRemoveFirmwareManagementParameters();
309 } else {
310 progress_callbacks_.Notify(state_);
311 }
312 }
313
314 void AutoEnrollmentController::StartRemoveFirmwareManagementParameters() {
315 DCHECK_EQ(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT, state_);
316
317 cryptohome::RemoveFirmwareManagementParametersRequest request;
318 chromeos::DBusThreadManager::Get()
319 ->GetCryptohomeClient()
320 ->RemoveFirmwareManagementParametersFromTpm(
321 request,
322 base::Bind(
323 &AutoEnrollmentController::OnFirmwareManagementParametersRemoved,
324 base::Unretained(this)));
Thiemo Nagel 2017/03/27 17:21:47 base::Unretained() seems unsafe. Are you sure thi
igorcov 2017/03/28 16:39:09 Not sure if it counts as "check", but safeguard_ti
Thiemo Nagel 2017/03/29 10:47:21 I think unless specified in the contract for the c
igorcov 2017/03/29 15:17:17 Done.
325 }
326
327 void AutoEnrollmentController::OnFirmwareManagementParametersRemoved(
328 chromeos::DBusMethodCallStatus call_status,
329 bool result,
330 const cryptohome::BaseReply& reply) {
331 if (!result) {
332 LOG(ERROR) << "Failed to remove firmware management parameters, error: "
333 << reply.error();
334 }
335
304 progress_callbacks_.Notify(state_); 336 progress_callbacks_.Notify(state_);
305 } 337 }
306 338
307 void AutoEnrollmentController::Timeout() { 339 void AutoEnrollmentController::Timeout() {
308 // TODO(mnissler): Add UMA to track results of auto-enrollment checks. 340 // TODO(mnissler): Add UMA to track results of auto-enrollment checks.
309 if (client_start_weak_factory_.HasWeakPtrs() && 341 if (client_start_weak_factory_.HasWeakPtrs() &&
310 fre_requirement_ != EXPLICITLY_REQUIRED) { 342 fre_requirement_ != EXPLICITLY_REQUIRED) {
311 // If the callbacks to check ownership status or state keys are still 343 // If the callbacks to check ownership status or state keys are still
312 // pending, there's a bug in the code running on the device. No use in 344 // pending, there's a bug in the code running on the device. No use in
313 // retrying anything, need to fix that bug. 345 // retrying anything, need to fix that bug.
314 LOG(ERROR) << "Failed to start auto-enrollment check, fix the code!"; 346 LOG(ERROR) << "Failed to start auto-enrollment check, fix the code!";
315 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); 347 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT);
316 } else { 348 } else {
317 // This can actually happen in some cases, for example when state key 349 // This can actually happen in some cases, for example when state key
318 // generation is waiting for time sync or the server just doesn't reply and 350 // generation is waiting for time sync or the server just doesn't reply and
319 // keeps the connection open. 351 // keeps the connection open.
320 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit."; 352 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit.";
321 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR); 353 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR);
322 } 354 }
323 355
324 // Reset state. 356 // Reset state.
325 Cancel(); 357 Cancel();
326 } 358 }
327 359
328 } // namespace chromeos 360 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698