| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS 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 "service.h" | 5 #include "service.h" |
| 6 | 6 |
| 7 #define __STDC_FORMAT_MACROS 1 |
| 8 #include <inttypes.h> |
| 7 #include <stdio.h> | 9 #include <stdio.h> |
| 8 #include <stdlib.h> | 10 #include <stdlib.h> |
| 9 | 11 |
| 10 #include <base/file_util.h> | 12 #include <base/file_util.h> |
| 11 #include <base/logging.h> | 13 #include <base/logging.h> |
| 12 #include <base/string_util.h> | 14 #include <base/string_util.h> |
| 13 #include <base/time.h> | 15 #include <base/time.h> |
| 14 #include <chromeos/dbus/dbus.h> | 16 #include <chromeos/dbus/dbus.h> |
| 17 #include <string> |
| 18 #include <vector> |
| 15 | 19 |
| 16 #include "cryptohome/marshal.glibmarshal.h" | 20 #include "cryptohome/marshal.glibmarshal.h" |
| 17 #include "cryptohome_event_source.h" | 21 #include "cryptohome_event_source.h" |
| 22 #include "crypto.h" |
| 23 #include "install_attributes.h" |
| 18 #include "interface.h" | 24 #include "interface.h" |
| 19 #include "crypto.h" | |
| 20 #include "mount.h" | 25 #include "mount.h" |
| 21 #include "secure_blob.h" | 26 #include "secure_blob.h" |
| 22 #include "tpm.h" | 27 #include "tpm.h" |
| 23 #include "username_passkey.h" | 28 #include "username_passkey.h" |
| 24 #include "vault_keyset.pb.h" | 29 #include "vault_keyset.pb.h" |
| 25 | 30 |
| 26 // Forcibly namespace the dbus-bindings generated server bindings instead of | 31 // Forcibly namespace the dbus-bindings generated server bindings instead of |
| 27 // modifying the files afterward. | 32 // modifying the files afterward. |
| 28 namespace cryptohome { // NOLINT | 33 namespace cryptohome { // NOLINT |
| 29 namespace gobject { // NOLINT | 34 namespace gobject { // NOLINT |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 default_tpm_init_(new TpmInit()), | 88 default_tpm_init_(new TpmInit()), |
| 84 tpm_init_(default_tpm_init_.get()), | 89 tpm_init_(default_tpm_init_.get()), |
| 85 default_pkcs11_init_(new Pkcs11Init()), | 90 default_pkcs11_init_(new Pkcs11Init()), |
| 86 pkcs11_init_(default_pkcs11_init_.get()), | 91 pkcs11_init_(default_pkcs11_init_.get()), |
| 87 initialize_tpm_(true), | 92 initialize_tpm_(true), |
| 88 mount_thread_(kMountThreadName), | 93 mount_thread_(kMountThreadName), |
| 89 async_complete_signal_(-1), | 94 async_complete_signal_(-1), |
| 90 tpm_init_signal_(-1), | 95 tpm_init_signal_(-1), |
| 91 event_source_(), | 96 event_source_(), |
| 92 auto_cleanup_period_(kAutoCleanupPeriodMS), | 97 auto_cleanup_period_(kAutoCleanupPeriodMS), |
| 98 default_install_attrs_(new cryptohome::InstallAttributes(NULL)), |
| 99 install_attrs_(default_install_attrs_.get()), |
| 93 update_user_activity_period_(kUpdateUserActivityPeriod - 1) { | 100 update_user_activity_period_(kUpdateUserActivityPeriod - 1) { |
| 94 } | 101 } |
| 95 | 102 |
| 96 Service::~Service() { | 103 Service::~Service() { |
| 97 if (loop_) | 104 if (loop_) |
| 98 g_main_loop_unref(loop_); | 105 g_main_loop_unref(loop_); |
| 99 if (cryptohome_) | 106 if (cryptohome_) |
| 100 g_object_unref(cryptohome_); | 107 g_object_unref(cryptohome_); |
| 101 if (mount_thread_.IsRunning()) { | 108 if (mount_thread_.IsRunning()) { |
| 102 mount_thread_.Stop(); | 109 mount_thread_.Stop(); |
| 103 } | 110 } |
| 104 } | 111 } |
| 105 | 112 |
| 106 bool Service::Initialize() { | 113 bool Service::Initialize() { |
| 107 bool result = true; | 114 bool result = true; |
| 108 | 115 |
| 109 mount_->Init(); | 116 mount_->Init(); |
| 117 // If the TPM is unowned or doesn't exist, it's safe for |
| 118 // this function to be called again. However, it shouldn't |
| 119 // be called across multiple threads in parallel. |
| 120 InitializeInstallAttributes(false); |
| 121 |
| 110 Tpm* tpm = const_cast<Tpm*>(mount_->get_crypto()->get_tpm()); | 122 Tpm* tpm = const_cast<Tpm*>(mount_->get_crypto()->get_tpm()); |
| 123 // TODO(wad) Determine if this should only be called if |
| 124 // tpm->IsEnabled() is true. |
| 111 if (tpm && initialize_tpm_) { | 125 if (tpm && initialize_tpm_) { |
| 112 tpm_init_->set_tpm(tpm); | 126 tpm_init_->set_tpm(tpm); |
| 113 tpm_init_->Init(this); | 127 tpm_init_->Init(this); |
| 114 if (!SeedUrandom()) { | 128 if (!SeedUrandom()) { |
| 115 LOG(ERROR) << "FAILED TO SEED /dev/urandom AT START"; | 129 LOG(ERROR) << "FAILED TO SEED /dev/urandom AT START"; |
| 116 } | 130 } |
| 117 } | 131 } |
| 118 | |
| 119 // Install the type-info for the service with dbus. | 132 // Install the type-info for the service with dbus. |
| 120 dbus_g_object_type_install_info(gobject::cryptohome_get_type(), | 133 dbus_g_object_type_install_info(gobject::cryptohome_get_type(), |
| 121 &gobject::dbus_glib_cryptohome_object_info); | 134 &gobject::dbus_glib_cryptohome_object_info); |
| 122 if (!Reset()) { | 135 if (!Reset()) { |
| 123 result = false; | 136 result = false; |
| 124 } | 137 } |
| 125 | 138 |
| 126 async_complete_signal_ = g_signal_new("async_call_status", | 139 async_complete_signal_ = g_signal_new("async_call_status", |
| 127 gobject::cryptohome_get_type(), | 140 gobject::cryptohome_get_type(), |
| 128 G_SIGNAL_RUN_LAST, | 141 G_SIGNAL_RUN_LAST, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 153 | 166 |
| 154 // Start scheduling periodic cleanup events. Note, that the first | 167 // Start scheduling periodic cleanup events. Note, that the first |
| 155 // event will be called by Chrome explicitly from the login screen. | 168 // event will be called by Chrome explicitly from the login screen. |
| 156 mount_thread_.message_loop()->PostDelayedTask( | 169 mount_thread_.message_loop()->PostDelayedTask( |
| 157 FROM_HERE, NewRunnableMethod(this, &Service::AutoCleanupCallback), | 170 FROM_HERE, NewRunnableMethod(this, &Service::AutoCleanupCallback), |
| 158 auto_cleanup_period_); | 171 auto_cleanup_period_); |
| 159 | 172 |
| 160 return result; | 173 return result; |
| 161 } | 174 } |
| 162 | 175 |
| 176 void Service::InitializeInstallAttributes(bool first_time) { |
| 177 Tpm* tpm = const_cast<Tpm*>(mount_->get_crypto()->get_tpm()); |
| 178 // Wait for ownership if there is a working TPM. |
| 179 if (tpm && tpm->IsEnabled() && !tpm->IsOwned()) |
| 180 return; |
| 181 |
| 182 // The TPM owning instance may have changed since initialization. |
| 183 // InstallAttributes can handle a NULL or !IsEnabled Tpm object. |
| 184 install_attrs_->SetTpm(tpm); |
| 185 |
| 186 if (first_time) |
| 187 // TODO(wad) Go nuclear if PrepareSystem fails! |
| 188 install_attrs_->PrepareSystem(); |
| 189 |
| 190 // Init can fail without making the interface inconsistent so we're okay here. |
| 191 install_attrs_->Init(); |
| 192 } |
| 193 |
| 163 bool Service::SeedUrandom() { | 194 bool Service::SeedUrandom() { |
| 164 SecureBlob random; | 195 SecureBlob random; |
| 165 if (!tpm_init_->GetRandomData(kDefaultRandomSeedLength, &random)) { | 196 if (!tpm_init_->GetRandomData(kDefaultRandomSeedLength, &random)) { |
| 166 LOG(ERROR) << "Could not get random data from the TPM"; | 197 LOG(ERROR) << "Could not get random data from the TPM"; |
| 167 return false; | 198 return false; |
| 168 } | 199 } |
| 169 size_t written = file_util::WriteFile(FilePath(kDefaultEntropySource), | 200 size_t written = file_util::WriteFile(FilePath(kDefaultEntropySource), |
| 170 static_cast<const char*>(random.const_data()), random.size()); | 201 static_cast<const char*>(random.const_data()), random.size()); |
| 171 if (written != random.size()) { | 202 if (written != random.size()) { |
| 172 LOG(ERROR) << "Error writing data to /dev/urandom"; | 203 LOG(ERROR) << "Error writing data to /dev/urandom"; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 203 | 234 |
| 204 void Service::NotifyEvent(CryptohomeEventBase* event) { | 235 void Service::NotifyEvent(CryptohomeEventBase* event) { |
| 205 if (!strcmp(event->GetEventName(), kMountTaskResultEventType)) { | 236 if (!strcmp(event->GetEventName(), kMountTaskResultEventType)) { |
| 206 MountTaskResult* result = static_cast<MountTaskResult*>(event); | 237 MountTaskResult* result = static_cast<MountTaskResult*>(event); |
| 207 g_signal_emit(cryptohome_, async_complete_signal_, 0, result->sequence_id(), | 238 g_signal_emit(cryptohome_, async_complete_signal_, 0, result->sequence_id(), |
| 208 result->return_status(), result->return_code()); | 239 result->return_status(), result->return_code()); |
| 209 } else if (!strcmp(event->GetEventName(), kTpmInitStatusEventType)) { | 240 } else if (!strcmp(event->GetEventName(), kTpmInitStatusEventType)) { |
| 210 TpmInitStatus* result = static_cast<TpmInitStatus*>(event); | 241 TpmInitStatus* result = static_cast<TpmInitStatus*>(event); |
| 211 g_signal_emit(cryptohome_, tpm_init_signal_, 0, tpm_init_->IsTpmReady(), | 242 g_signal_emit(cryptohome_, tpm_init_signal_, 0, tpm_init_->IsTpmReady(), |
| 212 tpm_init_->IsTpmEnabled(), result->get_took_ownership()); | 243 tpm_init_->IsTpmEnabled(), result->get_took_ownership()); |
| 244 // TODO(wad) should we package up a InstallAttributes status here too? |
| 213 } | 245 } |
| 214 } | 246 } |
| 215 | 247 |
| 216 void Service::InitializeTpmComplete(bool status, bool took_ownership) { | 248 void Service::InitializeTpmComplete(bool status, bool took_ownership) { |
| 217 if (took_ownership) { | 249 if (took_ownership) { |
| 218 MountTaskResult ignored_result; | 250 MountTaskResult ignored_result; |
| 219 base::WaitableEvent event(true, false); | 251 base::WaitableEvent event(true, false); |
| 220 MountTaskResetTpmContext* mount_task = | 252 MountTaskResetTpmContext* mount_task = |
| 221 new MountTaskResetTpmContext(NULL, mount_); | 253 new MountTaskResetTpmContext(NULL, mount_); |
| 222 mount_task->set_result(&ignored_result); | 254 mount_task->set_result(&ignored_result); |
| 223 mount_task->set_complete_event(&event); | 255 mount_task->set_complete_event(&event); |
| 224 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); | 256 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); |
| 225 event.Wait(); | 257 event.Wait(); |
| 258 // Initialize the install-time locked attributes since we |
| 259 // can't do it prior to ownership. |
| 260 InitializeInstallAttributes(true); |
| 226 } | 261 } |
| 227 // The event source will free this object | 262 // The event source will free this object |
| 228 TpmInitStatus* tpm_init_status = new TpmInitStatus(); | 263 TpmInitStatus* tpm_init_status = new TpmInitStatus(); |
| 229 tpm_init_status->set_status(status); | 264 tpm_init_status->set_status(status); |
| 230 tpm_init_status->set_took_ownership(took_ownership); | 265 tpm_init_status->set_took_ownership(took_ownership); |
| 231 event_source_.AddEvent(tpm_init_status); | 266 event_source_.AddEvent(tpm_init_status); |
| 232 } | 267 } |
| 233 | 268 |
| 234 gboolean Service::CheckKey(gchar *userid, | 269 gboolean Service::CheckKey(gchar *userid, |
| 235 gchar *key, | 270 gchar *key, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } else { | 396 } else { |
| 362 if (!mount_->UnmountCryptohome()) { | 397 if (!mount_->UnmountCryptohome()) { |
| 363 LOG(ERROR) << "Could not unmount cryptohome from previous user"; | 398 LOG(ERROR) << "Could not unmount cryptohome from previous user"; |
| 364 *OUT_error_code = Mount::MOUNT_ERROR_MOUNT_POINT_BUSY; | 399 *OUT_error_code = Mount::MOUNT_ERROR_MOUNT_POINT_BUSY; |
| 365 *OUT_result = FALSE; | 400 *OUT_result = FALSE; |
| 366 return TRUE; | 401 return TRUE; |
| 367 } | 402 } |
| 368 } | 403 } |
| 369 } | 404 } |
| 370 | 405 |
| 406 // Any non-guest mount attempt triggers InstallAttributes finalization. |
| 407 // The return value is ignored as it is possible we're pre-ownership. |
| 408 // The next login will assure finalization if possible. |
| 409 if (install_attrs_->is_first_install()) |
| 410 install_attrs_->Finalize(); |
| 411 |
| 371 MountTaskResult result; | 412 MountTaskResult result; |
| 372 base::WaitableEvent event(true, false); | 413 base::WaitableEvent event(true, false); |
| 373 Mount::MountArgs mount_args; | 414 Mount::MountArgs mount_args; |
| 374 mount_args.create_if_missing = create_if_missing; | 415 mount_args.create_if_missing = create_if_missing; |
| 375 MountTaskMount* mount_task = new MountTaskMount(NULL, | 416 MountTaskMount* mount_task = new MountTaskMount(NULL, |
| 376 mount_, | 417 mount_, |
| 377 credentials, | 418 credentials, |
| 378 mount_args); | 419 mount_args); |
| 379 mount_task->set_result(&result); | 420 mount_task->set_result(&result); |
| 380 mount_task->set_complete_event(&event); | 421 mount_task->set_complete_event(&event); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 410 mount_task->result()->set_return_code( | 451 mount_task->result()->set_return_code( |
| 411 Mount::MOUNT_ERROR_MOUNT_POINT_BUSY); | 452 Mount::MOUNT_ERROR_MOUNT_POINT_BUSY); |
| 412 mount_task->result()->set_return_status(false); | 453 mount_task->result()->set_return_status(false); |
| 413 *OUT_async_id = mount_task->sequence_id(); | 454 *OUT_async_id = mount_task->sequence_id(); |
| 414 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); | 455 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); |
| 415 return TRUE; | 456 return TRUE; |
| 416 } | 457 } |
| 417 } | 458 } |
| 418 } | 459 } |
| 419 | 460 |
| 461 // See Mount for a relevant comment. |
| 462 if (install_attrs_->is_first_install()) |
| 463 install_attrs_->Finalize(); |
| 464 |
| 420 Mount::MountArgs mount_args; | 465 Mount::MountArgs mount_args; |
| 421 mount_args.create_if_missing = create_if_missing; | 466 mount_args.create_if_missing = create_if_missing; |
| 422 MountTaskMount* mount_task = new MountTaskMount(this, | 467 MountTaskMount* mount_task = new MountTaskMount(this, |
| 423 mount_, | 468 mount_, |
| 424 credentials, | 469 credentials, |
| 425 mount_args); | 470 mount_args); |
| 426 *OUT_async_id = mount_task->sequence_id(); | 471 *OUT_async_id = mount_task->sequence_id(); |
| 427 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); | 472 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); |
| 428 return TRUE; | 473 return TRUE; |
| 429 } | 474 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 } | 623 } |
| 579 | 624 |
| 580 gboolean Service::Pkcs11GetTpmTokenInfo(gchar** OUT_label, | 625 gboolean Service::Pkcs11GetTpmTokenInfo(gchar** OUT_label, |
| 581 gchar** OUT_user_pin, | 626 gchar** OUT_user_pin, |
| 582 GError** error) { | 627 GError** error) { |
| 583 pkcs11_init_->GetTpmTokenInfo(OUT_label, | 628 pkcs11_init_->GetTpmTokenInfo(OUT_label, |
| 584 OUT_user_pin); | 629 OUT_user_pin); |
| 585 return TRUE; | 630 return TRUE; |
| 586 } | 631 } |
| 587 | 632 |
| 633 gboolean Service::InstallAttributesGet(gchar* name, |
| 634 GArray** OUT_value, |
| 635 gboolean* OUT_successful, |
| 636 GError** error) { |
| 637 chromeos::Blob value; |
| 638 *OUT_successful = install_attrs_->Get(name, &value); |
| 639 // TODO(wad) can g_array_new return NULL. |
| 640 *OUT_value = g_array_new(false, false, sizeof(char)); |
| 641 if (*OUT_successful) |
| 642 g_array_append_vals(*OUT_value, &value.front(), value.size()); |
| 643 return TRUE; |
| 644 } |
| 645 |
| 646 gboolean Service::InstallAttributesSet(gchar* name, |
| 647 GArray* value, |
| 648 gboolean* OUT_successful, |
| 649 GError** error) { |
| 650 // Convert from GArray to vector |
| 651 chromeos::Blob value_blob; |
| 652 value_blob.assign(value->data, value->data + value->len); |
| 653 *OUT_successful = install_attrs_->Set(name, value_blob); |
| 654 return TRUE; |
| 655 } |
| 656 |
| 657 gboolean Service::InstallAttributesFinalize(gboolean* OUT_finalized, |
| 658 GError** error) { |
| 659 *OUT_finalized = install_attrs_->Finalize(); |
| 660 return TRUE; |
| 661 } |
| 662 |
| 663 gboolean Service::InstallAttributesCount(gint* OUT_count, GError** error) { |
| 664 // TODO(wad) for all of these functions return error on uninit. |
| 665 // Follow the CHROMEOS_LOGIN_ERROR quark example in chromeos/dbus/ |
| 666 *OUT_count = install_attrs_->Count(); |
| 667 return TRUE; |
| 668 } |
| 669 |
| 670 gboolean Service::InstallAttributesIsReady(gboolean* OUT_ready, |
| 671 GError** error) { |
| 672 *OUT_ready = (install_attrs_->IsReady() == true); |
| 673 return TRUE; |
| 674 } |
| 675 |
| 676 gboolean Service::InstallAttributesIsSecure(gboolean* OUT_is_secure, |
| 677 GError** error) { |
| 678 *OUT_is_secure = (install_attrs_->is_secure() == true); |
| 679 return TRUE; |
| 680 } |
| 681 |
| 682 gboolean Service::InstallAttributesIsInvalid(gboolean* OUT_is_invalid, |
| 683 GError** error) { |
| 684 // Is true after a failed init or prior to Init(). |
| 685 *OUT_is_invalid = (install_attrs_->is_invalid() == true); |
| 686 return TRUE; |
| 687 } |
| 688 |
| 689 gboolean Service::InstallAttributesIsFirstInstall( |
| 690 gboolean* OUT_is_first_install, |
| 691 GError** error) { |
| 692 *OUT_is_first_install = (install_attrs_->is_first_install() == true); |
| 693 return TRUE; |
| 694 } |
| 695 |
| 588 gboolean Service::GetStatusString(gchar** OUT_status, GError** error) { | 696 gboolean Service::GetStatusString(gchar** OUT_status, GError** error) { |
| 589 Tpm::TpmStatusInfo tpm_status; | 697 Tpm::TpmStatusInfo tpm_status; |
| 590 mount_->get_crypto()->EnsureTpm(false); | 698 mount_->get_crypto()->EnsureTpm(false); |
| 591 Tpm* tpm = const_cast<Tpm*>(mount_->get_crypto()->get_tpm()); | 699 Tpm* tpm = const_cast<Tpm*>(mount_->get_crypto()->get_tpm()); |
| 592 | 700 |
| 593 if (tpm) { | 701 if (tpm) { |
| 594 tpm->GetStatus(true, &tpm_status); | 702 tpm->GetStatus(true, &tpm_status); |
| 595 } else { | 703 } else { |
| 596 Tpm::GetSingleton()->GetStatus(true, &tpm_status); | 704 Tpm::GetSingleton()->GetStatus(true, &tpm_status); |
| 597 } | 705 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 " (UTC)\n", | 746 " (UTC)\n", |
| 639 ((serialized.flags() & | 747 ((serialized.flags() & |
| 640 cryptohome::SerializedVaultKeyset::TPM_WRAPPED) ? "1" : "0"), | 748 cryptohome::SerializedVaultKeyset::TPM_WRAPPED) ? "1" : "0"), |
| 641 ((serialized.flags() & | 749 ((serialized.flags() & |
| 642 cryptohome::SerializedVaultKeyset::SCRYPT_WRAPPED) ? "1" : "0"), | 750 cryptohome::SerializedVaultKeyset::SCRYPT_WRAPPED) ? "1" : "0"), |
| 643 exploded.month, exploded.day_of_month, exploded.year, | 751 exploded.month, exploded.day_of_month, exploded.year, |
| 644 exploded.hour, exploded.minute, exploded.second); | 752 exploded.hour, exploded.minute, exploded.second); |
| 645 | 753 |
| 646 } while(false); | 754 } while(false); |
| 647 } | 755 } |
| 756 int install_attrs_size = install_attrs_->Count(); |
| 757 std::string install_attrs_data("InstallAttributes Contents:\n"); |
| 758 if (install_attrs_->Count()) { |
| 759 std::string name; |
| 760 chromeos::Blob value; |
| 761 for (int pair = 0; pair < install_attrs_size; ++pair) { |
| 762 install_attrs_data.append(StringPrintf( |
| 763 " Index...........................: %d\n", pair)); |
| 764 if (install_attrs_->GetByIndex(pair, &name, &value)) { |
| 765 std::string value_str(reinterpret_cast<const char*>(&value[0]), |
| 766 value.size()); |
| 767 install_attrs_data.append(StringPrintf( |
| 768 " Name............................: %s\n" |
| 769 " Value...........................: %s\n", |
| 770 name.c_str(), |
| 771 value_str.c_str())); |
| 772 } |
| 773 } |
| 774 } |
| 648 | 775 |
| 649 *OUT_status = g_strdup_printf( | 776 *OUT_status = g_strdup_printf( |
| 650 "TPM Status:\n" | 777 "TPM Status:\n" |
| 651 " Enabled.........................: %s\n" | 778 " Enabled.........................: %s\n" |
| 652 " Owned...........................: %s\n" | 779 " Owned...........................: %s\n" |
| 653 " Being Owned.....................: %s\n" | 780 " Being Owned.....................: %s\n" |
| 654 " Can Connect.....................: %s\n" | 781 " Can Connect.....................: %s\n" |
| 655 " Can Load SRK....................: %s\n" | 782 " Can Load SRK....................: %s\n" |
| 656 " Can Load SRK Public.............: %s\n" | 783 " Can Load SRK Public.............: %s\n" |
| 657 " Has Cryptohome Key..............: %s\n" | 784 " Has Cryptohome Key..............: %s\n" |
| 658 " Can Encrypt.....................: %s\n" | 785 " Can Encrypt.....................: %s\n" |
| 659 " Can Decrypt.....................: %s\n" | 786 " Can Decrypt.....................: %s\n" |
| 660 " Instance Context................: %s\n" | 787 " Instance Context................: %s\n" |
| 661 " Instance Key Handle.............: %s\n" | 788 " Instance Key Handle.............: %s\n" |
| 662 " Last Error......................: %08x\n" | 789 " Last Error......................: %08x\n" |
| 663 "%s" | 790 "%s" |
| 664 "Mount Status:\n" | 791 "Mount Status:\n" |
| 665 " Vault Is Mounted................: %s\n", | 792 " Vault Is Mounted................: %s\n" |
| 793 "InstallAttributes Status:\n" |
| 794 " Initialized.....................: %s\n" |
| 795 " Version.........................: %"PRIx64"\n" |
| 796 " Lockbox Index...................: 0x%x\n" |
| 797 " Secure..........................: %s\n" |
| 798 " Invalid.........................: %s\n" |
| 799 " First Install / Unlocked........: %s\n" |
| 800 " Entries.........................: %d\n" |
| 801 "%s", |
| 666 (tpm_status.Enabled ? "1" : "0"), | 802 (tpm_status.Enabled ? "1" : "0"), |
| 667 (tpm_status.Owned ? "1" : "0"), | 803 (tpm_status.Owned ? "1" : "0"), |
| 668 (tpm_status.BeingOwned ? "1" : "0"), | 804 (tpm_status.BeingOwned ? "1" : "0"), |
| 669 (tpm_status.CanConnect ? "1" : "0"), | 805 (tpm_status.CanConnect ? "1" : "0"), |
| 670 (tpm_status.CanLoadSrk ? "1" : "0"), | 806 (tpm_status.CanLoadSrk ? "1" : "0"), |
| 671 (tpm_status.CanLoadSrkPublicKey ? "1" : "0"), | 807 (tpm_status.CanLoadSrkPublicKey ? "1" : "0"), |
| 672 (tpm_status.HasCryptohomeKey ? "1" : "0"), | 808 (tpm_status.HasCryptohomeKey ? "1" : "0"), |
| 673 (tpm_status.CanEncrypt ? "1" : "0"), | 809 (tpm_status.CanEncrypt ? "1" : "0"), |
| 674 (tpm_status.CanDecrypt ? "1" : "0"), | 810 (tpm_status.CanDecrypt ? "1" : "0"), |
| 675 (tpm_status.ThisInstanceHasContext ? "1" : "0"), | 811 (tpm_status.ThisInstanceHasContext ? "1" : "0"), |
| 676 (tpm_status.ThisInstanceHasKeyHandle ? "1" : "0"), | 812 (tpm_status.ThisInstanceHasKeyHandle ? "1" : "0"), |
| 677 tpm_status.LastTpmError, | 813 tpm_status.LastTpmError, |
| 678 user_data.c_str(), | 814 user_data.c_str(), |
| 679 (mount_->IsCryptohomeMounted() ? "1" : "0")); | 815 (mount_->IsCryptohomeMounted() ? "1" : "0"), |
| 816 (install_attrs_->is_initialized() ? "1" : "0"), |
| 817 install_attrs_->version(), |
| 818 InstallAttributes::kLockboxIndex, |
| 819 (install_attrs_->is_secure() ? "1" : "0"), |
| 820 (install_attrs_->is_invalid() ? "1" : "0"), |
| 821 (install_attrs_->is_first_install() ? "1" : "0"), |
| 822 install_attrs_size, |
| 823 install_attrs_data.c_str()); |
| 680 return TRUE; | 824 return TRUE; |
| 681 } | 825 } |
| 682 | 826 |
| 683 // Called on Mount thread. | 827 // Called on Mount thread. |
| 684 void Service::AutoCleanupCallback() { | 828 void Service::AutoCleanupCallback() { |
| 685 static int ticks; | 829 static int ticks; |
| 686 | 830 |
| 687 // Update current user's activity timestamp every day. | 831 // Update current user's activity timestamp every day. |
| 688 if (++ticks > update_user_activity_period_) { | 832 if (++ticks > update_user_activity_period_) { |
| 689 mount_->UpdateUserActivityTimestamp(); | 833 mount_->UpdateUserActivityTimestamp(); |
| 690 ticks = 0; | 834 ticks = 0; |
| 691 } | 835 } |
| 692 | 836 |
| 693 mount_->DoAutomaticFreeDiskSpaceControl(); | 837 mount_->DoAutomaticFreeDiskSpaceControl(); |
| 694 | 838 |
| 695 // Schedule our next call. If the thread is terminating, we would | 839 // Schedule our next call. If the thread is terminating, we would |
| 696 // not be called. | 840 // not be called. |
| 697 mount_thread_.message_loop()->PostDelayedTask( | 841 mount_thread_.message_loop()->PostDelayedTask( |
| 698 FROM_HERE, NewRunnableMethod(this, &Service::AutoCleanupCallback), | 842 FROM_HERE, NewRunnableMethod(this, &Service::AutoCleanupCallback), |
| 699 auto_cleanup_period_); | 843 auto_cleanup_period_); |
| 700 } | 844 } |
| 701 | 845 |
| 702 } // namespace cryptohome | 846 } // namespace cryptohome |
| 703 | 847 |
| 704 // We do not want AutoCleanupCallback() to refer the class and make it | 848 // We do not want AutoCleanupCallback() to refer the class and make it |
| 705 // wait for its execution. If Mount thread terminates, it will delete | 849 // wait for its execution. If Mount thread terminates, it will delete |
| 706 // our pending task or wait for it to finish. | 850 // our pending task or wait for it to finish. |
| 707 DISABLE_RUNNABLE_METHOD_REFCOUNT(cryptohome::Service); | 851 DISABLE_RUNNABLE_METHOD_REFCOUNT(cryptohome::Service); |
| OLD | NEW |