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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-17 15:49:01 +02:00
parent ef3bb712a7
commit 6e19fb74bf
2 changed files with 13 additions and 44 deletions
+12 -44
View File
@@ -2,8 +2,9 @@
#include <unistd.h>
#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)
@@ -63,6 +63,7 @@ INTROSPECTABLE=(
systemd-pty-forward
systemd-random-seed
systemd-report
systemd-sbsign
systemd-socket-activate
systemd-socket-proxyd
systemd-stdio-bridge