From 21ddb0df0b5394279f82480257c0cf32f45810a1 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Fri, 25 Jul 1997 19:49:30 +0000 Subject: [PATCH] * loadv4.c: * kdb5_create.c: * kdb5_destroy.c: * dump.c: Update to new kdb API. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10135 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/dbutil/ChangeLog | 7 +++++++ src/kadmin/dbutil/dump.c | 11 ++++++++--- src/kadmin/dbutil/kdb5_create.c | 6 +++++- src/kadmin/dbutil/kdb5_destroy.c | 2 +- src/kadmin/dbutil/loadv4.c | 26 +++++++++++++++----------- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/kadmin/dbutil/ChangeLog b/src/kadmin/dbutil/ChangeLog index 92b0c7fb0..9d0cfac75 100644 --- a/src/kadmin/dbutil/ChangeLog +++ b/src/kadmin/dbutil/ChangeLog @@ -1,3 +1,10 @@ +Fri Jul 25 15:46:24 1997 Tom Yu + + * loadv4.c: + * kdb5_create.c: + * kdb5_destroy.c: + * dump.c: Update to new kdb API. + Thu Jul 17 12:25:41 1997 Ezra Peisach * dump.c (process_k5beta_record): Change variables from char to diff --git a/src/kadmin/dbutil/dump.c b/src/kadmin/dbutil/dump.c index 3a65640fb..194c6abad 100644 --- a/src/kadmin/dbutil/dump.c +++ b/src/kadmin/dbutil/dump.c @@ -208,6 +208,7 @@ static const char oldoption[] = "-old"; static const char b6option[] = "-b6"; static const char verboseoption[] = "-verbose"; static const char updateoption[] = "-update"; +static const char hashoption[] = "-hash"; static const char ovoption[] = "-ov"; static const char dump_tmptrail[] = "~"; @@ -1876,7 +1877,7 @@ restore_dump(programname, kcontext, dumpfile, f, verbose, dump, pol_db) } /* - * Usage: load_db [-old] [-ov] [-b6] [-verbose] [-update] filename + * Usage: load_db [-old] [-ov] [-b6] [-verbose] [-update] [-hash] filename */ void load_db(argc, argv) @@ -1897,6 +1898,7 @@ load_db(argc, argv) char buf[BUFSIZ]; dump_version *load; int update, verbose; + krb5_int32 crflags; int aindex; /* @@ -1910,6 +1912,7 @@ load_db(argc, argv) load = NULL; update = 0; verbose = 0; + crflags = KRB5_KDB_CREATE_BTREE; exit_status = 0; dbname_tmp = (char *) NULL; tmppol_db = NULL; @@ -1924,6 +1927,8 @@ load_db(argc, argv) verbose = 1; else if (!strcmp(argv[aindex], updateoption)) update = 1; + else if (!strcmp(argv[aindex], hashoption)) + crflags = KRB5_KDB_CREATE_HASH; else break; } @@ -2033,7 +2038,7 @@ load_db(argc, argv) * with policy info, because they may be loading an old dump * intending to use it with the new kadm5 system. */ - if (!update && (kret = krb5_db_create(kcontext, dbname_tmp))) { + if (!update && (kret = krb5_db_create(kcontext, dbname_tmp, crflags))) { fprintf(stderr, dbcreaterr_fmt, programname, dbname_tmp, error_message(kret)); exit_status++; @@ -2138,7 +2143,7 @@ error: */ if (!update) { if (exit_status) { - if ((kret = kdb5_db_destroy(kcontext, dbname_tmp))) { + if ((kret = krb5_db_destroy(kcontext, dbname_tmp))) { fprintf(stderr, dbdelerr_fmt, programname, dbname_tmp, error_message(kret)); exit_status++; diff --git a/src/kadmin/dbutil/kdb5_create.c b/src/kadmin/dbutil/kdb5_create.c index 7fe7b0fef..c599228b4 100644 --- a/src/kadmin/dbutil/kdb5_create.c +++ b/src/kadmin/dbutil/kdb5_create.c @@ -132,6 +132,7 @@ void kdb5_create(argc, argv) char *pw_str = 0; int pw_size = 0; int do_stash = 0; + krb5_int32 crflags = KRB5_KDB_CREATE_BTREE; krb5_data pwd; if (strrchr(argv[0], '/')) @@ -142,6 +143,8 @@ void kdb5_create(argc, argv) case 's': do_stash++; break; + case 'h': + crflags = KRB5_KDB_CREATE_HASH; case '?': default: usage(); @@ -232,7 +235,8 @@ master key name '%s'\n", (void) krb5_finish_key(util_context, &master_encblock); exit_status++; return; } - if ((retval = krb5_db_create(util_context, global_params.dbname))) { + if ((retval = krb5_db_create(util_context, + global_params.dbname, crflags))) { (void) krb5_finish_key(util_context, &master_encblock); (void) krb5_finish_random_key(util_context, &master_encblock, &rblock.rseed); com_err(argv[0], retval, "while creating database '%s'", diff --git a/src/kadmin/dbutil/kdb5_destroy.c b/src/kadmin/dbutil/kdb5_destroy.c index c9bdd604d..a0567c8b9 100644 --- a/src/kadmin/dbutil/kdb5_destroy.c +++ b/src/kadmin/dbutil/kdb5_destroy.c @@ -91,7 +91,7 @@ kdb5_destroy(argc, argv) com_err(argv[0], retval, "'%s'",dbname); exit_status++; return; } - retval1 = kdb5_db_destroy(context, dbname); + retval1 = krb5_db_destroy(context, dbname); retval2 = osa_adb_destroy_policy_db(&global_params); if (retval1) { com_err(argv[0], retval1, "deleting database '%s'",dbname); diff --git a/src/kadmin/dbutil/loadv4.c b/src/kadmin/dbutil/loadv4.c index 90fb001e5..01a4bf2a6 100644 --- a/src/kadmin/dbutil/loadv4.c +++ b/src/kadmin/dbutil/loadv4.c @@ -145,6 +145,7 @@ char *argv[]; kadm5_config_params newparams; extern kadm5_config_params global_params; long exp_time = 0; + krb5_int32 crflags = KRB5_KDB_CREATE_BTREE; retval = krb5_init_context(&context); if (retval) { @@ -181,6 +182,9 @@ char *argv[]; usage(); } } + else if (!strcmp(argv[op_ind], "-h")) { + crflags = KRB5_KDB_CREATE_HASH; + } else if ((argc - op_ind) >= 1) { v4dumpfile = argv[op_ind]; op_ind++; @@ -238,7 +242,7 @@ char *argv[]; strcpy(tempdbname, dbname); tempdbname[dbnamelen] = '~'; tempdbname[dbnamelen+1] = 0; - (void) kdb5_db_destroy(context, tempdbname); + (void) krb5_db_destroy(context, tempdbname); } @@ -298,10 +302,10 @@ master key name '%s'\n", krb5_free_context(context); return; } - if (retval = krb5_db_create(context, tempdbname)) { + if (retval = krb5_db_create(context, tempdbname, crflags)) { (void) krb5_finish_key(context, &master_encblock); (void) krb5_finish_random_key(context, &master_encblock, &rblock.rseed); - (void) krb5_dbm_db_destroy(context, tempdbname); + (void) krb5_db_destroy(context, tempdbname); com_err(PROGNAME, retval, "while creating %sdatabase '%s'", tempdb ? "temporary " : "", tempdbname); krb5_free_context(context); @@ -310,7 +314,7 @@ master key name '%s'\n", if (retval = krb5_db_set_name(context, tempdbname)) { (void) krb5_finish_key(context, &master_encblock); (void) krb5_finish_random_key(context, &master_encblock, &rblock.rseed); - (void) krb5_dbm_db_destroy(context, tempdbname); + (void) krb5_db_destroy(context, tempdbname); com_err(PROGNAME, retval, "while setting active database to '%s'", tempdbname); krb5_free_context(context); @@ -319,15 +323,15 @@ master key name '%s'\n", if (v4init(PROGNAME, v4manual, v4dumpfile)) { (void) krb5_finish_key(context, &master_encblock); (void) krb5_finish_random_key(context, &master_encblock, &rblock.rseed); - (void) krb5_dbm_db_destroy(context, tempdbname); + (void) krb5_db_destroy(context, tempdbname); krb5_free_context(context); return; } if ((retval = krb5_db_init(context)) || - (retval = krb5_dbm_db_open_database(context))) { + (retval = krb5_db_open_database(context))) { (void) krb5_finish_key(context, &master_encblock); (void) krb5_finish_random_key(context, &master_encblock, &rblock.rseed); - (void) krb5_dbm_db_destroy(context, tempdbname); + (void) krb5_db_destroy(context, tempdbname); com_err(PROGNAME, retval, "while initializing the database '%s'", tempdbname); krb5_free_context(context); @@ -338,7 +342,7 @@ master key name '%s'\n", (void) krb5_db_fini(context); (void) krb5_finish_key(context, &master_encblock); (void) krb5_finish_random_key(context, &master_encblock, &rblock.rseed); - (void) krb5_dbm_db_destroy(context, tempdbname); + (void) krb5_db_destroy(context, tempdbname); com_err(PROGNAME, retval, "while adding K/M to the database"); krb5_free_context(context); return; @@ -349,7 +353,7 @@ master key name '%s'\n", (void) krb5_db_fini(context); (void) krb5_finish_key(context, &master_encblock); (void) krb5_finish_random_key(context, &master_encblock, &rblock.rseed); - (void) krb5_dbm_db_destroy(context, tempdbname); + (void) krb5_db_destroy(context, tempdbname); com_err(PROGNAME, retval, "while adding TGT service to the database"); krb5_free_context(context); return; @@ -372,13 +376,13 @@ master key name '%s'\n", if (retval == 0) { if (retval = krb5_db_fini (context)) com_err(PROGNAME, retval, "while shutting down database"); - else if (tempdb && (retval = krb5_dbm_db_rename(context, tempdbname, + else if (tempdb && (retval = krb5_db_rename(context, tempdbname, dbname))) com_err(PROGNAME, retval, "while renaming temporary database"); } else { (void) krb5_db_fini (context); if (tempdb) - (void) krb5_dbm_db_destroy (context, tempdbname); + (void) krb5_db_destroy (context, tempdbname); } (void) krb5_finish_key(context, &master_encblock); (void) krb5_finish_random_key(context, &master_encblock, &rblock.rseed); -- 2.26.2