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;
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
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;
}