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

Side by Side Diff: service.cc

Issue 6801020: service,cryptohome: wire up lockbox to dbus (Closed)
Patch Set: auto-Finalization on Mount Created 9 years, 8 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
« service.h ('K') | « service.h ('k') | service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 // The TPM wasn't set during construction so force it now.
179 // This is also needed if the instance is changed by ownership.
180 if (tpm && tpm->IsEnabled()) {
181 install_attrs_->set_tpm(tpm);
182 if (!tpm->IsOwned())
183 return; // wait for ownership.
184 }
185 if (first_time)
186 install_attrs_->PrepareSystem();
187 // Even if the initialization fails, the baseline interface will not fail
188 // spectacularly.
189 install_attrs_->Init();
190 }
191
163 bool Service::SeedUrandom() { 192 bool Service::SeedUrandom() {
164 SecureBlob random; 193 SecureBlob random;
165 if (!tpm_init_->GetRandomData(kDefaultRandomSeedLength, &random)) { 194 if (!tpm_init_->GetRandomData(kDefaultRandomSeedLength, &random)) {
166 LOG(ERROR) << "Could not get random data from the TPM"; 195 LOG(ERROR) << "Could not get random data from the TPM";
167 return false; 196 return false;
168 } 197 }
169 size_t written = file_util::WriteFile(FilePath(kDefaultEntropySource), 198 size_t written = file_util::WriteFile(FilePath(kDefaultEntropySource),
170 static_cast<const char*>(random.const_data()), random.size()); 199 static_cast<const char*>(random.const_data()), random.size());
171 if (written != random.size()) { 200 if (written != random.size()) {
172 LOG(ERROR) << "Error writing data to /dev/urandom"; 201 LOG(ERROR) << "Error writing data to /dev/urandom";
(...skipping 30 matching lines...) Expand all
203 232
204 void Service::NotifyEvent(CryptohomeEventBase* event) { 233 void Service::NotifyEvent(CryptohomeEventBase* event) {
205 if (!strcmp(event->GetEventName(), kMountTaskResultEventType)) { 234 if (!strcmp(event->GetEventName(), kMountTaskResultEventType)) {
206 MountTaskResult* result = static_cast<MountTaskResult*>(event); 235 MountTaskResult* result = static_cast<MountTaskResult*>(event);
207 g_signal_emit(cryptohome_, async_complete_signal_, 0, result->sequence_id(), 236 g_signal_emit(cryptohome_, async_complete_signal_, 0, result->sequence_id(),
208 result->return_status(), result->return_code()); 237 result->return_status(), result->return_code());
209 } else if (!strcmp(event->GetEventName(), kTpmInitStatusEventType)) { 238 } else if (!strcmp(event->GetEventName(), kTpmInitStatusEventType)) {
210 TpmInitStatus* result = static_cast<TpmInitStatus*>(event); 239 TpmInitStatus* result = static_cast<TpmInitStatus*>(event);
211 g_signal_emit(cryptohome_, tpm_init_signal_, 0, tpm_init_->IsTpmReady(), 240 g_signal_emit(cryptohome_, tpm_init_signal_, 0, tpm_init_->IsTpmReady(),
212 tpm_init_->IsTpmEnabled(), result->get_took_ownership()); 241 tpm_init_->IsTpmEnabled(), result->get_took_ownership());
242 // TODO(wad) should we package up a InstallAttributes status here too?
213 } 243 }
214 } 244 }
215 245
216 void Service::InitializeTpmComplete(bool status, bool took_ownership) { 246 void Service::InitializeTpmComplete(bool status, bool took_ownership) {
217 if (took_ownership) { 247 if (took_ownership) {
218 MountTaskResult ignored_result; 248 MountTaskResult ignored_result;
219 base::WaitableEvent event(true, false); 249 base::WaitableEvent event(true, false);
220 MountTaskResetTpmContext* mount_task = 250 MountTaskResetTpmContext* mount_task =
221 new MountTaskResetTpmContext(NULL, mount_); 251 new MountTaskResetTpmContext(NULL, mount_);
222 mount_task->set_result(&ignored_result); 252 mount_task->set_result(&ignored_result);
223 mount_task->set_complete_event(&event); 253 mount_task->set_complete_event(&event);
224 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); 254 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task);
225 event.Wait(); 255 event.Wait();
256 // Initialize the install-time locked attributes since we
257 // can't do it prior to ownership.
258 InitializeInstallAttributes(true);
226 } 259 }
227 // The event source will free this object 260 // The event source will free this object
228 TpmInitStatus* tpm_init_status = new TpmInitStatus(); 261 TpmInitStatus* tpm_init_status = new TpmInitStatus();
229 tpm_init_status->set_status(status); 262 tpm_init_status->set_status(status);
230 tpm_init_status->set_took_ownership(took_ownership); 263 tpm_init_status->set_took_ownership(took_ownership);
231 event_source_.AddEvent(tpm_init_status); 264 event_source_.AddEvent(tpm_init_status);
232 } 265 }
233 266
234 gboolean Service::CheckKey(gchar *userid, 267 gboolean Service::CheckKey(gchar *userid,
235 gchar *key, 268 gchar *key,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } else { 394 } else {
362 if (!mount_->UnmountCryptohome()) { 395 if (!mount_->UnmountCryptohome()) {
363 LOG(ERROR) << "Could not unmount cryptohome from previous user"; 396 LOG(ERROR) << "Could not unmount cryptohome from previous user";
364 *OUT_error_code = Mount::MOUNT_ERROR_MOUNT_POINT_BUSY; 397 *OUT_error_code = Mount::MOUNT_ERROR_MOUNT_POINT_BUSY;
365 *OUT_result = FALSE; 398 *OUT_result = FALSE;
366 return TRUE; 399 return TRUE;
367 } 400 }
368 } 401 }
369 } 402 }
370 403
404 // Any non-guest mount attempt triggers InstallAttributes finalization.
405 // The return value is ignored as it is possible we're pre-ownership.
406 // The next login will assure finalization if possible.
407 if (install_attrs_->is_first_install())
408 install_attrs_->Finalize();
409
371 MountTaskResult result; 410 MountTaskResult result;
372 base::WaitableEvent event(true, false); 411 base::WaitableEvent event(true, false);
373 Mount::MountArgs mount_args; 412 Mount::MountArgs mount_args;
374 mount_args.create_if_missing = create_if_missing; 413 mount_args.create_if_missing = create_if_missing;
375 MountTaskMount* mount_task = new MountTaskMount(NULL, 414 MountTaskMount* mount_task = new MountTaskMount(NULL,
376 mount_, 415 mount_,
377 credentials, 416 credentials,
378 mount_args); 417 mount_args);
379 mount_task->set_result(&result); 418 mount_task->set_result(&result);
380 mount_task->set_complete_event(&event); 419 mount_task->set_complete_event(&event);
(...skipping 29 matching lines...) Expand all
410 mount_task->result()->set_return_code( 449 mount_task->result()->set_return_code(
411 Mount::MOUNT_ERROR_MOUNT_POINT_BUSY); 450 Mount::MOUNT_ERROR_MOUNT_POINT_BUSY);
412 mount_task->result()->set_return_status(false); 451 mount_task->result()->set_return_status(false);
413 *OUT_async_id = mount_task->sequence_id(); 452 *OUT_async_id = mount_task->sequence_id();
414 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); 453 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task);
415 return TRUE; 454 return TRUE;
416 } 455 }
417 } 456 }
418 } 457 }
419 458
459 // See Mount for a relevant comment.
460 if (install_attrs_->is_first_install())
461 install_attrs_->Finalize();
462
420 Mount::MountArgs mount_args; 463 Mount::MountArgs mount_args;
421 mount_args.create_if_missing = create_if_missing; 464 mount_args.create_if_missing = create_if_missing;
422 MountTaskMount* mount_task = new MountTaskMount(this, 465 MountTaskMount* mount_task = new MountTaskMount(this,
423 mount_, 466 mount_,
424 credentials, 467 credentials,
425 mount_args); 468 mount_args);
426 *OUT_async_id = mount_task->sequence_id(); 469 *OUT_async_id = mount_task->sequence_id();
427 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task); 470 mount_thread_.message_loop()->PostTask(FROM_HERE, mount_task);
428 return TRUE; 471 return TRUE;
429 } 472 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 621 }
579 622
580 gboolean Service::Pkcs11GetTpmTokenInfo(gchar** OUT_label, 623 gboolean Service::Pkcs11GetTpmTokenInfo(gchar** OUT_label,
581 gchar** OUT_user_pin, 624 gchar** OUT_user_pin,
582 GError** error) { 625 GError** error) {
583 pkcs11_init_->GetTpmTokenInfo(OUT_label, 626 pkcs11_init_->GetTpmTokenInfo(OUT_label,
584 OUT_user_pin); 627 OUT_user_pin);
585 return TRUE; 628 return TRUE;
586 } 629 }
587 630
631 gboolean Service::InstallAttributesGet(gchar* name,
632 GArray** OUT_value,
633 gboolean* OUT_successful,
634 GError** error) {
635 chromeos::Blob value;
636 *OUT_successful = install_attrs_->Get(name, &value);
637 *OUT_value = g_array_new(false, false, sizeof(char));
638 if (*OUT_successful)
639 g_array_append_vals(*OUT_value, &value.front(), value.size());
640 return TRUE;
641 }
642
643 gboolean Service::InstallAttributesSet(gchar* name,
644 GArray* value,
645 gboolean* OUT_successful,
646 GError** error) {
647 // Convert from GArray to vector
648 chromeos::Blob value_blob;
649 value_blob.assign(value->data, value->data + value->len);
650 *OUT_successful = install_attrs_->Set(name, value_blob);
651 return TRUE;
652 }
653
654 gboolean Service::InstallAttributesFinalize(gboolean* OUT_finalized,
655 GError** error) {
656 *OUT_finalized = install_attrs_->Finalize();
657 return TRUE;
658 }
659
660 gboolean Service::InstallAttributesCount(gint* OUT_count, GError** error) {
661 // TODO(wad) for all of these functions return error on uninit.
662 // Follow the CHROMEOS_LOGIN_ERROR quark example in chromeos/dbus/
663 *OUT_count = install_attrs_->Count();
664 return TRUE;
665 }
666
667 gboolean Service::InstallAttributesIsReady(gboolean* OUT_ready,
668 GError** error) {
669 *OUT_ready = (install_attrs_->is_initialized() == true);
670 return TRUE;
671 }
672
673 gboolean Service::InstallAttributesIsSecure(gboolean* OUT_is_secure,
674 GError** error) {
675 *OUT_is_secure = (install_attrs_->is_secure() == true);
676 return TRUE;
677 }
678
679 gboolean Service::InstallAttributesIsInvalid(gboolean* OUT_is_invalid,
680 GError** error) {
681 // Is true after a failed init or prior to Init().
682 *OUT_is_invalid = (install_attrs_->is_invalid() == true);
683 return TRUE;
684 }
685
686 gboolean Service::InstallAttributesIsFirstInstall(
687 gboolean* OUT_is_first_install,
688 GError** error) {
689 *OUT_is_first_install = (install_attrs_->is_first_install() == true);
690 return TRUE;
691 }
692
588 gboolean Service::GetStatusString(gchar** OUT_status, GError** error) { 693 gboolean Service::GetStatusString(gchar** OUT_status, GError** error) {
589 Tpm::TpmStatusInfo tpm_status; 694 Tpm::TpmStatusInfo tpm_status;
590 mount_->get_crypto()->EnsureTpm(false); 695 mount_->get_crypto()->EnsureTpm(false);
591 Tpm* tpm = const_cast<Tpm*>(mount_->get_crypto()->get_tpm()); 696 Tpm* tpm = const_cast<Tpm*>(mount_->get_crypto()->get_tpm());
592 697
593 if (tpm) { 698 if (tpm) {
594 tpm->GetStatus(true, &tpm_status); 699 tpm->GetStatus(true, &tpm_status);
595 } else { 700 } else {
596 Tpm::GetSingleton()->GetStatus(true, &tpm_status); 701 Tpm::GetSingleton()->GetStatus(true, &tpm_status);
597 } 702 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 " (UTC)\n", 743 " (UTC)\n",
639 ((serialized.flags() & 744 ((serialized.flags() &
640 cryptohome::SerializedVaultKeyset::TPM_WRAPPED) ? "1" : "0"), 745 cryptohome::SerializedVaultKeyset::TPM_WRAPPED) ? "1" : "0"),
641 ((serialized.flags() & 746 ((serialized.flags() &
642 cryptohome::SerializedVaultKeyset::SCRYPT_WRAPPED) ? "1" : "0"), 747 cryptohome::SerializedVaultKeyset::SCRYPT_WRAPPED) ? "1" : "0"),
643 exploded.month, exploded.day_of_month, exploded.year, 748 exploded.month, exploded.day_of_month, exploded.year,
644 exploded.hour, exploded.minute, exploded.second); 749 exploded.hour, exploded.minute, exploded.second);
645 750
646 } while(false); 751 } while(false);
647 } 752 }
753 int install_attrs_size = install_attrs_->Count();
754 std::string install_attrs_data("InstallAttributes Contents:\n");
755 if (install_attrs_->Count()) {
756 std::string name;
757 chromeos::Blob value;
758 for (int pair = 0; pair < install_attrs_size; ++pair) {
759 install_attrs_data.append(StringPrintf(
760 " Index...........................: %d\n", pair));
761 if (install_attrs_->GetByIndex(pair, &name, &value)) {
762 std::string value_str(reinterpret_cast<const char*>(&value[0]),
763 value.size());
764 install_attrs_data.append(StringPrintf(
765 " Name............................: %s\n"
766 " Value...........................: %s\n",
767 name.c_str(),
768 value_str.c_str()));
769 }
770 }
771 }
648 772
649 *OUT_status = g_strdup_printf( 773 *OUT_status = g_strdup_printf(
650 "TPM Status:\n" 774 "TPM Status:\n"
651 " Enabled.........................: %s\n" 775 " Enabled.........................: %s\n"
652 " Owned...........................: %s\n" 776 " Owned...........................: %s\n"
653 " Being Owned.....................: %s\n" 777 " Being Owned.....................: %s\n"
654 " Can Connect.....................: %s\n" 778 " Can Connect.....................: %s\n"
655 " Can Load SRK....................: %s\n" 779 " Can Load SRK....................: %s\n"
656 " Can Load SRK Public.............: %s\n" 780 " Can Load SRK Public.............: %s\n"
657 " Has Cryptohome Key..............: %s\n" 781 " Has Cryptohome Key..............: %s\n"
658 " Can Encrypt.....................: %s\n" 782 " Can Encrypt.....................: %s\n"
659 " Can Decrypt.....................: %s\n" 783 " Can Decrypt.....................: %s\n"
660 " Instance Context................: %s\n" 784 " Instance Context................: %s\n"
661 " Instance Key Handle.............: %s\n" 785 " Instance Key Handle.............: %s\n"
662 " Last Error......................: %08x\n" 786 " Last Error......................: %08x\n"
663 "%s" 787 "%s"
664 "Mount Status:\n" 788 "Mount Status:\n"
665 " Vault Is Mounted................: %s\n", 789 " Vault Is Mounted................: %s\n"
790 "InstallAttributes Status:\n"
791 " Initialized.....................: %s\n"
792 " Version.........................: %"PRIx64"\n"
793 " Lockbox ID......................: %u\n"
794 " Secure..........................: %s\n"
795 " Invalid.........................: %s\n"
796 " First Install / Unlocked........: %s\n"
797 " Entries.........................: %d\n"
798 "%s",
666 (tpm_status.Enabled ? "1" : "0"), 799 (tpm_status.Enabled ? "1" : "0"),
667 (tpm_status.Owned ? "1" : "0"), 800 (tpm_status.Owned ? "1" : "0"),
668 (tpm_status.BeingOwned ? "1" : "0"), 801 (tpm_status.BeingOwned ? "1" : "0"),
669 (tpm_status.CanConnect ? "1" : "0"), 802 (tpm_status.CanConnect ? "1" : "0"),
670 (tpm_status.CanLoadSrk ? "1" : "0"), 803 (tpm_status.CanLoadSrk ? "1" : "0"),
671 (tpm_status.CanLoadSrkPublicKey ? "1" : "0"), 804 (tpm_status.CanLoadSrkPublicKey ? "1" : "0"),
672 (tpm_status.HasCryptohomeKey ? "1" : "0"), 805 (tpm_status.HasCryptohomeKey ? "1" : "0"),
673 (tpm_status.CanEncrypt ? "1" : "0"), 806 (tpm_status.CanEncrypt ? "1" : "0"),
674 (tpm_status.CanDecrypt ? "1" : "0"), 807 (tpm_status.CanDecrypt ? "1" : "0"),
675 (tpm_status.ThisInstanceHasContext ? "1" : "0"), 808 (tpm_status.ThisInstanceHasContext ? "1" : "0"),
676 (tpm_status.ThisInstanceHasKeyHandle ? "1" : "0"), 809 (tpm_status.ThisInstanceHasKeyHandle ? "1" : "0"),
677 tpm_status.LastTpmError, 810 tpm_status.LastTpmError,
678 user_data.c_str(), 811 user_data.c_str(),
679 (mount_->IsCryptohomeMounted() ? "1" : "0")); 812 (mount_->IsCryptohomeMounted() ? "1" : "0"),
813 (install_attrs_->is_initialized() ? "1" : "0"),
814 install_attrs_->version(),
815 install_attrs_->lockbox_id(),
816 (install_attrs_->is_secure() ? "1" : "0"),
817 (install_attrs_->is_invalid() ? "1" : "0"),
818 (install_attrs_->is_first_install() ? "1" : "0"),
819 install_attrs_size,
820 install_attrs_data.c_str());
680 return TRUE; 821 return TRUE;
681 } 822 }
682 823
683 // Called on Mount thread. 824 // Called on Mount thread.
684 void Service::AutoCleanupCallback() { 825 void Service::AutoCleanupCallback() {
685 static int ticks; 826 static int ticks;
686 827
687 // Update current user's activity timestamp every day. 828 // Update current user's activity timestamp every day.
688 if (++ticks > update_user_activity_period_) { 829 if (++ticks > update_user_activity_period_) {
689 mount_->UpdateUserActivityTimestamp(); 830 mount_->UpdateUserActivityTimestamp();
690 ticks = 0; 831 ticks = 0;
691 } 832 }
692 833
693 mount_->DoAutomaticFreeDiskSpaceControl(); 834 mount_->DoAutomaticFreeDiskSpaceControl();
694 835
695 // Schedule our next call. If the thread is terminating, we would 836 // Schedule our next call. If the thread is terminating, we would
696 // not be called. 837 // not be called.
697 mount_thread_.message_loop()->PostDelayedTask( 838 mount_thread_.message_loop()->PostDelayedTask(
698 FROM_HERE, NewRunnableMethod(this, &Service::AutoCleanupCallback), 839 FROM_HERE, NewRunnableMethod(this, &Service::AutoCleanupCallback),
699 auto_cleanup_period_); 840 auto_cleanup_period_);
700 } 841 }
701 842
702 } // namespace cryptohome 843 } // namespace cryptohome
703 844
704 // We do not want AutoCleanupCallback() to refer the class and make it 845 // We do not want AutoCleanupCallback() to refer the class and make it
705 // wait for its execution. If Mount thread terminates, it will delete 846 // wait for its execution. If Mount thread terminates, it will delete
706 // our pending task or wait for it to finish. 847 // our pending task or wait for it to finish.
707 DISABLE_RUNNABLE_METHOD_REFCOUNT(cryptohome::Service); 848 DISABLE_RUNNABLE_METHOD_REFCOUNT(cryptohome::Service);
OLDNEW
« service.h ('K') | « service.h ('k') | service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698