diff options
author | Utkarsh Sanghi <usanghi@chromium.org> | 2015-08-31 12:18:55 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-09-09 11:18:01 -0700 |
commit | 50e52ff6bcc478118a1cdec27903a5af5061d77b (patch) | |
tree | 6b49512635ddd192c10077add62efcf6f5dd9cd7 /client | |
parent | 565f88fe8ebdabefe07e5d5cb65ae9bcab509368 (diff) | |
download | tpm_manager-50e52ff6bcc478118a1cdec27903a5af5061d77b.tar.gz |
tpm_manager: Implement Ownership flow
This CL implements the TakeOwnership IPC interface in TpmManager.
This allows clients to take ownership of a Tpm by injecting a random
password. Once a Tpm is owned, it can be utilized by ChromeOS.
BUG=chromium:521635
TEST=unit and take ownership on DUT
Change-Id: Icd4de6b6b1be419dd035e535473929cb8c0ecb16
Reviewed-on: https://chromium-review.googlesource.com/294614
Commit-Ready: Utkarsh Sanghi <usanghi@chromium.org>
Tested-by: Utkarsh Sanghi <usanghi@chromium.org>
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
Diffstat (limited to 'client')
-rw-r--r-- | client/main.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/client/main.cc b/client/main.cc index faa62a5..376e0aa 100644 --- a/client/main.cc +++ b/client/main.cc @@ -22,11 +22,14 @@ namespace tpm_manager { const char kGetTpmStatusCommand[] = "status"; +const char kTakeOwnershipCommand[] = "take_ownership"; const char kUsage[] = R"( Usage: tpm_manager_client <command> [<args>] Commands: status Prints the current status of the Tpm. + take_ownership + Takes ownership of the Tpm with a random password. )"; using ClientLoopBase = chromeos::Daemon; @@ -69,6 +72,9 @@ class ClientLoop : public ClientLoopBase { } else if (command_line->HasSwitch(kGetTpmStatusCommand)) { task = base::Bind(&ClientLoop::HandleGetTpmStatus, weak_factory_.GetWeakPtr()); + } else if (command_line->HasSwitch(kTakeOwnershipCommand)) { + task = base::Bind(&ClientLoop::HandleTakeOwnership, + weak_factory_.GetWeakPtr()); } else { // Command line arguments did not match any valid commands. LOG(ERROR) << "No Valid Command selected."; @@ -95,6 +101,22 @@ class ClientLoop : public ClientLoopBase { weak_factory_.GetWeakPtr())); } + void PrintTakeOwnershipReply(const TakeOwnershipReply& reply) { + if (reply.has_status() && reply.status() == STATUS_NOT_AVAILABLE) { + LOG(INFO) << "tpm_managerd is not available."; + } else { + LOG(INFO) << "TakeOwnershipReply: " << GetProtoDebugString(reply); + } + Quit(); + } + + void HandleTakeOwnership() { + TakeOwnershipRequest request; + tpm_manager_->TakeOwnership(request, + base::Bind(&ClientLoop::PrintTakeOwnershipReply, + weak_factory_.GetWeakPtr())); + } + // Pointer to a DBus proxy to tpm_managerd. std::unique_ptr<tpm_manager::TpmManagerInterface> tpm_manager_; |