From 8ca2bf1ef6ba62ff8a17f119ec237b9b3c5a1771 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Mon, 4 Jun 2001 21:17:17 +0000 Subject: [PATCH] * kadm5_create.c: Add prototype for static add_admin_princs(). Cleanup calling of add_admin_princs() to be consistant with prototype. * kdb5_create.c, kdb5_stash.c, kdb5_destroy.c: Cleanup assignments in conditionals. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13267 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/dbutil/ChangeLog | 9 ++++++++ src/kadmin/dbutil/kadm5_create.c | 17 +++++++------- src/kadmin/dbutil/kdb5_create.c | 21 +++++++++-------- src/kadmin/dbutil/kdb5_destroy.c | 4 ++-- src/kadmin/dbutil/kdb5_stash.c | 39 +++++++++++++++++++------------- 5 files changed, 55 insertions(+), 35 deletions(-) diff --git a/src/kadmin/dbutil/ChangeLog b/src/kadmin/dbutil/ChangeLog index 4b62233fd..10e2df034 100644 --- a/src/kadmin/dbutil/ChangeLog +++ b/src/kadmin/dbutil/ChangeLog @@ -1,3 +1,12 @@ +2001-06-04 Ezra Peisach + + * kadm5_create.c: Add prototype for static + add_admin_princs(). Cleanup calling of add_admin_princs() to be + consistant with prototype. + + * kdb5_create.c, kdb5_stash.c, kdb5_destroy.c: Cleanup assignments + in conditionals. + Mon Feb 26 15:01:27 2001 Ezra Peisach * loadv4.c, ovload.c, kdb5_util.h, kdb5_util.c, kadm5_create.c, diff --git a/src/kadmin/dbutil/kadm5_create.c b/src/kadmin/dbutil/kadm5_create.c index 1c432ef73..d4f326a39 100644 --- a/src/kadmin/dbutil/kadm5_create.c +++ b/src/kadmin/dbutil/kadm5_create.c @@ -51,6 +51,7 @@ static char *rcsid = "$Header$"; static int add_admin_princ(void *handle, krb5_context context, char *name, char *realm, int attrs, int lifetime); +static int add_admin_princs(void *handle, krb5_context context, char *realm); #define ERR 1 #define OK 0 @@ -119,7 +120,7 @@ int kadm5_create_magic_princs(kadm5_config_params *params, return retval; } - retval = add_admin_princs(handle, &context, params->realm); + retval = add_admin_princs(handle, context, params->realm); kadm5_destroy(handle); @@ -229,25 +230,25 @@ int add_admin_princ(void *handle, krb5_context context, char *name, char *realm, int attrs, int lifetime) { char *fullname; - int nprincs; krb5_error_code ret; kadm5_principal_ent_rec ent; memset(&ent, 0, sizeof(ent)); fullname = build_name_with_realm(name, realm); - if (ret = krb5_parse_name(context, fullname, &ent.principal)) { + ret = krb5_parse_name(context, fullname, &ent.principal); + if (ret) { com_err(progname, ret, str_PARSE_NAME); return(ERR); } ent.max_life = lifetime; ent.attributes = attrs | KRB5_KDB_DISALLOW_ALL_TIX; - if (ret = kadm5_create_principal(handle, &ent, - (KADM5_PRINCIPAL | - KADM5_MAX_LIFE | - KADM5_ATTRIBUTES), - "to-be-random")) { + ret = kadm5_create_principal(handle, &ent, + (KADM5_PRINCIPAL | KADM5_MAX_LIFE | + KADM5_ATTRIBUTES), + "to-be-random"); + if (ret) { if (ret != KADM5_DUP) { com_err(progname, ret, str_PUT_PRINC, fullname); krb5_free_principal(context, ent.principal); diff --git a/src/kadmin/dbutil/kdb5_create.c b/src/kadmin/dbutil/kdb5_create.c index ee2982f44..f10f6a4f8 100644 --- a/src/kadmin/dbutil/kdb5_create.c +++ b/src/kadmin/dbutil/kdb5_create.c @@ -240,8 +240,10 @@ master key name '%s'\n", com_err(argv[0], retval, "while calculated master key salt"); exit_status++; return; } - if (retval = krb5_c_string_to_key(util_context, master_keyblock.enctype, - &pwd, &master_salt, &master_keyblock)) { + + retval = krb5_c_string_to_key(util_context, master_keyblock.enctype, + &pwd, &master_salt, &master_keyblock); + if (retval) { com_err(argv[0], retval, "while transforming master key from password"); exit_status++; return; } @@ -261,7 +263,7 @@ master key name '%s'\n", global_params.dbname); exit_status++; return; } - if (retval = krb5_db_fini(util_context)) { + if ((retval = krb5_db_fini(util_context))) { com_err(argv[0], retval, "while closing current database"); exit_status++; return; } @@ -287,10 +289,11 @@ master key name '%s'\n", * it; delete the file below if it was not requested. DO NOT EXIT * BEFORE DELETING THE KEYFILE if do_stash is not set. */ - if (retval = krb5_db_store_mkey(util_context, - global_params.stash_file, - master_princ, - &master_keyblock)) { + retval = krb5_db_store_mkey(util_context, + global_params.stash_file, + master_princ, + &master_keyblock); + if (retval) { com_err(argv[0], errno, "while storing key"); printf("Warning: couldn't stash master key.\n"); } @@ -324,7 +327,6 @@ tgt_keysalt_iterate(ksent, ptr) struct iterate_args *iargs; krb5_keyblock key; krb5_int32 ind; - krb5_pointer rseed; krb5_data pwd; iargs = (struct iterate_args *) ptr; @@ -338,7 +340,8 @@ tgt_keysalt_iterate(ksent, ptr) */ pwd.data = mkey_password; pwd.length = strlen(mkey_password); - if (kret = krb5_c_random_seed(context, &pwd)) + kret = krb5_c_random_seed(context, &pwd); + if (kret) return kret; if (!(kret = krb5_dbe_create_key_data(iargs->ctx, iargs->dbentp))) { diff --git a/src/kadmin/dbutil/kdb5_destroy.c b/src/kadmin/dbutil/kdb5_destroy.c index 51fe7ac01..ea2fb7142 100644 --- a/src/kadmin/dbutil/kdb5_destroy.c +++ b/src/kadmin/dbutil/kdb5_destroy.c @@ -53,7 +53,6 @@ kdb5_destroy(argc, argv) int optchar; char *dbname; char buf[5]; - char dbfilename[MAXPATHLEN]; krb5_error_code retval, retval1, retval2; krb5_context context; int force = 0; @@ -90,7 +89,8 @@ kdb5_destroy(argc, argv) printf("OK, deleting database '%s'...\n", dbname); } - if (retval = krb5_db_set_name(context, dbname)) { + retval = krb5_db_set_name(context, dbname); + if (retval) { com_err(argv[0], retval, "'%s'",dbname); exit_status++; return; } diff --git a/src/kadmin/dbutil/kdb5_stash.c b/src/kadmin/dbutil/kdb5_stash.c index 419d14f66..46a2c6192 100644 --- a/src/kadmin/dbutil/kdb5_stash.c +++ b/src/kadmin/dbutil/kdb5_stash.c @@ -83,8 +83,6 @@ char *argv[]; char *keyfile = 0; krb5_context context; - int enctypedone = 0; - if (strrchr(argv[0], '/')) argv[0] = strrchr(argv[0], '/')+1; @@ -121,50 +119,59 @@ char *argv[]; exit_status++; return; } - if (retval = krb5_db_set_name(context, dbname)) { + retval = krb5_db_set_name(context, dbname); + if (retval) { com_err(argv[0], retval, "while setting active database to '%s'", dbname); exit_status++; return; } /* assemble & parse the master key name */ - - if (retval = krb5_db_setup_mkey_name(context, mkey_name, realm, - &mkey_fullname, &master_princ)) { + retval = krb5_db_setup_mkey_name(context, mkey_name, realm, + &mkey_fullname, &master_princ); + if (retval) { com_err(argv[0], retval, "while setting up master key name"); exit_status++; return; } - if (retval = krb5_db_init(context)) { + retval = krb5_db_init(context); + if (retval) { com_err(argv[0], retval, "while initializing the database '%s'", dbname); exit_status++; return; } /* TRUE here means read the keyboard, but only once */ - if (retval = krb5_db_fetch_mkey(context, master_princ, - master_keyblock.enctype, - TRUE, FALSE, (char *) NULL, - 0, &master_keyblock)) { + retval = krb5_db_fetch_mkey(context, master_princ, + master_keyblock.enctype, + TRUE, FALSE, (char *) NULL, + 0, &master_keyblock); + if (retval) { com_err(argv[0], retval, "while reading master key"); (void) krb5_db_fini(context); exit_status++; return; } - if (retval = krb5_db_verify_master_key(context, master_princ, - &master_keyblock)) { + + retval = krb5_db_verify_master_key(context, master_princ, + &master_keyblock); + if (retval) { com_err(argv[0], retval, "while verifying master key"); (void) krb5_db_fini(context); exit_status++; return; } - if (retval = krb5_db_store_mkey(context, keyfile, master_princ, - &master_keyblock)) { + + retval = krb5_db_store_mkey(context, keyfile, master_princ, + &master_keyblock); + if (retval) { com_err(argv[0], errno, "while storing key"); memset((char *)master_keyblock.contents, 0, master_keyblock.length); (void) krb5_db_fini(context); exit_status++; return; } memset((char *)master_keyblock.contents, 0, master_keyblock.length); - if (retval = krb5_db_fini(context)) { + + retval = krb5_db_fini(context); + if (retval) { com_err(argv[0], retval, "closing database '%s'", dbname); exit_status++; return; } -- 2.26.2