diff options
author | David Howells <dhowells@redhat.com> | 2011-03-11 01:00:30 +0000 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2011-03-11 01:00:30 +0000 |
commit | 6388ba5becf6c7aadea13c7b13ca29e10251c968 (patch) | |
tree | b12c37e1f0083835d5f76aea8a3b9c7fbfd9c837 | |
parent | 8fb54eb74d03b6fc0ba208e718b9e13dcd84fb60 (diff) | |
download | keyutils-6388ba5becf6c7aadea13c7b13ca29e10251c968.tar.gz |
keyctl: Allow multiple lines in the commands[] table with same name
Allow multiple lines in the commands[] table with same name by setting the
action function pointer to NULL for the second and subsequent entries. This
prevents the partial matcher from proclaiming ambiguity for short versions of
commands that have multiple lines ('session' and 'purge').
Also alphabetically order the commands table.
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | keyctl.c | 68 |
1 files changed, 35 insertions, 33 deletions
@@ -63,45 +63,45 @@ static int act_keyctl_reap(int argc, char *argv[]); static int act_keyctl_purge(int argc, char *argv[]); const struct command commands[] = { - { act_keyctl_show, "show", "" }, { act_keyctl_add, "add", "<type> <desc> <data> <keyring>" }, - { act_keyctl_padd, "padd", "<type> <desc> <keyring>" }, - { act_keyctl_request, "request", "<type> <desc> [<dest_keyring>]" }, - { act_keyctl_request2, "request2", "<type> <desc> <info> [<dest_keyring>]" }, - { act_keyctl_prequest2, "prequest2", "<type> <desc> [<dest_keyring>]" }, - { act_keyctl_update, "update", "<key> <data>" }, - { act_keyctl_pupdate, "pupdate", "<key>" }, - { act_keyctl_newring, "newring", "<name> <keyring>" }, - { act_keyctl_revoke, "revoke", "<key>" }, + { act_keyctl_chgrp, "chgrp", "<key> <gid>" }, + { act_keyctl_chown, "chown", "<key> <uid>" }, { act_keyctl_clear, "clear", "<keyring>" }, + { act_keyctl_describe, "describe", "<keyring>" }, + { act_keyctl_instantiate, "instantiate","<key> <data> <keyring>" }, { act_keyctl_link, "link", "<key> <keyring>" }, - { act_keyctl_unlink, "unlink", "<key> [<keyring>]" }, - { act_keyctl_search, "search", "<keyring> <type> <desc> [<dest_keyring>]" }, - { act_keyctl_read, "read", "<key>" }, + { act_keyctl_list, "list", "<keyring>" }, + { act_keyctl_negate, "negate", "<key> <timeout> <keyring>" }, + { act_keyctl_new_session, "new_session", "" }, + { act_keyctl_newring, "newring", "<name> <keyring>" }, + { act_keyctl_padd, "padd", "<type> <desc> <keyring>" }, + { act_keyctl_pinstantiate, "pinstantiate","<key> <keyring>" }, { act_keyctl_pipe, "pipe", "<key>" }, + { act_keyctl_prequest2, "prequest2", "<type> <desc> [<dest_keyring>]" }, { act_keyctl_print, "print", "<key>" }, - { act_keyctl_list, "list", "<keyring>" }, - { act_keyctl_rlist, "rlist", "<keyring>" }, - { act_keyctl_describe, "describe", "<keyring>" }, + { act_keyctl_pupdate, "pupdate", "<key>" }, + { act_keyctl_purge, "purge", "<type>" }, + { NULL, "purge", "[-p] [-i] <type> <desc>" }, + { NULL, "purge", "-s <type> <desc>" }, { act_keyctl_rdescribe, "rdescribe", "<keyring> [sep]" }, - { act_keyctl_chown, "chown", "<key> <uid>" }, - { act_keyctl_chgrp, "chgrp", "<key> <gid>" }, - { act_keyctl_setperm, "setperm", "<key> <mask>" }, + { act_keyctl_read, "read", "<key>" }, + { act_keyctl_reap, "reap", "[-v]" }, + { act_keyctl_reject, "reject", "<key> <timeout> <error> <keyring>" }, + { act_keyctl_request, "request", "<type> <desc> [<dest_keyring>]" }, + { act_keyctl_request2, "request2", "<type> <desc> <info> [<dest_keyring>]" }, + { act_keyctl_revoke, "revoke", "<key>" }, + { act_keyctl_rlist, "rlist", "<keyring>" }, + { act_keyctl_search, "search", "<keyring> <type> <desc> [<dest_keyring>]" }, + { act_keyctl_security, "security", "<key>" }, { act_keyctl_session, "session", "" }, - { act_keyctl_session, "session", "- [<prog> <arg1> <arg2> ...]" }, - { act_keyctl_session, "session", "<name> [<prog> <arg1> <arg2> ...]" }, - { act_keyctl_instantiate, "instantiate","<key> <data> <keyring>" }, - { act_keyctl_pinstantiate, "pinstantiate","<key> <keyring>" }, - { act_keyctl_negate, "negate", "<key> <timeout> <keyring>" }, + { NULL, "session", "- [<prog> <arg1> <arg2> ...]" }, + { NULL, "session", "<name> [<prog> <arg1> <arg2> ...]" }, + { act_keyctl_setperm, "setperm", "<key> <mask>" }, + { act_keyctl_show, "show", "" }, { act_keyctl_timeout, "timeout", "<key> <timeout>" }, - { act_keyctl_security, "security", "<key>" }, - { act_keyctl_new_session, "new_session", "" }, - { act_keyctl_reject, "reject", "<key> <timeout> <error> <keyring>" }, - { act_keyctl_reap, "reap", "[-v]" }, - { act_keyctl_purge, "purge", "<type>" }, - { act_keyctl_purge, "purge", "[-p] [-i] <type> <desc>" }, - { act_keyctl_purge, "purge", "-s <type> <desc>" }, - { NULL, NULL, NULL } + { act_keyctl_unlink, "unlink", "<key> [<keyring>]" }, + { act_keyctl_update, "update", "<key> <data>" }, + { NULL, NULL, NULL } }; static int dump_key_tree(key_serial_t keyring, const char *name); @@ -144,7 +144,9 @@ int main(int argc, char *argv[]) best = NULL; n = strlen(*argv); - for (cmd = commands; cmd->action; cmd++) { + for (cmd = commands; cmd->name; cmd++) { + if (!cmd->action) + continue; if (memcmp(cmd->name, *argv, n) != 0) continue; @@ -198,7 +200,7 @@ static void format(void) fprintf(stderr, "Format:\n"); - for (cmd = commands; cmd->action; cmd++) + for (cmd = commands; cmd->name; cmd++) fprintf(stderr, " keyctl %s %s\n", cmd->name, cmd->format); fprintf(stderr, "\n"); |