asetkey: Add new 'delete' command variants

The current 'delete' command from asetkey only lets the user delete
old-style rxkad keys. Add a couple of new variants to allow specifying
the key type and subtype, so the user can delete specific key types
and enctypes if they want.

Change-Id: If0dfaa70ea0b749dadd52a6b7d62fd3ad2b61d18
Reviewed-on: https://gerrit.openafs.org/12767
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Andrew Deason 2017-11-09 12:47:57 -06:00 committed by Benjamin Kaduk
parent 12b46b6af7
commit 5120409cc9
2 changed files with 47 additions and 7 deletions

View File

@ -17,6 +17,10 @@ B<asetkey> add <I<type>> <I<kvno>> <I<subtype>> <I<keyfile>> <I<princ>>
B<asetkey> delete <I<kvno>>
B<asetkey> delete <I<type>> <I<kvno>>
B<asetkey> delete <I<type>> <I<kvno>> <I<subtype>>
B<asetkey> list
=for html

View File

@ -240,18 +240,52 @@ addKey(struct afsconf_dir *dir, int argc, char **argv) {
static void
deleteKey(struct afsconf_dir *dir, int argc, char **argv)
{
int type;
int subtype;
int kvno;
int code;
if (argc != 3) {
switch (argc) {
case 3:
kvno = atoi(argv[2]);
code = afsconf_DeleteKey(dir, kvno);
if (code) {
afs_com_err(argv[0], code, "while deleting key %d", kvno);
exit(1);
}
printf("Deleted rxkad key %d\n", kvno);
break;
case 4:
type = stringToType(argv[2]);
kvno = atoi(argv[3]);
code = afsconf_DeleteKeyByType(dir, type, kvno);
if (code) {
afs_com_err(argv[0], code, "while deleting key (type %d kvno %d)",
type, kvno);
exit(1);
}
printf("Deleted key (type %d kvno %d)\n", type, kvno);
break;
case 5:
type = stringToType(argv[2]);
kvno = atoi(argv[3]);
subtype = atoi(argv[4]);
code = afsconf_DeleteKeyBySubType(dir, type, kvno, subtype);
if (code) {
afs_com_err(argv[0], code, "while deleting key (type %d kvno %d subtype %d)\n",
type, kvno, subtype);
exit(1);
}
printf("Deleted key (type %d kvno %d subtype %d)\n", type, kvno, subtype);
break;
default:
fprintf(stderr, "%s delete: usage is '%s delete <kvno>\n",
argv[0], argv[0]);
exit(1);
}
kvno = atoi(argv[2]);
code = afsconf_DeleteKey(dir, kvno);
if (code) {
afs_com_err(argv[0], code, "while deleting key %d", kvno);
fprintf(stderr, "\tOR\n\t%s delete <type> <kvno>\n", argv[0]);
fprintf(stderr, "\tOR\n\t%s delete <type> <kvno> <subtype>\n", argv[0]);
exit(1);
}
}
@ -324,6 +358,8 @@ main(int argc, char *argv[])
argv[0]);
fprintf(stderr, "\t\tEx: %s add 0 \"80b6a7cd7a9dadb6\"\n", argv[0]);
fprintf(stderr, "\t%s delete <kvno>\n", argv[0]);
fprintf(stderr, "\t%s delete <type> <kvno>\n", argv[0]);
fprintf(stderr, "\t%s delete <type> <kvno> <subtype>\n", argv[0]);
fprintf(stderr, "\t%s list\n", argv[0]);
exit(1);
}