From 6e19fb74bfd48474e6ce6c58abdb65a4865f84bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 17 Aug 2026 13:37:29 +0200 Subject: [PATCH] sbsign: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The abstract gains its missing trailing period and says "PE binaries", like the man page. --- src/sbsign/sbsign.c | 56 ++++--------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 44 deletions(-) diff --git a/src/sbsign/sbsign.c b/src/sbsign/sbsign.c index bed464e8ce..dd50afb63f 100644 --- a/src/sbsign/sbsign.c +++ b/src/sbsign/sbsign.c @@ -2,8 +2,9 @@ #include +#include "sd-json.h" + #include "alloc-util.h" -#include "ansi-color.h" #include "ask-password-api.h" #include "authenticode.h" #include "build.h" @@ -13,16 +14,13 @@ #include "efi.h" #include "fd-util.h" #include "fileio.h" -#include "format-table.h" #include "fs-util.h" #include "install-file.h" #include "io-util.h" #include "log.h" #include "main-func.h" -#include "options.h" #include "parse-argument.h" #include "pe-binary.h" -#include "pretty-print.h" #include "stat-util.h" #include "string-util.h" #include "time-util.h" @@ -48,46 +46,13 @@ STATIC_DESTRUCTOR_REGISTER(arg_private_key_source, freep); STATIC_DESTRUCTOR_REGISTER(arg_signed_data, freep); STATIC_DESTRUCTOR_REGISTER(arg_signed_data_signature, freep); -static int help(void) { - _cleanup_free_ char *link = NULL; - _cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL; - int r; +COMMAND( + "systemd-sbsign\0", + "Sign PE binaries for EFI Secure Boot.", + .man_pages = "systemd-sbsign.1\0", +); - r = terminal_urlify_man("systemd-sbsign", "1", &link); - if (r < 0) - return log_oom(); - - r = verbs_get_help_table(&verbs); - if (r < 0) - return r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - (void) table_sync_column_widths(0, verbs, options); - - printf("%s [OPTIONS...] COMMAND ...\n" - "\n%sSign binaries for EFI Secure Boot%s\n" - "\n%sCommands:%s\n", - program_invocation_short_name, - ansi_highlight(), ansi_normal(), - ansi_underline(), ansi_normal()); - - r = table_print_or_warn(verbs); - if (r < 0) - return r; - - printf("\n%sOptions:%s\n", ansi_underline(), ansi_normal()); - r = table_print_or_warn(options); - if (r < 0) - return r; - - printf("\nSee the %s for details.\n", link); - return 0; -} - -VERB_COMMON_HELP_HIDDEN(help); +VERB_COMMON_HELP_AUTO_HIDDEN("systemd-sbsign"); static int parse_argv(int argc, char *argv[], char ***ret_args) { assert(argc >= 0); @@ -101,7 +66,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-sbsign"); OPTION_COMMON_VERSION: return version(); @@ -163,6 +128,9 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { return r; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } if (arg_private_key_source && !arg_certificate) diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 0498f7524e..93fe96194d 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -63,6 +63,7 @@ INTROSPECTABLE=( systemd-pty-forward systemd-random-seed systemd-report + systemd-sbsign systemd-socket-activate systemd-socket-proxyd systemd-stdio-bridge