Commit 7f579bfc authored by Leo Lai's avatar Leo Lai Committed by Chromium LUCI CQ

SessionTerminationManager query GetLoginStatus instead of GetTpmStatus

We are deprecating GetTpmStatus APIs by cryptohome.
Also, GetLoginStatus is a better fit to reporting "lock to single user"
status.

BUG=b:172748724
TEST=unit_tests.

Cq-Depend: chromium:2586412
Change-Id: I096e09c8ecbc670b03f375f059f70d466f8839e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586414
Commit-Queue: Leo Lai <cylai@google.com>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836529}
parent b0c1d50f
...@@ -404,6 +404,19 @@ class CryptohomeClientImpl : public CryptohomeClient { ...@@ -404,6 +404,19 @@ class CryptohomeClientImpl : public CryptohomeClient {
return CallBoolMethodAndBlock(&method_call, is_first_install); return CallBoolMethodAndBlock(&method_call, is_first_install);
} }
void GetLoginStatus(
const cryptohome::GetLoginStatusRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeGetLoginStatus);
dbus::MessageWriter writer(&method_call);
writer.AppendProtoAsArrayOfBytes(request);
proxy_->CallMethod(
&method_call, kTpmDBusTimeoutMs,
base::BindOnce(&CryptohomeClientImpl::OnBaseReplyMethod,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void GetKeyDataEx( void GetKeyDataEx(
const cryptohome::AccountIdentifier& id, const cryptohome::AccountIdentifier& id,
const cryptohome::AuthorizationRequest& auth, const cryptohome::AuthorizationRequest& auth,
......
...@@ -29,6 +29,7 @@ class EndFingerprintAuthSessionRequest; ...@@ -29,6 +29,7 @@ class EndFingerprintAuthSessionRequest;
class FlushAndSignBootAttributesRequest; class FlushAndSignBootAttributesRequest;
class GetBootAttributeRequest; class GetBootAttributeRequest;
class GetKeyDataRequest; class GetKeyDataRequest;
class GetLoginStatusRequest;
class GetSupportedKeyPoliciesRequest; class GetSupportedKeyPoliciesRequest;
class GetTpmStatusRequest; class GetTpmStatusRequest;
class LockToSingleUserMountUntilRebootRequest; class LockToSingleUserMountUntilRebootRequest;
...@@ -275,6 +276,14 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) CryptohomeClient { ...@@ -275,6 +276,14 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) CryptohomeClient {
// succeeds. This method blocks until the call returns. // succeeds. This method blocks until the call returns.
virtual bool InstallAttributesIsFirstInstall(bool* is_first_install) = 0; virtual bool InstallAttributesIsFirstInstall(bool* is_first_install) = 0;
// Asynchronously calls the GetLoginStatus method. |callback| will be invoked
// with the reply protobuf.
// GetLoginStatus returns information about the current status of user login.
// For example, it tells if cryptohome is locked to single user until reboot.
virtual void GetLoginStatus(
const cryptohome::GetLoginStatusRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) = 0;
// Asynchronously calls the GetKeyDataEx method. |callback| will be invoked // Asynchronously calls the GetKeyDataEx method. |callback| will be invoked
// with the reply protobuf. // with the reply protobuf.
// GetKeyDataEx returns information about the key specified in |request|. At // GetKeyDataEx returns information about the key specified in |request|. At
......
...@@ -289,6 +289,18 @@ bool FakeCryptohomeClient::InstallAttributesIsFirstInstall( ...@@ -289,6 +289,18 @@ bool FakeCryptohomeClient::InstallAttributesIsFirstInstall(
return true; return true;
} }
void FakeCryptohomeClient::GetLoginStatus(
const cryptohome::GetLoginStatusRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) {
cryptohome::BaseReply reply;
cryptohome::GetLoginStatusReply* get_login_status_reply =
reply.MutableExtension(cryptohome::GetLoginStatusReply::reply);
get_login_status_reply->set_owner_user_exists(false);
get_login_status_reply->set_boot_lockbox_finalized(false);
get_login_status_reply->set_is_locked_to_single_user(false);
ReturnProtobufMethodCallback(reply, std::move(callback));
}
void FakeCryptohomeClient::GetKeyDataEx( void FakeCryptohomeClient::GetKeyDataEx(
const cryptohome::AccountIdentifier& cryptohome_id, const cryptohome::AccountIdentifier& cryptohome_id,
const cryptohome::AuthorizationRequest& auth, const cryptohome::AuthorizationRequest& auth,
......
...@@ -91,6 +91,9 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient ...@@ -91,6 +91,9 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient
void InstallAttributesIsReady(DBusMethodCallback<bool> callback) override; void InstallAttributesIsReady(DBusMethodCallback<bool> callback) override;
bool InstallAttributesIsInvalid(bool* is_invalid) override; bool InstallAttributesIsInvalid(bool* is_invalid) override;
bool InstallAttributesIsFirstInstall(bool* is_first_install) override; bool InstallAttributesIsFirstInstall(bool* is_first_install) override;
void GetLoginStatus(
const cryptohome::GetLoginStatusRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) override;
void GetKeyDataEx( void GetKeyDataEx(
const cryptohome::AccountIdentifier& cryptohome_id, const cryptohome::AccountIdentifier& cryptohome_id,
const cryptohome::AuthorizationRequest& auth, const cryptohome::AuthorizationRequest& auth,
......
...@@ -63,22 +63,23 @@ void SessionTerminationManager::DidWaitForServiceToBeAvailable( ...@@ -63,22 +63,23 @@ void SessionTerminationManager::DidWaitForServiceToBeAvailable(
LOG(ERROR) << "WaitForServiceToBeAvailable failed."; LOG(ERROR) << "WaitForServiceToBeAvailable failed.";
return; return;
} }
CryptohomeClient::Get()->GetTpmStatus( CryptohomeClient::Get()->GetLoginStatus(
cryptohome::GetTpmStatusRequest(), cryptohome::GetLoginStatusRequest(),
base::BindOnce(&SessionTerminationManager::RebootIfNecessaryProcessReply, base::BindOnce(&SessionTerminationManager::RebootIfNecessaryProcessReply,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void SessionTerminationManager::ProcessTpmStatusReply( void SessionTerminationManager::ProcessCryptohomeLoginStatusReply(
const base::Optional<cryptohome::BaseReply>& reply) { const base::Optional<cryptohome::BaseReply>& reply) {
if (!reply.has_value() || reply->has_error() || if (!reply.has_value() || reply->has_error() ||
!reply->HasExtension(cryptohome::GetTpmStatusReply::reply)) { !reply->HasExtension(cryptohome::GetLoginStatusReply::reply)) {
LOG(ERROR) << "TPM status request failed, error: " LOG(ERROR) << "Login status request failed, error: "
<< (reply.has_value() && reply->has_error() ? reply->error() << (reply.has_value() && reply->has_error() ? reply->error()
: 0); : 0);
return; return;
} }
auto reply_proto = reply->GetExtension(cryptohome::GetTpmStatusReply::reply); auto reply_proto =
reply->GetExtension(cryptohome::GetLoginStatusReply::reply);
if (reply_proto.has_is_locked_to_single_user() && if (reply_proto.has_is_locked_to_single_user() &&
reply_proto.is_locked_to_single_user()) { reply_proto.is_locked_to_single_user()) {
is_locked_to_single_user_ = true; is_locked_to_single_user_ = true;
...@@ -92,7 +93,7 @@ void SessionTerminationManager::Reboot() { ...@@ -92,7 +93,7 @@ void SessionTerminationManager::Reboot() {
void SessionTerminationManager::RebootIfNecessaryProcessReply( void SessionTerminationManager::RebootIfNecessaryProcessReply(
base::Optional<cryptohome::BaseReply> reply) { base::Optional<cryptohome::BaseReply> reply) {
ProcessTpmStatusReply(reply); ProcessCryptohomeLoginStatusReply(reply);
if (is_locked_to_single_user_) if (is_locked_to_single_user_)
Reboot(); Reboot();
} }
......
...@@ -36,7 +36,7 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_SESSION) SessionTerminationManager { ...@@ -36,7 +36,7 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_SESSION) SessionTerminationManager {
private: private:
void DidWaitForServiceToBeAvailable(bool service_is_available); void DidWaitForServiceToBeAvailable(bool service_is_available);
void ProcessTpmStatusReply( void ProcessCryptohomeLoginStatusReply(
const base::Optional<cryptohome::BaseReply>& reply); const base::Optional<cryptohome::BaseReply>& reply);
void Reboot(); void Reboot();
void RebootIfNecessaryProcessReply( void RebootIfNecessaryProcessReply(
......
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