From: Greg Hudson Date: Mon, 21 Jun 2010 20:29:12 +0000 (+0000) Subject: Eliminate a bunch of duplicated code in kdb5_stash() by using X-Git-Tag: krb5-1.9-beta1~185 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ec0105acd554d50bc757dbe23ffe8e986f3a1ce4;p=krb5.git Eliminate a bunch of duplicated code in kdb5_stash() by using util_context. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24142 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/dbutil/kdb5_stash.c b/src/kadmin/dbutil/kdb5_stash.c index 422a3fbb0..0da44ac4a 100644 --- a/src/kadmin/dbutil/kdb5_stash.c +++ b/src/kadmin/dbutil/kdb5_stash.c @@ -78,28 +78,11 @@ kdb5_stash(argc, argv) int optchar; krb5_error_code retval; char *dbname = (char *) NULL; - char *realm = 0; char *mkey_name = 0; - char *mkey_fullname; char *keyfile = 0; - krb5_context context; krb5_kvno mkey_kvno; - retval = kadm5_init_krb5_context(&context); - if( retval ) - { - com_err(progname, retval, "while initializing krb5_context"); - exit(1); - } - - if ((retval = krb5_set_default_realm(context, - util_context->default_realm))) { - com_err(progname, retval, "while setting default realm name"); - exit(1); - } - dbname = global_params.dbname; - realm = global_params.realm; mkey_name = global_params.mkey_name; keyfile = global_params.stash_file; @@ -127,22 +110,6 @@ kdb5_stash(argc, argv) exit_status++; return; } - /* assemble & parse the master key name */ - retval = krb5_db_setup_mkey_name(context, mkey_name, realm, - &mkey_fullname, &master_princ); - if (retval) { - com_err(progname, retval, "while setting up master key name"); - exit_status++; return; - } - - retval = krb5_db_open(context, db5util_db_args, - KRB5_KDB_OPEN_RW | KRB5_KDB_SRV_TYPE_ADMIN); - if (retval) { - com_err(progname, retval, "while initializing the database '%s'", - dbname); - exit_status++; return; - } - if (global_params.mask & KADM5_CONFIG_KVNO) mkey_kvno = global_params.kvno; /* user specified */ else @@ -150,44 +117,39 @@ kdb5_stash(argc, argv) if (!valid_master_key) { /* TRUE here means read the keyboard, but only once */ - retval = krb5_db_fetch_mkey(context, master_princ, + retval = krb5_db_fetch_mkey(util_context, master_princ, master_keyblock.enctype, TRUE, FALSE, (char *) NULL, &mkey_kvno, NULL, &master_keyblock); if (retval) { com_err(progname, retval, "while reading master key"); - (void) krb5_db_fini(context); exit_status++; return; } - retval = krb5_db_fetch_mkey_list(context, master_princ, + retval = krb5_db_fetch_mkey_list(util_context, master_princ, &master_keyblock, mkey_kvno, &master_keylist); if (retval) { com_err(progname, retval, "while getting master key list"); - (void) krb5_db_fini(context); exit_status++; return; } } else { printf("Using existing stashed keys to update stash file.\n"); } - retval = krb5_db_store_master_key_list(context, keyfile, master_princ, + retval = krb5_db_store_master_key_list(util_context, keyfile, master_princ, master_keylist, NULL); if (retval) { com_err(progname, errno, "while storing key"); - (void) krb5_db_fini(context); exit_status++; return; } - retval = krb5_db_fini(context); if (retval) { com_err(progname, retval, "closing database '%s'", dbname); exit_status++; return; } - krb5_free_context(context); exit_status = 0; return; }