tty-ask-password-agent: convert to VERB_COMMAND and add --introspect-cli

The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-15 15:30:02 +02:00
parent 5c5d3d2065
commit caf889d1ea
2 changed files with 14 additions and 31 deletions
@@ -12,6 +12,8 @@
#include <sys/wait.h>
#include <unistd.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "ask-password-api.h"
#include "build.h"
@@ -24,16 +26,13 @@
#include "exit-status.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-table.h"
#include "format-util.h"
#include "inotify-util.h"
#include "io-util.h"
#include "main-func.h"
#include "mkdir.h"
#include "options.h"
#include "path-util.h"
#include "pidref.h"
#include "pretty-print.h"
#include "process-util.h"
#include "set.h"
#include "signal-util.h"
@@ -43,6 +42,7 @@
#include "strv.h"
#include "terminal-util.h"
#include "time-util.h"
#include "verbs.h"
#include "wall.h"
static enum {
@@ -58,6 +58,12 @@ static char *arg_device = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_device, freep);
COMMAND(
"systemd-tty-ask-password-agent\0",
"Process system password requests.",
.man_pages = "systemd-tty-ask-password-agent.1\0",
);
static int send_passwords(const char *socket_name, char **passwords) {
int r;
@@ -442,33 +448,6 @@ static int process_and_watch_password_files(bool watch) {
return 0;
}
static int help(void) {
_cleanup_free_ char *link = NULL;
_cleanup_(table_unrefp) Table *options = NULL;
int r;
r = terminal_urlify_man("systemd-tty-ask-password-agent", "1", &link);
if (r < 0)
return log_oom();
r = option_parser_get_help_table(&options);
if (r < 0)
return r;
printf("%s [OPTIONS...]\n"
"\n%sProcess system password requests.%s\n\n",
program_invocation_short_name,
ansi_highlight(),
ansi_normal());
r = table_print_or_warn(options);
if (r < 0)
return r;
printf("\nSee the %s for details.\n", link);
return 0;
}
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
@@ -480,7 +459,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
OPTION_COMMON_HELP:
return help();
return command_print_help("systemd-tty-ask-password-agent");
OPTION_COMMON_VERSION:
return version();
@@ -519,6 +498,9 @@ static int parse_argv(int argc, char *argv[]) {
return r;
}
break;
OPTION_COMMON_INTROSPECT_CLI:
return introspect_cli(SD_JSON_FORMAT_OFF);
}
if (option_parser_get_n_args(&opts) > 0)
@@ -36,6 +36,7 @@ INTROSPECTABLE=(
systemd-path
systemd-pty-forward
systemd-socket-activate
systemd-tty-ask-password-agent
systemd-veritysetup
timedatectl
varlinkctl