int argc;
char **argv;
{
- kadm5_config_params newparams;
krb5_error_code kret;
krb5_context kcontext;
FILE *f;
extern int optind;
char *dumpfile;
char *dbname;
- char *dbname_tmp;
char buf[BUFSIZ];
dump_version *load;
int flags;
flags = 0;
crflags = KRB5_KDB_CREATE_BTREE;
exit_status = 0;
- dbname_tmp = (char *) NULL;
log_ctx = util_context->kdblog_context;
for (aindex = 1; aindex < argc; aindex++) {
}
dumpfile = argv[aindex];
- if (asprintf(&dbname_tmp, "%s%s", dbname, dump_tmptrail) < 0) {
- fprintf(stderr, no_name_mem_fmt, progname);
- exit_status++;
- return;
- }
-
/*
* Initialize the Kerberos context and error tables.
*/
if ((kret = kadm5_init_krb5_context(&kcontext))) {
fprintf(stderr, ctx_err_fmt, progname);
- free(dbname_tmp);
exit_status++;
return;
}
if( (kret = krb5_set_default_realm(kcontext, util_context->default_realm)) )
{
fprintf(stderr, "%s: Unable to set the default realm\n", progname);
- free(dbname_tmp);
exit_status++;
return;
}
* mode, we create an alternate database and then promote it to
* be the live db.
*/
- newparams = global_params;
if (! (flags & FLAG_UPDATE)) {
- newparams.mask |= KADM5_CONFIG_DBNAME;
- newparams.dbname = dbname_tmp;
-
- if ((kret = kadm5_get_config_params(kcontext, 1,
- &newparams, &newparams))) {
- com_err(progname, kret,
- "while retreiving new configuration parameters");
- exit_status++;
- return;
- }
-
if (!add_db_arg("temporary")) {
com_err(progname, ENOMEM, "computing parameters for database");
exit(1);
com_err(progname, ENOMEM, "computing parameters for database");
exit(1);
}
- }
- /*
- * If not an update restoration, create the database. otherwise open
- */
- if (!(flags & FLAG_UPDATE)) {
if((kret = krb5_db_create(kcontext, db5util_db_args))) {
const char *emsg = krb5_get_error_message(kcontext, kret);
/*
progname, dbname, error_message(kret));
}
exit_status++;
- kadm5_free_config_params(kcontext, &newparams);
if (dumpfile) fclose(f);
return;
}
}
if (!(flags & FLAG_UPDATE) && load->create_kadm5 &&
- ((kret = kadm5_create_magic_princs(&newparams, kcontext)))) {
+ ((kret = kadm5_create_magic_princs(&global_params, kcontext)))) {
/* error message printed by create_magic_princs */
exit_status++;
}
fclose(f);
}
- if (dbname_tmp)
- free(dbname_tmp);
krb5_free_context(kcontext);
}