Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium 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 "chrome/browser/chromeos/login/hwid_checker.h" | 5 #include "chrome/browser/chromeos/login/hwid_checker.h" |
| 6 | 6 |
| 7 #include <cstdio> | 7 #include <cstdio> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 | 102 |
| 103 } // anonymous namespace | 103 } // anonymous namespace |
| 104 | 104 |
| 105 namespace chromeos { | 105 namespace chromeos { |
| 106 | 106 |
| 107 bool IsHWIDCorrect(const std::string& hwid) { | 107 bool IsHWIDCorrect(const std::string& hwid) { |
| 108 return IsCorrectHWIDv2(hwid) || IsCorrectExceptionalHWID(hwid) || | 108 return IsCorrectHWIDv2(hwid) || IsCorrectExceptionalHWID(hwid) || |
| 109 IsCorrectHWIDv3(hwid); | 109 IsCorrectHWIDv3(hwid); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool IsMachineHWIDCorrect() { | 112 bool IsMachineHWIDCorrect() { |
|
Daniel Erat
2016/08/10 16:32:28
it's not your fault, but would you mind adding tes
norvez
2016/08/11 17:10:34
Done.
| |
| 113 #if !defined(GOOGLE_CHROME_BUILD) | 113 #if !defined(GOOGLE_CHROME_BUILD) |
| 114 return true; | 114 return true; |
| 115 #endif | 115 #endif |
| 116 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 116 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 117 if (cmd_line->HasSwitch(::switches::kTestType)) | 117 if (cmd_line->HasSwitch(::switches::kTestType)) |
| 118 return true; | 118 return true; |
| 119 if (!base::SysInfo::IsRunningOnChromeOS()) | 119 if (!base::SysInfo::IsRunningOnChromeOS()) |
| 120 return true; | 120 return true; |
| 121 chromeos::system::StatisticsProvider* stats = | 121 chromeos::system::StatisticsProvider* stats = |
| 122 chromeos::system::StatisticsProvider::GetInstance(); | 122 chromeos::system::StatisticsProvider::GetInstance(); |
| 123 | 123 |
| 124 std::string hwid; | 124 std::string hwid; |
| 125 if (!stats->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid)) { | 125 if (!stats->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid)) { |
| 126 LOG(ERROR) << "Couldn't get machine statistic 'hardware_class'."; | 126 LOG(ERROR) << "Couldn't get machine statistic 'hardware_class'."; |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 if (!chromeos::IsHWIDCorrect(hwid)) { | 129 if (!chromeos::IsHWIDCorrect(hwid)) { |
| 130 // Log the system vendor info to see what the system vendor is on the GCE | |
| 131 // VMs. This info will be used to filter out error messages on VMs. See | |
| 132 // http://crbug.com/585514 and http://crbug.com/585515 for more info. | |
| 133 std::string system_vendor; | 130 std::string system_vendor; |
| 134 stats->GetMachineStatistic(chromeos::system::kSystemVendorKey, | 131 stats->GetMachineStatistic(chromeos::system::kSystemVendorKey, |
| 135 &system_vendor); | 132 &system_vendor); |
| 136 std::string firmware_type; | 133 if (!stats->IsRunningOnVm()) { |
| 137 const bool non_chrome_firmware = | |
| 138 stats->GetMachineStatistic(chromeos::system::kFirmwareTypeKey, | |
| 139 &firmware_type) && | |
| 140 firmware_type == system::kFirmwareTypeValueNonchrome; | |
| 141 if (non_chrome_firmware) { | |
| 142 LOG(WARNING) << "Detected non-Chrome firmware with malformed HWID '" | |
| 143 << hwid << "', assuming VM environment. " | |
| 144 << "The system vendor is '" << system_vendor << "'."; | |
| 145 } else { | |
| 146 LOG(ERROR) << "Machine has malformed HWID '" << hwid << "'. " | 134 LOG(ERROR) << "Machine has malformed HWID '" << hwid << "'. " |
| 147 << "The system vendor is '" << system_vendor << "'."; | 135 << "The system vendor is '" << system_vendor << "'."; |
| 148 return false; | 136 return false; |
| 137 } else { | |
| 138 LOG(WARNING) << "The system is a VM. The system vendor is '" | |
| 139 << system_vendor << "'."; | |
|
Daniel Erat
2016/08/10 16:32:28
nit: fix indenting ('<<' should line up with first
achuithb
2016/08/10 18:24:58
We had introduced this logging because we weren't
norvez
2016/08/11 17:10:34
Done.
| |
| 149 } | 140 } |
| 150 } | 141 } |
| 151 return true; | 142 return true; |
| 152 } | 143 } |
| 153 | 144 |
| 154 } // namespace chromeos | 145 } // namespace chromeos |
| OLD | NEW |