report-sign-tpm2: convert to VERB_COMMAND and add --introspect-cli

The custom help() is replaced by a COMMAND() description, matching the
other report-sign services. The abstract is now wrapped at 80 columns
in the help output.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-28 14:50:10 +02:00
parent a677a39c1e
commit 274d366eb3
2 changed files with 14 additions and 24 deletions
+13 -24
View File
@@ -9,9 +9,7 @@
#include "dlopen-note.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-table.h"
#include "fs-util.h"
#include "help-util.h"
#include "iovec-util.h"
#include "json-util.h"
#include "log.h"
@@ -25,6 +23,14 @@
#include "tpm2-util.h"
#include "varlink-io.systemd.Report.Signer.h"
#include "varlink-util.h"
#include "verbs.h"
COMMAND(
"systemd-report-sign-tpm2\0",
"Get an attestation report from a Trusted Platform Module (TPM) "
"that includes the hash of the system report.",
.man_pages = "systemd-report-sign-tpm2@.service(8)\0",
);
#define REPORT_SIGN_TPM2_PERSISTENT_DIR "/var/lib/systemd/report.sign.tpm2"
#define REPORT_SIGN_TPM2_RUNTIME_DIR "/run/systemd/report.sign.tpm2"
@@ -715,27 +721,6 @@ static int vl_server(void) {
return 0;
}
static int help(void) {
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
help_cmdline("[OPTIONS...]");
help_abstract("Get an attestation report from a Trusted Platform Module (TPM) "
"that includes the hash of the system report.");
help_section("Options");
r = table_print_or_warn(options);
if (r < 0)
return r;
help_man_page_reference("systemd-report-sign-tpm2@.service", "8");
return 0;
}
static int parse_argv(int argc, char *argv[]) {
int r;
@@ -747,9 +732,13 @@ static int parse_argv(int argc, char *argv[]) {
FOREACH_OPTION_OR_RETURN(c, &opts)
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help();
OPTION_COMMON_VERSION:
return version();
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (option_parser_get_n_args(&opts) > 0)
@@ -111,6 +111,7 @@ INTROSPECTABLE=(
systemd-report-cgroup
systemd-report-files
systemd-report-sign-plain
systemd-report-sign-tpm2
systemd-report-sign-tsm
systemd-resolved
systemd-run