Commit 8f07351e authored by derat's avatar derat Committed by Commit bot

chromeos: Avoid cryptohome D-Bus log spam at boot.

Make EnterpriseInstallAttributes defer running its
consistency check (which calls cryptohome's TpmIsOwned
method over D-Bus) until the cryptohome service is
available.

Also fix an apparent bug where the check was retried five
times the intended number of times.

BUG=636554

Review-Url: https://codereview.chromium.org/2244443002
Cr-Commit-Position: refs/heads/master@{#419180}
parent 1d291e86
......@@ -79,11 +79,15 @@ EnterpriseInstallAttributes::EnterpriseInstallAttributes(
EnterpriseInstallAttributes::~EnterpriseInstallAttributes() {}
void EnterpriseInstallAttributes::Init(const base::FilePath& cache_file) {
DCHECK_EQ(false, device_locked_);
DCHECK(!device_locked_);
// The actual check happens asynchronously, thus it is ok to trigger it before
// Init() has completed.
TriggerConsistencyCheck(kDbusRetryCount * kDbusRetryIntervalInSeconds);
// Mark the consistency check as running to ensure that LockDevice() is
// blocked, but wait for the cryptohome service to be available before
// actually calling TriggerConsistencyCheck().
consistency_check_running_ = true;
cryptohome_client_->WaitForServiceToBeAvailable(base::Bind(
&EnterpriseInstallAttributes::OnCryptohomeServiceInitiallyAvailable,
weak_ptr_factory_.GetWeakPtr()));
if (!base::PathExists(cache_file))
return;
......@@ -99,7 +103,7 @@ void EnterpriseInstallAttributes::Init(const base::FilePath& cache_file) {
cryptohome::SerializedInstallAttributes install_attrs_proto;
if (!install_attrs_proto.ParseFromArray(buf, len)) {
LOG(ERROR) << "Failed to parse install attributes cache";
LOG(ERROR) << "Failed to parse install attributes cache.";
return;
}
......@@ -356,7 +360,6 @@ DeviceMode EnterpriseInstallAttributes::GetMode() {
}
void EnterpriseInstallAttributes::TriggerConsistencyCheck(int dbus_retries) {
consistency_check_running_ = true;
cryptohome_client_->TpmIsOwned(
base::Bind(&EnterpriseInstallAttributes::OnTpmOwnerCheckCompleted,
weak_ptr_factory_.GetWeakPtr(),
......@@ -418,6 +421,16 @@ const char EnterpriseInstallAttributes::kAttrEnterpriseUser[] =
const char EnterpriseInstallAttributes::kAttrConsumerKioskEnabled[] =
"consumer.app_kiosk_enabled";
void EnterpriseInstallAttributes::OnCryptohomeServiceInitiallyAvailable(
bool service_is_ready) {
if (!service_is_ready)
LOG(ERROR) << "Failed waiting for cryptohome D-Bus service availability.";
// Start the consistency check even if we failed to wait for availability;
// hopefully the service will become available eventually.
TriggerConsistencyCheck(kDbusRetryCount);
}
std::string EnterpriseInstallAttributes::GetDeviceModeString(DeviceMode mode) {
switch (mode) {
case DEVICE_MODE_CONSUMER:
......
......@@ -139,6 +139,10 @@ class EnterpriseInstallAttributes {
static const char kAttrEnterpriseUser[];
static const char kAttrConsumerKioskEnabled[];
// Called by |cryptohome_client_| when the cryptohome service becomes
// initially available over D-Bus.
void OnCryptohomeServiceInitiallyAvailable(bool service_is_ready);
// Translates DeviceMode constants to strings used in the lockbox.
std::string GetDeviceModeString(DeviceMode mode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment