trivial: uefi: allow forcing to TPM2 via environment variable

Use this environment variable to ensure that TPM2 is used in self
tests even if the system has TPM1.2.
This commit is contained in:
Mario Limonciello 2019-09-24 14:57:02 -05:00 committed by Mario Limonciello
parent f1accad201
commit 42ee62ef34
2 changed files with 4 additions and 1 deletions

View File

@ -50,6 +50,7 @@ fu_uefi_pcrs_2_0_func (void)
g_autoptr(GPtrArray) pcr0s = NULL;
g_autoptr(GPtrArray) pcrXs = NULL;
const gchar *tpm_server_running = g_getenv ("TPM_SERVER_RUNNING");
g_setenv ("FWUPD_FORCE_TPM2", "1", TRUE);
if (!fu_uefi_pcrs_setup (pcrs, &error)) {
if (tpm_server_running == NULL &&
@ -65,6 +66,7 @@ fu_uefi_pcrs_2_0_func (void)
pcrXs = fu_uefi_pcrs_get_checksums (pcrs, 999);
g_assert_nonnull (pcrXs);
g_assert_cmpint (pcrXs->len, ==, 0);
g_unsetenv ("FWUPD_FORCE_TPM2");
}
static void

View File

@ -188,7 +188,8 @@ fu_uefi_pcrs_setup (FuUefiPcrs *self, GError **error)
sysfstpmdir = fu_common_get_path (FU_PATH_KIND_SYSFSDIR_TPM);
devpath = g_build_filename (sysfstpmdir, "tpm0", NULL);
fn_pcrs = g_build_filename (devpath, "pcrs", NULL);
if (g_file_test (fn_pcrs, G_FILE_TEST_EXISTS)) {
if (g_file_test (fn_pcrs, G_FILE_TEST_EXISTS) &&
g_getenv ("FWUPD_FORCE_TPM2") == NULL) {
if (!fu_uefi_pcrs_setup_tpm12 (self, fn_pcrs, error))
return FALSE;