]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: move TPM conditionalization into measure.h header
authorLennart Poettering <lennart@poettering.net>
Tue, 21 Sep 2021 13:39:47 +0000 (15:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Sep 2021 15:24:10 +0000 (17:24 +0200)
Let's move conditionalization of tpm_log_load_options() into the
measure.h to encapsulate the ifdeffery a bit more.

src/boot/efi/boot.c
src/boot/efi/measure.h
src/boot/efi/stub.c

index 386ee678ea663ae34587b4b8f9defae7126c1aa6..9efd157a8ee692650186565b2a5914f72e5db9a5 100644 (file)
@@ -2314,10 +2314,8 @@ static EFI_STATUS image_start(
                 loaded_image->LoadOptions = options;
                 loaded_image->LoadOptionsSize = StrSize(loaded_image->LoadOptions);
 
-#if ENABLE_TPM
                 /* Try to log any options to the TPM, especially to catch manually edited options */
                 (VOID) tpm_log_load_options(options);
-#endif
         }
 
         efivar_set_time_usec(LOADER_GUID, L"LoaderTimeExecUSec", 0);
index 69eb682a2ec950a1a0f4d025e8f1e41f5f415619..b92d0574c9d5fcdb9c1b6906c7e1a84c74f97ca0 100644 (file)
@@ -3,6 +3,18 @@
 
 #include <efi.h>
 
-EFI_STATUS tpm_log_event(UINT32 pcrindex, const EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description);
+#if ENABLE_TPM
 
+EFI_STATUS tpm_log_event(UINT32 pcrindex, const EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description);
 EFI_STATUS tpm_log_load_options(const CHAR16 *cmdline);
+
+#else
+
+static inline EFI_STATUS tpm_log_event(UINT32 pcrindex, const EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description) {
+        return EFI_SUCCESS;
+}
+static inline EFI_STATUS tpm_log_load_options(const CHAR16 *cmdline) {
+        return EFI_SUCCESS;
+}
+
+#endif
index 3bbb25321e3f4d44dac0f54f50e51d74ceb71083..ad01ab138b6f136e73793270d092be4916cf4742 100644 (file)
@@ -193,13 +193,11 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
                         line[i] = options[i];
                 cmdline = line;
 
-#if ENABLE_TPM
                 /* Let's measure the passed kernel command line into the TPM. Note that this possibly
                  * duplicates what we already did in the boot menu, if that was already used. However, since
                  * we want the boot menu to support an EFI binary, and want to this stub to be usable from
                  * any boot menu, let's measure things anyway. */
                 (VOID) tpm_log_load_options(loaded_image->LoadOptions);
-#endif
         }
 
         export_variables(loaded_image);