Use the string form of key types in asetkey

Check for rxkad-k5 keys in the six-argument form and warn they are
unsupported.  Do sanity-checking on the type.

(cherry-picked from fe73ac62fb)

Change-Id: I59fc1702dc1b201340dc033adeb8aa57251feee6
This commit is contained in:
Ben Kaduk 2013-07-12 12:53:46 -04:00 committed by Simon Wilkinson
parent 7dea66612a
commit 1cd7e3cff5

View File

@ -197,10 +197,24 @@ addKey(struct afsconf_dir *dir, int argc, char **argv) {
kvno = atoi(argv[3]);
if (type == afsconf_rxkad) {
typedKey = keyFromCommandLine(afsconf_rxkad, kvno, 0, argv[5], 8);
} else if (type == afsconf_rxkad_krb5){
fprintf(stderr, "Raw keys for afsconf_rxkad_krb5 are unsupported");
exit(1);
} else {
fprintf(stderr, "Unknown key type %s\n", argv[2]);
exit(1);
}
break;
case 7:
typedKey = keyFromKeytab(atoi(argv[3]), atoi(argv[2]), atoi(argv[4]), argv[5], argv[6]);
type = stringToType(argv[2]);
kvno = atoi(argv[3]);
if (type == afsconf_rxkad || type == afsconf_rxkad_krb5) {
typedKey = keyFromKeytab(kvno, type, atoi(argv[4]), argv[5],
argv[6]);
} else {
fprintf(stderr, "Unknown key type %s\n", argv[2]);
exit(1);
}
break;
default:
fprintf(stderr, "%s add: usage is '%s add <kvno> <keyfile> "