mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
Add a "test" that prints the SBAT table
The SBAT section was included in a special section in the EFI code, but the contents weren't directly visible in any way. Let's add a "test" that prints them for visual inspection. If there's some external linter for this format, we could hook it up in the future.
This commit is contained in:
parent
9ce14a75e7
commit
776fabbc8b
@ -3,6 +3,8 @@
|
|||||||
conf.set10('ENABLE_EFI', get_option('efi'))
|
conf.set10('ENABLE_EFI', get_option('efi'))
|
||||||
conf.set10('HAVE_GNU_EFI', false)
|
conf.set10('HAVE_GNU_EFI', false)
|
||||||
|
|
||||||
|
efi_config_h_dir = meson.current_build_dir()
|
||||||
|
|
||||||
if not get_option('efi') or get_option('gnu-efi') == 'false'
|
if not get_option('efi') or get_option('gnu-efi') == 'false'
|
||||||
if get_option('gnu-efi') == 'true'
|
if get_option('gnu-efi') == 'true'
|
||||||
error('gnu-efi support requested, but general efi support is disabled')
|
error('gnu-efi support requested, but general efi support is disabled')
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
|
#include "sbat.h"
|
||||||
#include "secure-boot.h"
|
#include "secure-boot.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@ -30,8 +31,5 @@ SecureBootMode secure_boot_mode(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SBAT_DISTRO
|
#ifdef SBAT_DISTRO
|
||||||
static const char sbat[] _used_ _section_(".sbat") =
|
static const char sbat[] _used_ _section_(".sbat") = SBAT_SECTION_TEXT;
|
||||||
"sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md\n"
|
|
||||||
SBAT_PROJECT ",1,The systemd Developers," SBAT_PROJECT "," PROJECT_VERSION "," PROJECT_URL "\n"
|
|
||||||
SBAT_PROJECT "." SBAT_DISTRO "," STRINGIFY(SBAT_DISTRO_GENERATION) "," SBAT_DISTRO_SUMMARY "," SBAT_DISTRO_PKGNAME "," SBAT_DISTRO_VERSION "," SBAT_DISTRO_URL "\n";
|
|
||||||
#endif
|
#endif
|
||||||
|
8
src/fundamental/sbat.h
Normal file
8
src/fundamental/sbat.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
|
#ifdef SBAT_DISTRO
|
||||||
|
# define SBAT_SECTION_TEXT \
|
||||||
|
"sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md\n" \
|
||||||
|
SBAT_PROJECT ",1,The systemd Developers," SBAT_PROJECT "," PROJECT_VERSION "," PROJECT_URL "\n" \
|
||||||
|
SBAT_PROJECT "." SBAT_DISTRO "," STRINGIFY(SBAT_DISTRO_GENERATION) "," SBAT_DISTRO_SUMMARY "," SBAT_DISTRO_PKGNAME "," SBAT_DISTRO_VERSION "," SBAT_DISTRO_URL "\n"
|
||||||
|
#endif
|
@ -478,6 +478,10 @@ tests += [
|
|||||||
|
|
||||||
[files('test-date.c')],
|
[files('test-date.c')],
|
||||||
|
|
||||||
|
[files('test-sbat.c'),
|
||||||
|
[], [], [], 'HAVE_GNU_EFI', '',
|
||||||
|
['-I@0@'.format(efi_config_h_dir)]],
|
||||||
|
|
||||||
[files('test-sleep.c')],
|
[files('test-sleep.c')],
|
||||||
|
|
||||||
[files('test-tpm2.c')],
|
[files('test-tpm2.c')],
|
||||||
|
23
src/test/test-sbat.c
Normal file
23
src/test/test-sbat.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
|
/* We include efi_config.h after undefining PROJECT_VERSION which is also defined in config.h. */
|
||||||
|
#undef PROJECT_VERSION
|
||||||
|
#include "efi_config.h"
|
||||||
|
|
||||||
|
#include "build.h"
|
||||||
|
#include "sbat.h"
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
|
TEST(sbat_section_text) {
|
||||||
|
log_info("---SBAT-----------&<----------------------------------------\n"
|
||||||
|
"%s"
|
||||||
|
"------------------>&-----------------------------------------",
|
||||||
|
#ifdef SBAT_DISTRO
|
||||||
|
SBAT_SECTION_TEXT
|
||||||
|
#else
|
||||||
|
"(not defined)"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_TEST_MAIN(LOG_INFO);
|
Loading…
Reference in New Issue
Block a user