From 110eb286bcef515ec8b5c4ea80792cf8084cd1bb Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 8 Sep 2020 12:58:38 -0500 Subject: [PATCH] Make TPM more optional (Fixes: #2360) - Rename the `plugin_tpm` option to `tpm` and when it's disabled remove TPM support from all plugins - If enabled then require the TSS to be installed --- contrib/ci/build_windows.sh | 2 +- contrib/ci/trust.sh | 2 +- contrib/fwupd.spec.in | 4 ++-- meson.build | 11 +++++------ meson_options.txt | 2 +- plugins/meson.build | 4 ++-- plugins/uefi/fu-self-test.c | 5 +++++ 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/contrib/ci/build_windows.sh b/contrib/ci/build_windows.sh index 33c2a8604..28230fb78 100755 --- a/contrib/ci/build_windows.sh +++ b/contrib/ci/build_windows.sh @@ -22,7 +22,7 @@ meson .. \ -Dplugin_altos=false \ -Dplugin_dell=false \ -Dplugin_nvme=false \ - -Dplugin_tpm=false \ + -Dtpm=false \ -Dsystemd=false \ -Dplugin_emmc=false \ -Dplugin_amt=false \ diff --git a/contrib/ci/trust.sh b/contrib/ci/trust.sh index d1ebc5c3a..506776243 100755 --- a/contrib/ci/trust.sh +++ b/contrib/ci/trust.sh @@ -15,7 +15,7 @@ meson build \ -Dman=false \ -Ddaemon=false \ -Dgusb:tests=false \ - -Dplugin_tpm=false \ + -Dtpm=false \ -Dplugin_modem_manager=false \ -Dplugin_flashrom=false \ -Dplugin_uefi=false \ diff --git a/contrib/fwupd.spec.in b/contrib/fwupd.spec.in index 49e26f837..ef825a70d 100644 --- a/contrib/fwupd.spec.in +++ b/contrib/fwupd.spec.in @@ -201,11 +201,11 @@ Data files for installed tests. %if 0%{?have_uefi} -Dplugin_uefi=true \ -Dplugin_nvme=true \ - -Dplugin_tpm=true \ + -Dtpm=true \ %else -Dplugin_uefi=false \ -Dplugin_nvme=false \ - -Dplugin_tpm=false \ + -Dtpm=false \ %endif %if 0%{?have_dell} -Dplugin_dell=true \ diff --git a/meson.build b/meson.build index 473015489..bf8e4775b 100644 --- a/meson.build +++ b/meson.build @@ -226,10 +226,6 @@ libgcab = dependency('libgcab-1.0', version : '>= 1.0', fallback : ['gcab', 'gca gcab = find_program('gcab', required : true) bashcomp = dependency('bash-completion', required: false) python3 = find_program('python3') -tpm2tss = dependency('tss2-esys', version : '>= 2.0', required: false) -if tpm2tss.found() - conf.set('HAVE_TSS2', '1') -endif platform_deps = [] if get_option('default_library') != 'static' @@ -290,8 +286,11 @@ if cc.has_function('pwrite', args : '-D_XOPEN_SOURCE') conf.set('HAVE_PWRITE', '1') endif -if build_standalone and get_option('plugin_tpm') and not tpm2tss.found() - error('tss2-esys is required for -Dplugin_tpm=true') +if build_standalone and get_option('tpm') + tpm2tss = dependency('tss2-esys', version : '>= 2.0') + conf.set('HAVE_TSS2', '1') +else + tpm2tss = dependency('', required: false) endif if build_standalone and get_option('plugin_uefi') diff --git a/meson_options.txt b/meson_options.txt index c2fb1f720..ad0f3b730 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -15,7 +15,6 @@ option('plugin_emmc', type : 'boolean', value : true, description : 'enable eMMC option('plugin_synaptics', type: 'boolean', value: true, description : 'enable Synaptics MST hub support') option('plugin_thunderbolt', type : 'boolean', value : true, description : 'enable Thunderbolt support') option('plugin_redfish', type : 'boolean', value : true, description : 'enable Redfish support') -option('plugin_tpm', type : 'boolean', value : true, description : 'enable TPM support') option('plugin_uefi', type : 'boolean', value : true, description : 'enable UEFI support') option('plugin_nvme', type : 'boolean', value : true, description : 'enable NVMe support') option('plugin_modem_manager', type : 'boolean', value : false, description : 'enable ModemManager support') @@ -27,6 +26,7 @@ option('systemd', type : 'boolean', value : true, description : 'enable systemd option('systemd_root_prefix', type: 'string', value: '', description: 'Directory to base systemd’s installation directories on') option('elogind', type : 'boolean', value : false, description : 'enable elogind support') option('tests', type : 'boolean', value : true, description : 'enable tests') +option('tpm', type : 'boolean', value : true, description : 'enable TPM support') option('udevdir', type: 'string', value: '', description: 'Directory for udev rules') option('efi-cc', type : 'string', value : 'gcc', description : 'the compiler to use for EFI modules') option('efi-ld', type : 'string', value : 'ld', description : 'the linker to use for EFI modules') diff --git a/plugins/meson.build b/plugins/meson.build index 6ecd99578..b24c13920 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -57,9 +57,9 @@ endif # depends on dfu subdir('csr') -if get_option('plugin_tpm') +if get_option('tpm') if not get_option('gudev') - error('gudev is required for plugin_tpm') + error('gudev is required for tpm') endif subdir('tpm') subdir('tpm-eventlog') diff --git a/plugins/uefi/fu-self-test.c b/plugins/uefi/fu-self-test.c index 19899b38d..aef078cc6 100644 --- a/plugins/uefi/fu-self-test.c +++ b/plugins/uefi/fu-self-test.c @@ -50,6 +50,11 @@ fu_uefi_pcrs_2_0_func (void) const gchar *tpm_server_running = g_getenv ("TPM_SERVER_RUNNING"); g_setenv ("FWUPD_FORCE_TPM2", "1", TRUE); +#ifndef HAVE_TSS2 + g_test_skip ("Compiled without TPM2.0 support"); + return; +#endif + #ifdef HAVE_GETUID if (tpm_server_running == NULL && (getuid () != 0 || geteuid () != 0)) {