shared/verbs: turn verb argument specification into nulstr

Like the command-level CommandDescription.argspec, a verb's argspec is now
a nulstr, so that a verb may declare multiple alternative usage lines. The
verbs help table renders one synopsis line per nulstr entry in the
synopsis cell.

All verb argument specifications must gain an explicit NUL suffix. This
is a lot of churn, but I think this needs to be done. For now, there'll
be only one user of the new functionality (i.e. a verb with more than
one argspec), but I think we'll eventually want to use this in other
places too.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-28 09:29:04 +02:00
parent 057fc4251a
commit efd63ddfbf
42 changed files with 365 additions and 351 deletions
+5 -5
View File
@@ -418,7 +418,7 @@ static int table_add_uid_map(
return n_added;
}
VERB(verb_display_user, "user", "[USER…]", VERB_ANY, VERB_ANY, VERB_DEFAULT,
VERB(verb_display_user, "user", "[USER…]\0", VERB_ANY, VERB_ANY, VERB_DEFAULT,
"Inspect user");
static int verb_display_user(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_(table_unrefp) Table *table = NULL;
@@ -763,7 +763,7 @@ static int add_unavailable_gid(Table *table, uid_t start, uid_t end) {
return 2;
}
VERB(verb_display_group, "group", "[GROUP…]", VERB_ANY, VERB_ANY, 0,
VERB(verb_display_group, "group", "[GROUP…]\0", VERB_ANY, VERB_ANY, 0,
"Inspect group");
static int verb_display_group(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_(table_unrefp) Table *table = NULL;
@@ -966,9 +966,9 @@ static int show_membership(const char *user, const char *group, Table *table) {
return 0;
}
VERB(verb_display_memberships, "users-in-group", "[GROUP…]", VERB_ANY, VERB_ANY, 0,
VERB(verb_display_memberships, "users-in-group", "[GROUP…]\0", VERB_ANY, VERB_ANY, 0,
"Show users that are members of specified groups");
VERB(verb_display_memberships, "groups-of-user", "[USER…]", VERB_ANY, VERB_ANY, 0,
VERB(verb_display_memberships, "groups-of-user", "[USER…]\0", VERB_ANY, VERB_ANY, 0,
"Show groups the specified users are members of");
static int verb_display_memberships(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_(table_unrefp) Table *table = NULL;
@@ -1131,7 +1131,7 @@ static int verb_display_services(int argc, char *argv[], uintptr_t _data, void *
return 0;
}
VERB(verb_ssh_authorized_keys, "ssh-authorized-keys", "USER", 2, VERB_ANY, 0,
VERB(verb_ssh_authorized_keys, "ssh-authorized-keys", "USER\0", 2, VERB_ANY, 0,
"Show SSH authorized keys for user");
static int verb_ssh_authorized_keys(int argc, char *argv[], uintptr_t _data, void *userdata) {
_cleanup_(user_record_unrefp) UserRecord *ur = NULL;