Commit ed12c7da authored by Kazuhiro Inaba's avatar Kazuhiro Inaba Committed by Commit Bot

cryptohome: Do not ignore the system slot id returned by GetTpmTokenSlotForPath

When TPM/chaps is not fully initialized, the method returns -1 and Chrome should
attempt a retry later. The existing implementation overwrote the slot id always
by 0 and as a result disabled the retry, leading to a failure on establishing
the device ownership on certain cases.

BUG=b/37259691
TEST=`cros flash ssh://dut xbuddy://remote/samus/R61-9693.0.0/test;
 test_that --args="value='samus-release/R61-9694.0.0'" provision_AutoUpdate;
 test_that cheets_StartAndroid` > "Manage other people" setting is modifiable.

Change-Id: I9ebb731ba8004a61a9d868f3e586fe32d1979ab9
Reviewed-on: https://chromium-review.googlesource.com/558528Reviewed-by: default avatarMatt Mueller <mattm@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Commit-Queue: Kazuhiro Inaba <kinaba@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487409}
parent c96de186
...@@ -399,11 +399,9 @@ class CryptohomeClientImpl : public CryptohomeClient { ...@@ -399,11 +399,9 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
writer.AppendString(cryptohome_id.id()); writer.AppendString(cryptohome_id.id());
proxy_->CallMethod( proxy_->CallMethod(
&method_call, kTpmDBusTimeoutMs , &method_call, kTpmDBusTimeoutMs,
base::Bind( base::Bind(&CryptohomeClientImpl::OnPkcs11GetTpmTokenInfo,
&CryptohomeClientImpl::OnPkcs11GetTpmTokenInfoForUser, weak_ptr_factory_.GetWeakPtr(), callback));
weak_ptr_factory_.GetWeakPtr(),
callback));
} }
// CryptohomeClient override. // CryptohomeClient override.
...@@ -1136,7 +1134,8 @@ class CryptohomeClientImpl : public CryptohomeClient { ...@@ -1136,7 +1134,8 @@ class CryptohomeClientImpl : public CryptohomeClient {
callback.Run(DBUS_METHOD_CALL_SUCCESS, true, reply); callback.Run(DBUS_METHOD_CALL_SUCCESS, true, reply);
} }
// Handles responses for Pkcs11GetTpmTokenInfo. // Handles responses for Pkcs11GetTpmTokenInfo and
// Pkcs11GetTpmTokenInfoForUser.
void OnPkcs11GetTpmTokenInfo(const Pkcs11GetTpmTokenInfoCallback& callback, void OnPkcs11GetTpmTokenInfo(const Pkcs11GetTpmTokenInfoCallback& callback,
dbus::Response* response) { dbus::Response* response) {
if (!response) { if (!response) {
...@@ -1146,26 +1145,6 @@ class CryptohomeClientImpl : public CryptohomeClient { ...@@ -1146,26 +1145,6 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageReader reader(response); dbus::MessageReader reader(response);
std::string label; std::string label;
std::string user_pin; std::string user_pin;
if (!reader.PopString(&label) || !reader.PopString(&user_pin)) {
callback.Run(DBUS_METHOD_CALL_FAILURE, std::string(), std::string(), -1);
LOG(ERROR) << "Invalid response: " << response->ToString();
return;
}
const int kDefaultSlot = 0;
callback.Run(DBUS_METHOD_CALL_SUCCESS, label, user_pin, kDefaultSlot);
}
// Handles responses for Pkcs11GetTpmTokenInfoForUser.
void OnPkcs11GetTpmTokenInfoForUser(
const Pkcs11GetTpmTokenInfoCallback& callback,
dbus::Response* response) {
if (!response) {
callback.Run(DBUS_METHOD_CALL_FAILURE, std::string(), std::string(), -1);
return;
}
dbus::MessageReader reader(response);
std::string label;
std::string user_pin;
int slot = 0; int slot = 0;
if (!reader.PopString(&label) || !reader.PopString(&user_pin) || if (!reader.PopString(&label) || !reader.PopString(&user_pin) ||
!reader.PopInt32(&slot)) { !reader.PopInt32(&slot)) {
......
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