From e008bd77815f37410b06dd0a9ebfa0d280e32147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 6 Oct 2026 16:05:11 +0200 Subject: [PATCH] meson: add config switch for systemd-report This prog is still labelled as experimental and we didn't have a way to disable its build. With the addition of this option, all experimental components can be disabled. --- man/rules/meson.build | 14 ++--- man/systemd-report-diskspace@.service.xml | 2 +- man/systemd-report-files@.service.xml | 3 +- man/systemd-report-hwmon@.service.xml | 3 +- man/systemd-report-sign-plain@.service.xml | 5 +- man/systemd-report-sign-tpm2@.service.xml | 5 +- man/systemd-report-sign-tsm@.service.xml | 3 +- man/systemd-report.xml | 3 +- meson.build | 3 + meson_options.txt | 2 + src/report/meson.build | 4 ++ src/shared/meson.build | 9 ++- test/units/TEST-07-PID1.reload-count.sh | 7 ++- test/units/TEST-74-AUX-UTILS.report.sh | 3 + test/units/TEST-94-COCO.snp-direct.sh | 4 ++ tmpfiles.d/systemd.conf.in | 2 + units/meson.build | 72 ++++++++++++++++------ 17 files changed, 106 insertions(+), 38 deletions(-) diff --git a/man/rules/meson.build b/man/rules/meson.build index 3dc47929707..c7a32700b44 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -1212,28 +1212,28 @@ manpages = [ ['systemd-report-diskspace@.service', '8', ['systemd-report-diskspace', 'systemd-report-diskspace.socket'], - 'HAVE_LIBMOUNT'], + 'ENABLE_REPORT HAVE_LIBMOUNT'], ['systemd-report-files@.service', '8', ['systemd-report-files', 'systemd-report-files.socket'], - ''], + 'ENABLE_REPORT'], ['systemd-report-hwmon@.service', '8', ['systemd-report-hwmon', 'systemd-report-hwmon.socket'], - ''], + 'ENABLE_REPORT'], ['systemd-report-sign-plain@.service', '8', ['systemd-report-sign-plain', 'systemd-report-sign-plain.socket'], - 'HAVE_OPENSSL'], + 'ENABLE_REPORT HAVE_OPENSSL'], ['systemd-report-sign-tpm2@.service', '8', ['systemd-report-sign-tpm2', 'systemd-report-sign-tpm2.socket'], - 'HAVE_OPENSSL HAVE_TPM2'], + 'ENABLE_REPORT HAVE_OPENSSL HAVE_TPM2'], ['systemd-report-sign-tsm@.service', '8', ['systemd-report-sign-tsm', 'systemd-report-sign-tsm.socket'], - ''], - ['systemd-report', '1', [], ''], + 'ENABLE_REPORT'], + ['systemd-report', '1', [], 'ENABLE_REPORT'], ['systemd-resolved.service', '8', ['systemd-resolved'], 'ENABLE_RESOLVE'], ['systemd-rfkill.service', '8', diff --git a/man/systemd-report-diskspace@.service.xml b/man/systemd-report-diskspace@.service.xml index ee61c1d0ce5..c5ded8fb1c6 100644 --- a/man/systemd-report-diskspace@.service.xml +++ b/man/systemd-report-diskspace@.service.xml @@ -4,7 +4,7 @@ + conditional='ENABLE_REPORT HAVE_LIBMOUNT'> systemd-report-diskspace@.service diff --git a/man/systemd-report-files@.service.xml b/man/systemd-report-files@.service.xml index a44b189fb6c..c6c586d00b2 100644 --- a/man/systemd-report-files@.service.xml +++ b/man/systemd-report-files@.service.xml @@ -3,7 +3,8 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> - + systemd-report-files@.service diff --git a/man/systemd-report-hwmon@.service.xml b/man/systemd-report-hwmon@.service.xml index 135c695c33a..726ddb0d1f2 100644 --- a/man/systemd-report-hwmon@.service.xml +++ b/man/systemd-report-hwmon@.service.xml @@ -3,7 +3,8 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> - + systemd-report-hwmon@.service diff --git a/man/systemd-report-sign-plain@.service.xml b/man/systemd-report-sign-plain@.service.xml index 1602f616637..50bb9a986b3 100644 --- a/man/systemd-report-sign-plain@.service.xml +++ b/man/systemd-report-sign-plain@.service.xml @@ -3,8 +3,9 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> - + systemd-report-sign-plain@.service diff --git a/man/systemd-report-sign-tpm2@.service.xml b/man/systemd-report-sign-tpm2@.service.xml index 4ba9309474e..39577c301bf 100644 --- a/man/systemd-report-sign-tpm2@.service.xml +++ b/man/systemd-report-sign-tpm2@.service.xml @@ -3,8 +3,9 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> - + systemd-report-sign-tpm2@.service diff --git a/man/systemd-report-sign-tsm@.service.xml b/man/systemd-report-sign-tsm@.service.xml index 61d67b24a9a..879d7ce3f6e 100644 --- a/man/systemd-report-sign-tsm@.service.xml +++ b/man/systemd-report-sign-tsm@.service.xml @@ -4,7 +4,8 @@ + xmlns:xi="http://www.w3.org/2001/XInclude" + conditional='ENABLE_REPORT'> systemd-report-sign-tsm@.service diff --git a/man/systemd-report.xml b/man/systemd-report.xml index baafbb4104c..1d14f059531 100644 --- a/man/systemd-report.xml +++ b/man/systemd-report.xml @@ -7,7 +7,8 @@ + xmlns:xi="http://www.w3.org/2001/XInclude" + conditional='ENABLE_REPORT'> systemd-report diff --git a/meson.build b/meson.build index 5735c5e64df..c8bd251e0a8 100644 --- a/meson.build +++ b/meson.build @@ -1565,6 +1565,8 @@ have = get_option('repart').require( error_message : 'fdisk required').allowed() conf.set10('ENABLE_REPART', have) +conf.set10('ENABLE_REPORT', get_option('report').allowed()) + default_dnssec = get_option('default-dnssec') if default_dnssec != 'no' and conf.get('HAVE_OPENSSL') == 0 message('default-dnssec cannot be set to yes or allow-downgrade when openssl is disabled. Setting default-dnssec to no.') @@ -3224,6 +3226,7 @@ foreach tuple : [ ['quotacheck'], ['randomseed'], ['repart'], + ['report'], ['resolve'], ['rfkill'], ['sysext'], diff --git a/meson_options.txt b/meson_options.txt index 06e781c3ada..266f2dbb83e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -231,6 +231,8 @@ option('remote', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : description : 'support for "journal over the network"') option('repart', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'install the systemd-repart tool') +option('report', type : 'feature', + description : 'install the systemd-report stack') option('resolve', type : 'boolean', description : 'systemd-resolved stack') option('rfkill', type : 'boolean', diff --git a/src/report/meson.build b/src/report/meson.build index d2583cd84a4..748fad5097d 100644 --- a/src/report/meson.build +++ b/src/report/meson.build @@ -1,5 +1,9 @@ # SPDX-License-Identifier: LGPL-2.1-or-later +if conf.get('ENABLE_REPORT') != 1 + subdir_done() +endif + executables += [ libexec_template + { 'name' : 'systemd-report', diff --git a/src/shared/meson.build b/src/shared/meson.build index 648887e9ec4..7e76bfeec7c 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -212,7 +212,6 @@ shared_sources = files( 'tomoyo-util.c', 'tpm2-util.c', 'tpm2-event-log.c', - 'tsm-report.c', 'udev-util.c', 'unit-file.c', 'user-record-nss.c', @@ -307,8 +306,12 @@ if conf.get('HAVE_LIBBPF') == 1 shared_sources += files('bpf-link.c') endif -if conf.get('HAVE_TPM2') == 1 - shared_sources += files('tpm2-report.c') +if conf.get('ENABLE_REPORT') == 1 + shared_sources += files('tsm-report.c') + + if conf.get('HAVE_TPM2') == 1 + shared_sources += files('tpm2-report.c') + endif endif generate_ip_protocol_list = files('generate-ip-protocol-list.sh') diff --git a/test/units/TEST-07-PID1.reload-count.sh b/test/units/TEST-07-PID1.reload-count.sh index a41a4e467d2..b6a0c106d5d 100755 --- a/test/units/TEST-07-PID1.reload-count.sh +++ b/test/units/TEST-07-PID1.reload-count.sh @@ -3,6 +3,11 @@ set -eux set -o pipefail +REPORT=/usr/lib/systemd/systemd-report + +# systemd-report is optional +[ -x "$REPORT" ] || exit 77 + # Verify that the manager exposes a ReloadCount property that increments on # every daemon-reload, resets to zero across daemon-reexec (since the count # is not serialized), and is reachable over D-Bus, Varlink Describe, and the @@ -28,7 +33,7 @@ read_count_varlink() { read_count_report() { local out # Strip the RS separator that jq --seq re-emits on output. - out=$(/usr/lib/systemd/systemd-report metrics --json=short \ + out=$("$REPORT" metrics --json=short \ io.systemd.Manager.ReloadCount \ | jq --seq -r 'select(.name == "io.systemd.Manager.ReloadCount") | .value' \ | tr -d '\036') diff --git a/test/units/TEST-74-AUX-UTILS.report.sh b/test/units/TEST-74-AUX-UTILS.report.sh index 563bc7d33d7..6d2f19c4522 100755 --- a/test/units/TEST-74-AUX-UTILS.report.sh +++ b/test/units/TEST-74-AUX-UTILS.report.sh @@ -9,6 +9,9 @@ export PAGER= REPORT=/usr/lib/systemd/systemd-report +# systemd-report is optional +[ -x "$REPORT" ] || exit 77 + "$REPORT" --help "$REPORT" help "$REPORT" --version diff --git a/test/units/TEST-94-COCO.snp-direct.sh b/test/units/TEST-94-COCO.snp-direct.sh index ea8242690d4..d426bfaadf1 100755 --- a/test/units/TEST-94-COCO.snp-direct.sh +++ b/test/units/TEST-94-COCO.snp-direct.sh @@ -14,6 +14,10 @@ if [[ "${COCO_TYPE:?}" != "sev-snp" ]]; then exit 77 fi +# systemd-report is optional, and a large part of the tests below will fail +# without it. Skip the whole test for simplicity. +[ -x /usr/lib/systemd/systemd-report ] || exit 77 + MACHINE="coco-snp-direct-$$" WORKDIR="$(mktemp -d)" mkdir -p "$WORKDIR/honest" "$WORKDIR/hostile" diff --git a/tmpfiles.d/systemd.conf.in b/tmpfiles.d/systemd.conf.in index 786b86d0069..6f5f1ff2d72 100644 --- a/tmpfiles.d/systemd.conf.in +++ b/tmpfiles.d/systemd.conf.in @@ -19,7 +19,9 @@ d$ /run/systemd/users 0755 root root - d /run/systemd/machines 0755 root root - d$ /run/systemd/shutdown 0755 root root - d /run/systemd/dissect-root 0000 root root - +{% if ENABLE_REPORT %} d /run/systemd/report.sign 0700 root root - +{% endif %} d /run/log 0755 root root - diff --git a/units/meson.build b/units/meson.build index 55610bfb27e..2334195328f 100644 --- a/units/meson.build +++ b/units/meson.build @@ -686,10 +686,22 @@ units = [ 'conditions' : ['ENABLE_BOOTLOADER', 'HAVE_OPENSSL', 'HAVE_TPM2'], 'symlinks' : ['sysinit.target.wants/'], }, - { 'file' : 'systemd-report.socket' }, - { 'file' : 'systemd-report@.service.in' }, - { 'file' : 'systemd-report-basic.socket' }, - { 'file' : 'systemd-report-basic@.service.in' }, + { + 'file' : 'systemd-report.socket', + 'conditions' : ['ENABLE_REPORT'], + }, + { + 'file' : 'systemd-report@.service.in', + 'conditions' : ['ENABLE_REPORT'], + }, + { + 'file' : 'systemd-report-basic.socket', + 'conditions' : ['ENABLE_REPORT'], + }, + { + 'file' : 'systemd-report-basic@.service.in', + 'conditions' : ['ENABLE_REPORT'], + }, { 'file' : 'systemd-tpm2-clear.service.in', 'conditions' : ['ENABLE_BOOTLOADER', 'HAVE_OPENSSL', 'HAVE_TPM2'], @@ -792,38 +804,62 @@ units = [ 'file' : 'systemd-repart@.service', 'conditions' : ['ENABLE_REPART'], }, - { 'file' : 'systemd-report-cgroup.socket' }, - { 'file' : 'systemd-report-cgroup@.service.in' }, + { + 'file' : 'systemd-report-cgroup.socket', + 'conditions' : ['ENABLE_REPORT'], + }, + { + 'file' : 'systemd-report-cgroup@.service.in', + 'conditions' : ['ENABLE_REPORT'], + }, { 'file' : 'systemd-report-diskspace.socket', - 'conditions' : ['HAVE_LIBMOUNT'], + 'conditions' : ['ENABLE_REPORT', 'HAVE_LIBMOUNT'], }, { 'file' : 'systemd-report-diskspace@.service.in', - 'conditions' : ['HAVE_LIBMOUNT'], + 'conditions' : ['ENABLE_REPORT', 'HAVE_LIBMOUNT'], + }, + { + 'file' : 'systemd-report-files.socket', + 'conditions' : ['ENABLE_REPORT'], + }, + { + 'file' : 'systemd-report-files@.service.in', + 'conditions' : ['ENABLE_REPORT'], + }, + { + 'file' : 'systemd-report-hwmon.socket', + 'conditions' : ['ENABLE_REPORT'], + }, + { + 'file' : 'systemd-report-hwmon@.service.in', + 'conditions' : ['ENABLE_REPORT'], }, - { 'file' : 'systemd-report-files.socket' }, - { 'file' : 'systemd-report-files@.service.in' }, - { 'file' : 'systemd-report-hwmon.socket' }, - { 'file' : 'systemd-report-hwmon@.service.in' }, { 'file' : 'systemd-report-sign-plain.socket', - 'conditions' : ['HAVE_OPENSSL'], + 'conditions' : ['ENABLE_REPORT', 'HAVE_OPENSSL'], }, { 'file' : 'systemd-report-sign-plain@.service.in', - 'conditions' : ['HAVE_OPENSSL'], + 'conditions' : ['ENABLE_REPORT', 'HAVE_OPENSSL'], }, { 'file' : 'systemd-report-sign-tpm2.socket', - 'conditions' : ['HAVE_OPENSSL','HAVE_TPM2'], + 'conditions' : ['ENABLE_REPORT', 'HAVE_OPENSSL', 'HAVE_TPM2'], }, { 'file' : 'systemd-report-sign-tpm2@.service.in', - 'conditions' : ['HAVE_OPENSSL', 'HAVE_TPM2'], + 'conditions' : ['ENABLE_REPORT', 'HAVE_OPENSSL', 'HAVE_TPM2'], + }, + { + 'file' : 'systemd-report-sign-tsm.socket', + 'conditions' : ['ENABLE_REPORT'], + }, + { + 'file' : 'systemd-report-sign-tsm@.service.in', + 'conditions' : ['ENABLE_REPORT'], }, - { 'file' : 'systemd-report-sign-tsm.socket' }, - { 'file' : 'systemd-report-sign-tsm@.service.in' }, { 'file' : 'systemd-resolved.service.in', 'conditions' : ['ENABLE_RESOLVE'],