From 9f4a4c5938a3cb89c7e0693ca5a195e9678569cf Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Mon, 30 Oct 1995 15:59:04 +0000 Subject: [PATCH] When showing a principal with the "show" command, iterate through the keys, displaying the version number and type. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7004 dc483132-0cff-0310-8789-dd5450dbe970 --- src/admin/edit/kdb5_edit.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/admin/edit/kdb5_edit.c b/src/admin/edit/kdb5_edit.c index 9c7c202d0..b2d8dba0a 100644 --- a/src/admin/edit/kdb5_edit.c +++ b/src/admin/edit/kdb5_edit.c @@ -1045,6 +1045,7 @@ void show_principal(argc, argv) krb5_error_code retval; char *pr_name = 0; char buffer[256]; + int i; if (argc < 2) { com_err(argv[0], 0, "Too few arguments"); @@ -1089,7 +1090,6 @@ void show_principal(argc, argv) } printf("Name: %s\n", pr_name); - printf("Key version: %d\n", entry.key_data[0].key_data_kvno); printf("Maximum life: %s\n", strdur(entry.max_life)); printf("Maximum renewable life: %s\n", strdur(entry.max_renewable_life)); printf("Master key version: %d\n", entry.mkvno); @@ -1113,13 +1113,32 @@ void show_principal(argc, argv) (void) krb5_flags_to_string(entry.attributes, ", ", buffer, sizeof(buffer)); printf("Attributes: %s\n", buffer); - /* printf("Salt: %d\n", entry.salt_type); - printf("Alt salt: %d\n", entry.salt_type); */ - - if (!nprincs) { - com_err(argv[0], 0, "Principal '%s' does not exist", argv[1]); - exit_status++; - goto errout; + + printf("Number of keys: %d\n", entry.n_key_data); + for (i = 0; i < entry.n_key_data; i++) { + char enctype[64], salttype[32]; + krb5_keyblock key; + krb5_keysalt salt; + + if ((retval = krb5_dbekd_decrypt_key_data(edit_context, + &master_encblock, + &entry.key_data[i], + &key, &salt))) { + com_err(argv[0], retval, "while reading key information"); + continue; + } + + /* Paranoia... */ + memset((char *)key.contents, 0, key.length); + krb5_xfree(key.contents); + + if (krb5_enctype_to_string(key.enctype, enctype, sizeof(enctype))) + sprintf(enctype, "", key.enctype); + if (krb5_salttype_to_string(salt.type, salttype, sizeof(salttype))) + sprintf(salttype, "", salt.type); + + printf("Key: Version %d, Type %s/%s\n", + entry.key_data[i].key_data_kvno, enctype, salttype); } errout: -- 2.26.2