diff options
author | Paul Park <pjpark@mit.edu> | 1995-08-07 21:42:42 +0000 |
---|---|---|
committer | Paul Park <pjpark@mit.edu> | 1995-08-07 21:42:42 +0000 |
commit | d05b4069c6086aef0917b33b108709fdb413a6aa (patch) | |
tree | 890ca139642fc38776d13dd2cc061d4d2e858d04 | |
parent | 38ee61f81fb3c4bf81ff189f7ad03913e2184694 (diff) | |
download | krb5-d05b4069c6086aef0917b33b108709fdb413a6aa.tar.gz krb5-d05b4069c6086aef0917b33b108709fdb413a6aa.tar.xz krb5-d05b4069c6086aef0917b33b108709fdb413a6aa.zip |
Use krb5_string_to_keysalts() to ensure that list is unique
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6438 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r-- | src/admin/edit/ChangeLog | 5 | ||||
-rw-r--r-- | src/admin/edit/cpw.c | 55 |
2 files changed, 16 insertions, 44 deletions
diff --git a/src/admin/edit/ChangeLog b/src/admin/edit/ChangeLog index b6457060f..0e5756fd5 100644 --- a/src/admin/edit/ChangeLog +++ b/src/admin/edit/ChangeLog @@ -1,4 +1,9 @@ +Mon Aug 7 17:32:31 EDT 1995 Paul Park (pjpark@mit.edu) + * cpw.c - Use krb5_string_to_keysalts() to generate a list of unique + key/salt pairs supplied in argv. + + Mon Aug 07 11:16:03 1995 Chris Provenzano (proven@mit.edu) * cpw.c : Uses new kdb change password routines for ank, ark, cpw, diff --git a/src/admin/edit/cpw.c b/src/admin/edit/cpw.c index dbf3f503b..9c121f89f 100644 --- a/src/admin/edit/cpw.c +++ b/src/admin/edit/cpw.c @@ -235,6 +235,7 @@ void change_pwd_key(argc, argv) char *argv[]; { krb5_key_salt_tuple * ks_tuple = NULL; + krb5_int32 n_ks_tuple = 0; krb5_error_code retval; krb5_principal newprinc; krb5_db_entry entry; @@ -245,64 +246,30 @@ void change_pwd_key(argc, argv) if (argc < 2) { com_err(argv[0], 0, "Too few arguments"); - com_err(argv[0], 0, "Usage: %s [-<key_type[:<salt_type>]> principal", + com_err(argv[0], 0, "Usage: %s [<key_type[:<salt_type>]>] principal", argv[0]); exit_status++; return; } for (i = 1; i < (argc - 1); i++) { - char * salt_type_name; - - if (!ks_tuple) { - ks_tuple = (krb5_key_salt_tuple *)malloc( - sizeof(krb5_key_salt_tuple)); - } else { - ks_tuple = (krb5_key_salt_tuple *)realloc(ks_tuple, - sizeof(krb5_key_salt_tuple) * i); - } - if (!ks_tuple) { - com_err(argv[0], 0, "Insufficient memory to proceed"); + if (krb5_string_to_keysalts(argv[i], + "", + ":", + 0, + &ks_tuple, + &n_ks_tuple)) { + com_err(argv[0], 0, "Unrecognized key/salt type %s", argv[i]); exit_status++; return; } - - while (salt_type_name = strchr(argv[i], ':')) { - *salt_type_name++ = '\0'; - if (!strcmp(salt_type_name, "v4")) { - ks_tuple[i - 1].ks_salttype = KRB5_KDB_SALTTYPE_V4; - break; - } - if (!strcmp(salt_type_name, "normal")) { - ks_tuple[i - 1].ks_salttype = KRB5_KDB_SALTTYPE_NORMAL; - break; - } - if (!strcmp(salt_type_name, "norealm")) { - ks_tuple[i - 1].ks_salttype = KRB5_KDB_SALTTYPE_NOREALM; - break; - } - if (!strcmp(salt_type_name, "onlyrealm")) { - ks_tuple[i - 1].ks_salttype = KRB5_KDB_SALTTYPE_ONLYREALM; - break; - } - com_err(argv[0], 0, "Unknown salt type %s", salt_type_name); - exit_status++; - return; - } - - if (!strcmp(argv[i], "des")) { - ks_tuple[i - 1].ks_keytype = KRB5_KDB_SALTTYPE_ONLYREALM; - continue; - } - com_err(argv[0], 0, "Unknown key type %s", argv[i]); - goto change_pwd_key_error; } switch (pre_key(argc, argv, &newprinc, &entry)) { case 1: /* Done with principal */ krb5_free_principal(edit_context, newprinc); - enter_pwd_key(argv[0], argv[i], ks_tuple, i-1, &entry); + enter_pwd_key(argv[0], argv[i], ks_tuple, n_ks_tuple, &entry); break; case 0: com_err(argv[0], 0, "No principal '%s' exists", argv[i]); @@ -327,7 +294,7 @@ void add_new_key(argc, argv) if (argc < 2) { com_err(argv[0], 0, "Too few arguments"); - com_err(argv[0], 0, "Usage: %s [-<key_type[:<salt_type>]> principal", + com_err(argv[0], 0, "Usage: %s [<key_type[:<salt_type>]>] principal", argv[0]); exit_status++; return; |