Chromium Code Reviews| Index: chromeos/tpm/tpm_token_info_getter.cc |
| diff --git a/chromeos/tpm/tpm_token_info_getter.cc b/chromeos/tpm/tpm_token_info_getter.cc |
| index 1e7918d03c016ab2b6bd074ab0bb3a8126a50cd6..da88626a4d79392375cb6eaa1cdd4736bf8d9831 100644 |
| --- a/chromeos/tpm/tpm_token_info_getter.cc |
| +++ b/chromeos/tpm/tpm_token_info_getter.cc |
| @@ -7,6 +7,8 @@ |
| #include <stdint.h> |
| #include "base/bind.h" |
| +#include "base/files/file_path.h" |
| +#include "base/files/file_util.h" |
| #include "base/location.h" |
| #include "base/task_runner.h" |
| #include "chromeos/cryptohome/cryptohome_parameters.h" |
| @@ -17,6 +19,11 @@ namespace { |
| const int64_t kInitialRequestDelayMs = 100; |
| const int64_t kMaxRequestDelayMs = 300000; // 5 minutes |
| +// If either of these two files exist, then we are using Cr50 and not using TPM. |
| +constexpr char kCr50UsedIndicatorFile1[] = |
| + "/opt/google/cr50/firmware/cr50.bin.prod"; |
| +constexpr char kCr50UsedIndicatorFile2[] = "/etc/init/cr50-update.conf"; |
| + |
| // Calculates the delay before running next attempt to initiatialize the TPM |
| // token, if |last_delay| was the last or initial delay. |
| base::TimeDelta GetNextRequestDelayMs(base::TimeDelta last_delay) { |
| @@ -61,6 +68,11 @@ std::unique_ptr<TPMTokenInfoGetter> TPMTokenInfoGetter::CreateForSystemToken( |
| TYPE_SYSTEM, EmptyAccountId(), cryptohome_client, delayed_task_runner)); |
| } |
| +bool TPMTokenInfoGetter::IsCr50Used() { |
| + return base::PathExists(base::FilePath(kCr50UsedIndicatorFile1)) || |
| + base::PathExists(base::FilePath(kCr50UsedIndicatorFile2)); |
|
xiyuan
2017/05/03 04:06:49
base::PathExists touches file system and should no
sammiequon
2017/05/04 16:04:47
Done. Though I am concerned with not doing this pr
|
| +} |
| + |
| TPMTokenInfoGetter::~TPMTokenInfoGetter() {} |
| void TPMTokenInfoGetter::Start(const TPMTokenInfoCallback& callback) { |