From: Theodore Tso Date: Tue, 5 Feb 1991 13:25:07 +0000 (+0000) Subject: Changed so that kdb5_edit can be run even if there is no valid X-Git-Tag: krb5-1.0-alpha4~324 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=578595ec58ac5c5ce66051a31f96543824301ed4;p=krb5.git Changed so that kdb5_edit can be run even if there is no valid database. (Needed for slave propagation to do the load_db request). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1648 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/admin/edit/kdb5_edit.c b/src/admin/edit/kdb5_edit.c index c0c218e08..86856a029 100644 --- a/src/admin/edit/kdb5_edit.c +++ b/src/admin/edit/kdb5_edit.c @@ -48,6 +48,7 @@ struct mblock { }; char *Err_no_master_msg = "Master key not entered!\n"; +char *Err_no_database = "Database not currently opened!\n"; char *current_dbname = NULL; /* krb5_kvno may be narrow */ @@ -203,8 +204,7 @@ char *argv[]; } cur_realm = defrealm; } - if (retval = set_dbname_help(progname, dbname)) - exit(retval); + (void) set_dbname_help(progname, dbname); if (request) { (void) ss_execute_line(sci_idx, request, &code); @@ -412,6 +412,10 @@ krb5_pointer infop; (void) krb5_finish_key(&master_encblock); (void) krb5_finish_random_key(&master_encblock, &master_random); + memset((char *)master_keyblock.contents, 0, + master_keyblock.length); + free((char *) master_keyblock.contents); + master_keyblock.contents = NULL; } krb5_free_principal(master_princ); dbactive = FALSE; @@ -497,13 +501,19 @@ char *dbname; if (retval = krb5_db_verify_master_key(master_princ, &master_keyblock, &master_encblock)) { com_err(pname, retval, "while verifying master key"); - (void) krb5_db_fini(); + memset((char *)master_keyblock.contents, 0, master_keyblock.length); + free((char *)master_keyblock.contents); + valid_master_key = 0; + dbactive = TRUE; return(1); } if (retval = krb5_process_key(&master_encblock, &master_keyblock)) { com_err(pname, retval, "while processing master key"); - (void) krb5_db_fini(); + memset((char *)master_keyblock.contents, 0, master_keyblock.length); + free((char *)master_keyblock.contents); + valid_master_key = 0; + dbactive = TRUE; return(1); } if (retval = krb5_init_random_key(&master_encblock, @@ -511,7 +521,10 @@ char *dbname; &master_random)) { com_err(pname, retval, "while initializing random key generator"); (void) krb5_finish_key(&master_encblock); - (void) krb5_db_fini(); + memset((char *)master_keyblock.contents, 0, master_keyblock.length); + free((char *)master_keyblock.contents); + valid_master_key = 0; + dbactive = TRUE; return(1); } dbactive = TRUE; @@ -526,7 +539,7 @@ void enter_master_key(argc, argv) krb5_error_code retval; if (!dbactive) { - com_err(pname, 0, "Kerberos database not selected"); + com_err(pname, 0, Err_no_database); return; } if (retval = krb5_db_fetch_mkey(master_princ, &master_encblock, @@ -587,6 +600,10 @@ char *argv[]; com_err(argv[0], 0, "Usage: %s instance name [name ...]", argv[0]); return; } + if (!dbactive) { + com_err(argv[0], 0, Err_no_database); + return; + } if (!valid_master_key) { com_err(argv[0], 0, Err_no_master_msg); return; @@ -693,6 +710,10 @@ char *argv[]; com_err(argv[0], 0, "Usage: %s instance name [name ...]", argv[0]); return; } + if (!dbactive) { + com_err(argv[0], 0, Err_no_database); + return; + } if (!valid_master_key) { com_err(argv[0], 0, Err_no_master_msg); return; @@ -803,6 +824,10 @@ list_db(argc, argv) int argc; char *argv[]; { + if (!dbactive) { + com_err(argv[0], 0, Err_no_database); + return; + } if (!valid_master_key) { com_err(argv[0], 0, Err_no_master_msg); return; @@ -825,6 +850,10 @@ char *argv[]; com_err(argv[0], 0, "Usage: %s principal", argv[0]); return; } + if (!dbactive) { + com_err(argv[0], 0, Err_no_database); + return; + } if (!valid_master_key) { com_err(argv[0], 0, Err_no_master_msg); return; @@ -876,6 +905,10 @@ char *argv[]; com_err(argv[0], 0, "Usage: %s principal", argv[0]); return; } + if (!dbactive) { + com_err(argv[0], 0, Err_no_database); + return; + } if (!valid_master_key) { com_err(argv[0], 0, Err_no_master_msg); return; @@ -929,6 +962,10 @@ char *argv[]; com_err(argv[0], 0, "Usage: %s principal", argv[0]); return; } + if (!dbactive) { + com_err(argv[0], 0, Err_no_database); + return; + } if (!valid_master_key) { com_err(argv[0], 0, Err_no_master_msg); return; @@ -961,6 +998,10 @@ char *argv[]; com_err(argv[0], 0, "Usage: %s principal", argv[0]); return; } + if (!dbactive) { + com_err(argv[0], 0, Err_no_database); + return; + } if (!valid_master_key) { com_err(argv[0], 0, Err_no_master_msg); return;