From: Ezra Peisach Date: Mon, 26 Feb 2001 20:03:16 +0000 (+0000) Subject: * loadv4.c, ovload.c, kdb5_util.h, kdb5_util.c, kadm5_create.c, X-Git-Tag: krb5-1.3-alpha1~1651 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2b3491d27bf17b80d2178a7a3f7056f34d6672cc;p=krb5.git * loadv4.c, ovload.c, kdb5_util.h, kdb5_util.c, kadm5_create.c, dumpv4.c, dump.c: Compiler warning cleanup including prototypes, assignments in conditionals, unused variables, varaibles shadowing one-another. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13028 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/dbutil/ChangeLog b/src/kadmin/dbutil/ChangeLog index 94745aa6c..4b62233fd 100644 --- a/src/kadmin/dbutil/ChangeLog +++ b/src/kadmin/dbutil/ChangeLog @@ -1,3 +1,10 @@ +Mon Feb 26 15:01:27 2001 Ezra Peisach + + * loadv4.c, ovload.c, kdb5_util.h, kdb5_util.c, kadm5_create.c, + dumpv4.c, dump.c: Compiler warning cleanup including prototypes, + assignments in conditionals, unused variables, varaibles shadowing + one-another. + 2001-02-08 Tom Yu * loadv4.c: Remove references to KRB_NEVERDATE. diff --git a/src/kadmin/dbutil/dump.c b/src/kadmin/dbutil/dump.c index bbaf18fc4..3ecb1111f 100644 --- a/src/kadmin/dbutil/dump.c +++ b/src/kadmin/dbutil/dump.c @@ -40,10 +40,6 @@ /* * Needed for master key conversion. */ -extern krb5_keyblock master_keyblock; -extern krb5_principal master_princ; -extern int valid_master_key; -extern void usage(); static int mkey_convert; static krb5_keyblock new_master_keyblock; @@ -246,7 +242,7 @@ static const char dump_tmptrail[] = "~"; /* * Re-encrypt the key_data with the new master key... */ -krb5_error_code master_key_convert(context, db_entry) +static krb5_error_code master_key_convert(context, db_entry) krb5_context context; krb5_db_entry * db_entry; { @@ -458,6 +454,7 @@ find_enctype(dbentp, enctype, salttype, kentp) return(ENOENT); } +#if 0 /* * dump_k5beta_header() - Make a dump header that is recognizable by Kerberos * Version 5 Beta 5 and previous releases. @@ -470,6 +467,7 @@ dump_k5beta_header(arglist) fprintf(arglist->ofile, k5beta_dump_header); return(0); } +#endif /* * dump_k5beta_iterator() - Dump an entry in a format that is usable @@ -891,7 +889,7 @@ void dump_k5beta7_policy(void *data, osa_policy_ent_t entry) entry->policy_refcnt); } -void print_key_data(FILE *f, krb5_key_data *key_data) +static void print_key_data(FILE *f, krb5_key_data *key_data) { int c; @@ -1901,7 +1899,8 @@ process_k5beta6_record(fname, kcontext, filep, verbose, linenop, pol_db) return(retval); } -int process_k5beta7_policy(fname, kcontext, filep, verbose, linenop, pol_db) +static int +process_k5beta7_policy(fname, kcontext, filep, verbose, linenop, pol_db) char *fname; krb5_context kcontext; FILE *filep; diff --git a/src/kadmin/dbutil/dumpv4.c b/src/kadmin/dbutil/dumpv4.c index 2343987b1..0afbadae9 100644 --- a/src/kadmin/dbutil/dumpv4.c +++ b/src/kadmin/dbutil/dumpv4.c @@ -81,12 +81,6 @@ struct dump_record { char *realm; }; -extern krb5_keyblock master_keyblock; -extern krb5_principal master_princ; -extern krb5_boolean dbactive; -extern int exit_status; -extern krb5_context util_context; -extern kadm5_config_params global_params; void update_ok_file(); @@ -95,6 +89,11 @@ void update_ok_file(); static char *v4_mkeyfile = "/.k"; static int shortlife; +static krb5_error_code handle_one_key(struct dump_record *arg, + krb5_keyblock *v5mkey, + krb5_key_data *v5key, + des_cblock v4key); +static int handle_keys(struct dump_record *arg); static int v4init(arg, manual) @@ -122,6 +121,7 @@ v4init(arg, manual) return 0; } +static void v4_print_time(file, timeval) FILE *file; unsigned long timeval; @@ -139,7 +139,7 @@ v4_print_time(file, timeval) -krb5_error_code +static krb5_error_code dump_v4_iterator(ptr, entry) krb5_pointer ptr; krb5_db_entry *entry; @@ -186,8 +186,8 @@ dump_v4_iterator(ptr, entry) strcpy(principal->instance, "*"); /* Now move to mod princ */ - if (retval = krb5_dbe_lookup_mod_princ_data(util_context,entry, - &mod_time, &mod_princ)){ + if ((retval = krb5_dbe_lookup_mod_princ_data(util_context,entry, + &mod_time, &mod_princ))){ com_err(arg->comerr_name, retval, "while unparsing db entry"); exit_status++; return retval; @@ -342,7 +342,7 @@ void dump_v4db(argc, argv) /* special handling for K.M since it isn't preserved */ { des_cblock v4key; - int i; + int i2; /* assume: max lifetime (255) @@ -369,9 +369,9 @@ void dump_v4db(argc, argv) ENCRYPT); #endif /* KDB4_DISABLE */ - for (i=0; i<8; i++) { - fprintf(f, "%02x", ((unsigned char*)v4key)[i]); - if (i == 3) fputc(' ', f); + for (i2=0; i2<8; i2++) { + fprintf(f, "%02x", ((unsigned char*)v4key)[i2]); + if (i2 == 3) fputc(' ', f); } fprintf(f," 200001010459 197001020000 db_creation *\n"); } @@ -384,16 +384,16 @@ void dump_v4db(argc, argv) update_ok_file(outname); } -int handle_keys(arg) +static int handle_keys(arg) struct dump_record *arg; { krb5_error_code retval; char *defrealm; char *mkey_name = 0; char *mkey_fullname; - krb5_principal master_princ; + krb5_principal l_master_princ; - if (retval = krb5_get_default_realm(util_context, &defrealm)) { + if ((retval = krb5_get_default_realm(util_context, &defrealm))) { com_err(arg->comerr_name, retval, "while retrieving default realm name"); exit(1); @@ -402,16 +402,16 @@ int handle_keys(arg) /* assemble & parse the master key name */ - if (retval = krb5_db_setup_mkey_name(util_context, mkey_name, arg->realm, - &mkey_fullname, &master_princ)) { + if ((retval = krb5_db_setup_mkey_name(util_context, mkey_name, arg->realm, + &mkey_fullname, &l_master_princ))) { com_err(arg->comerr_name, retval, "while setting up master key name"); exit(1); } - if (retval = krb5_db_fetch_mkey(util_context, master_princ, - master_keyblock.enctype, 0, - 0, global_params.stash_file, 0, - &master_keyblock)) { + if ((retval = krb5_db_fetch_mkey(util_context, l_master_princ, + master_keyblock.enctype, 0, + 0, global_params.stash_file, 0, + &master_keyblock))) { com_err(arg->comerr_name, retval, "while reading master key"); exit(1); } @@ -419,6 +419,7 @@ int handle_keys(arg) return(0); } +static krb5_error_code handle_one_key(arg, v5mkey, v5key, v4key) struct dump_record *arg; krb5_keyblock *v5mkey; @@ -427,18 +428,14 @@ handle_one_key(arg, v5mkey, v5key, v4key) { krb5_error_code retval; - krb5_keyblock v4v5key; krb5_keyblock v5plainkey; /* v4key is the actual v4 key from the file. */ - if (retval = krb5_dbekd_decrypt_key_data(util_context, v5mkey, v5key, - &v5plainkey, NULL)) + retval = krb5_dbekd_decrypt_key_data(util_context, v5mkey, v5key, + &v5plainkey, NULL); + if (retval) return retval; - /* v4v5key.contents = (krb5_octet *)v4key; */ - /* v4v5key.enctype = ENCTYPE_DES; */ - /* v4v5key.length = sizeof(v4key); */ - memcpy(v4key, v5plainkey.contents, sizeof(des_cblock)); #ifndef KDB4_DISABLE kdb_encrypt_key (v4key, v4key, diff --git a/src/kadmin/dbutil/kadm5_create.c b/src/kadmin/dbutil/kadm5_create.c index 9a67ea445..1c432ef73 100644 --- a/src/kadmin/dbutil/kadm5_create.c +++ b/src/kadmin/dbutil/kadm5_create.c @@ -42,11 +42,14 @@ static char *rcsid = "$Header$"; #include #include #include +#include + #include #include +#include "kdb5_util.h" -int add_admin_princ(void *handle, krb5_context context, +static int add_admin_princ(void *handle, krb5_context context, char *name, char *realm, int attrs, int lifetime); #define ERR 1 @@ -55,11 +58,6 @@ int add_admin_princ(void *handle, krb5_context context, #define ADMIN_LIFETIME 60*60*3 /* 3 hours */ #define CHANGEPW_LIFETIME 60*5 /* 5 minutes */ -extern char *progname; - -extern krb5_keyblock master_keyblock; -extern krb5_db_entry master_db; - /* * Function: kadm5_create * @@ -74,26 +72,24 @@ extern krb5_db_entry master_db; int kadm5_create(kadm5_config_params *params) { int retval; - void *handle; krb5_context context; - FILE *f; kadm5_config_params lparams; - if (retval = krb5_init_context(&context)) + if ((retval = krb5_init_context(&context))) exit(ERR); /* * The lock file has to exist before calling kadm5_init, but * params->admin_lockfile may not be set yet... */ - if (retval = kadm5_get_config_params(context, NULL, NULL, - params, &lparams)) { + if ((retval = kadm5_get_config_params(context, NULL, NULL, + params, &lparams))) { com_err(progname, retval, str_INITING_KCONTEXT); return 1; } - if (retval = osa_adb_create_policy_db(&lparams)) { + if ((retval = osa_adb_create_policy_db(&lparams))) { com_err(progname, retval, str_CREATING_POLICY_DB); return 1; } @@ -107,7 +103,7 @@ int kadm5_create(kadm5_config_params *params) } int kadm5_create_magic_princs(kadm5_config_params *params, - krb5_context *context) + krb5_context context) { int retval; void *handle; @@ -123,7 +119,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); @@ -178,7 +174,7 @@ char *build_name_with_realm(char *name, char *realm) * printed. If any of these existing principal do not have the proper * attributes, a warning message is printed. */ -int add_admin_princs(void *handle, krb5_context context, char *realm) +static int add_admin_princs(void *handle, krb5_context context, char *realm) { krb5_error_code ret = 0; diff --git a/src/kadmin/dbutil/kdb5_util.c b/src/kadmin/dbutil/kdb5_util.c index 7803e8664..849c24a9d 100644 --- a/src/kadmin/dbutil/kdb5_util.c +++ b/src/kadmin/dbutil/kdb5_util.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include "kdb5_util.h" @@ -78,7 +79,7 @@ krb5_context util_context; osa_adb_policy_t policy_db; kadm5_config_params global_params; -usage() +void usage() { fprintf(stderr, "Usage: " "kdb5_util cmd [-r realm] [-d dbname] [-k mkeytype] [-M mkeyname]\n" @@ -104,35 +105,29 @@ char *progname; krb5_boolean manual_mkey = FALSE; krb5_boolean dbactive = FALSE; -int kdb5_create(int, char **); -int kdb5_destroy(int, char **); -int kdb5_stash(int, char **); -int dump_db(int, char **); -int load_db(int, char **); -int dump_v4db(int, char **); -int load_v4db(int, char **); -int open_db_and_mkey(); -int add_random_key(int, char **); +static int open_db_and_mkey(void); + +static void add_random_key(int, char **); -typedef int (*cmd_func)(int, char **); +typedef void (*cmd_func)(int, char **); struct _cmd_table { char *name; cmd_func func; int opendb; } cmd_table[] = { - "create", kdb5_create, 0, - "destroy", kdb5_destroy, 1, - "stash", kdb5_stash, 1, - "dump", dump_db, 1, - "load", load_db, 0, - "dump_v4", dump_v4db, 1, - "load_v4", load_v4db, 0, - "ark", add_random_key, 1, - NULL, NULL, 0, + {"create", kdb5_create, 0}, + {"destroy", kdb5_destroy, 1}, + {"stash", kdb5_stash, 1}, + {"dump", dump_db, 1}, + {"load", load_db, 0}, + {"dump_v4", dump_v4db, 1}, + {"load_v4", load_v4db, 0}, + {"ark", add_random_key, 1}, + {NULL, NULL, 0}, }; -struct _cmd_table *cmd_lookup(name) +static struct _cmd_table *cmd_lookup(name) char *name; { struct _cmd_table *cmd = cmd_table; @@ -220,8 +215,9 @@ int main(argc, argv) if (cmd_argv[0] == NULL) usage(); - if (retval = kadm5_get_config_params(util_context, NULL, NULL, - &global_params, &global_params)) { + retval = kadm5_get_config_params(util_context, NULL, NULL, + &global_params, &global_params); + if (retval) { com_err(argv[0], retval, "while retreiving configuration parameters"); exit(1); } @@ -299,7 +295,7 @@ void set_dbname(argc, argv) * cannot be fetched (the master key stash file may not exist when the * program is run). */ -int open_db_and_mkey() +static int open_db_and_mkey() { krb5_error_code retval; int nentries; @@ -320,10 +316,10 @@ int open_db_and_mkey() exit_status++; return(1); } - if (retval = osa_adb_open_policy(&policy_db, &global_params)) { - com_err(progname, retval, "opening policy database"); - exit_status++; - return (1); + if ((retval = osa_adb_open_policy(&policy_db, &global_params))) { + com_err(progname, retval, "opening policy database"); + exit_status++; + return (1); } /* assemble & parse the master key name */ @@ -445,7 +441,7 @@ quit() return 0; } -int +static void add_random_key(argc, argv) int argc; char **argv; @@ -453,7 +449,7 @@ add_random_key(argc, argv) krb5_error_code ret; krb5_principal princ; krb5_db_entry dbent; - int n, i; + int n; krb5_boolean more; krb5_timestamp now; @@ -481,23 +477,27 @@ add_random_key(argc, argv) ret = krb5_parse_name(util_context, pr_str, &princ); if (ret) { com_err(me, ret, "while parsing principal name %s", pr_str); - return 1; + exit_status++; + return; } n = 1; ret = krb5_db_get_principal(util_context, princ, &dbent, &n, &more); if (ret) { com_err(me, ret, "while fetching principal %s", pr_str); - return 1; + exit_status++; + return; } if (n != 1) { fprintf(stderr, "principal %s not found\n", pr_str); - return 1; + exit_status++; + return; } if (more) { fprintf(stderr, "principal %s not unique\n", pr_str); krb5_dbe_free_contents(util_context, &dbent); - return 1; + exit_status++; + return; } ret = krb5_string_to_keysalts(ks_str, ", \t", ":.-", 0, @@ -505,7 +505,8 @@ add_random_key(argc, argv) &num_keysalts); if (ret) { com_err(me, ret, "while parsing keysalts %s", ks_str); - return 1; + exit_status++; + return; } if (!num_keysalts || keysalts == NULL) { num_keysalts = global_params.num_keysalts; @@ -521,27 +522,30 @@ add_random_key(argc, argv) if (ret) { com_err(me, ret, "while randomizing principal %s", pr_str); krb5_dbe_free_contents(util_context, &dbent); - return 1; + exit_status++; + return; } dbent.attributes &= ~KRB5_KDB_REQUIRES_PWCHANGE; ret = krb5_timeofday(util_context, &now); if (ret) { com_err(me, ret, "while getting time"); krb5_dbe_free_contents(util_context, &dbent); - return 1; + exit_status++; + return; } ret = krb5_dbe_update_last_pwd_change(util_context, &dbent, now); if (ret) { com_err(me, ret, "while setting changetime"); krb5_dbe_free_contents(util_context, &dbent); - return 1; + exit_status++; + return; } ret = krb5_db_put_principal(util_context, &dbent, &n); krb5_dbe_free_contents(util_context, &dbent); if (ret) { com_err(me, ret, "while saving principal %s", pr_str); - return 1; + exit_status++; + return; } printf("%s changed\n", pr_str); - return 0; } diff --git a/src/kadmin/dbutil/kdb5_util.h b/src/kadmin/dbutil/kdb5_util.h index 843b7dd99..52175e56f 100644 --- a/src/kadmin/dbutil/kdb5_util.h +++ b/src/kadmin/dbutil/kdb5_util.h @@ -30,23 +30,54 @@ extern char *progname; extern char *Err_no_database; +#ifndef V4_DECLARES_STATIC +extern krb5_keyblock master_keyblock; +extern krb5_principal master_princ; +#endif +extern krb5_boolean dbactive; +extern int exit_status; +extern krb5_context util_context; +extern kadm5_config_params global_params; +extern int valid_master_key; +extern krb5_db_entry master_db; -void add_key +extern void usage(void); + +extern void add_key PROTOTYPE((char const *, char const *, krb5_const_principal, const krb5_keyblock *, krb5_kvno, krb5_keysalt *)); -int set_dbname_help +extern int set_dbname_help PROTOTYPE((char *, char *)); -char *kdb5_util_Init PROTOTYPE((int, char **)); +extern char *kdb5_util_Init PROTOTYPE((int, char **)); -int quit(); +extern int quit PROTOTYPE((void)); -int check_for_match +extern int check_for_match PROTOTYPE((char *, int, krb5_db_entry *, int, int)); -void parse_token +extern void parse_token PROTOTYPE((char *, int *, int *, char *)); -int create_db_entry - PROTOTYPE((krb5_principal, krb5_db_entry *)); +extern int create_db_entry PROTOTYPE((krb5_principal, krb5_db_entry *)); + +extern int kadm5_create_magic_princs PROTOTYPE((kadm5_config_params *params, + krb5_context context)); + +extern int process_ov_principal PROTOTYPE((char *fname, krb5_context kcontext, + FILE *filep, int verbose, + int *linenop, + void *pol_db)); + +extern void load_db PROTOTYPE((int argc, char **argv)); +extern void dump_db PROTOTYPE((int argc, char **argv)); +extern void load_v4db PROTOTYPE((int argc, char **argv)); +extern void dump_v4db PROTOTYPE((int argc, char **argv)); +extern void kdb5_create PROTOTYPE((int argc, char **argv)); +extern void kdb5_destroy PROTOTYPE((int argc, char **argv)); +extern void kdb5_stash PROTOTYPE((int argc, char **argv)); + +extern void update_ok_file PROTOTYPE((char *file_name)); + +extern int kadm5_create PROTOTYPE((kadm5_config_params *params)); diff --git a/src/kadmin/dbutil/loadv4.c b/src/kadmin/dbutil/loadv4.c index 8ce696c2f..d4de7572c 100644 --- a/src/kadmin/dbutil/loadv4.c +++ b/src/kadmin/dbutil/loadv4.c @@ -64,7 +64,6 @@ static C_Block master_key; static Key_schedule master_key_schedule; -static long master_key_version; static char *v4_mkeyfile = "/.k"; @@ -72,7 +71,10 @@ static char *v4_mkeyfile = "/.k"; #include "com_err.h" #include #include - +/* Define to make certain blocks private */ +#define V4_DECLARES_STATIC +#include "kdb5_util.h" +#include "kadm5/adb.h" /* osa_adb_create_policy_db */ #include /* ntohl */ #define PROGNAME argv[0] @@ -165,7 +167,7 @@ char *argv[]; char *mkey_fullname; char *defrealm; int v4manual = 0; - int read_mkey = 0; + krb5_boolean read_mkey = 0; int tempdb = 0; char *tempdbname; krb5_context context; @@ -263,7 +265,7 @@ char *argv[]; } tempdbname = dbname; } else { - int dbnamelen = strlen(dbname); + size_t dbnamelen = strlen(dbname); tempdbname = malloc(dbnamelen + 2); if (tempdbname == 0) { com_err(PROGNAME, ENOMEM, "allocating temporary filename"); @@ -278,7 +280,8 @@ char *argv[]; if (!realm) { - if (retval = krb5_get_default_realm(context, &defrealm)) { + retval = krb5_get_default_realm(context, &defrealm); + if (retval) { com_err(PROGNAME, retval, "while retrieving default realm name"); krb5_free_context(context); return; @@ -287,9 +290,10 @@ char *argv[]; } /* 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(PROGNAME, retval, "while setting up master key name"); krb5_free_context(context); return; @@ -312,10 +316,12 @@ master key name '%s'\n", fflush(stdout); } - if (retval = krb5_db_fetch_mkey(context, master_princ, - master_keyblock.enctype, - read_mkey, read_mkey, stash_file, 0, - &master_keyblock)) { + + retval = krb5_db_fetch_mkey(context, master_princ, + master_keyblock.enctype, + read_mkey, read_mkey, stash_file, 0, + &master_keyblock); + if (retval) { com_err(PROGNAME, retval, "while reading master key"); krb5_free_context(context); return; @@ -326,18 +332,23 @@ master key name '%s'\n", seed.length = master_keyblock.length; seed.data = master_keyblock.contents; - if (retval = krb5_c_random_seed(context, &seed)) { + retval = krb5_c_random_seed(context, &seed); + if (retval) { com_err(PROGNAME, retval, "while initializing random key generator"); krb5_free_context(context); return; } - if (retval = krb5_db_create(context, tempdbname, crflags)) { + + retval = krb5_db_create(context, tempdbname, crflags); + if (retval) { com_err(PROGNAME, retval, "while creating %sdatabase '%s'", tempdb ? "temporary " : "", tempdbname); krb5_free_context(context); return; } - if (retval = krb5_db_set_name(context, tempdbname)) { + + retval = krb5_db_set_name(context, tempdbname); + if (retval) { (void) krb5_db_destroy(context, tempdbname); com_err(PROGNAME, retval, "while setting active database to '%s'", tempdbname); @@ -358,7 +369,8 @@ master key name '%s'\n", return; } - if (retval = add_principal(context, master_princ, MASTER_KEY, &rblock)) { + retval = add_principal(context, master_princ, MASTER_KEY, &rblock); + if (retval) { (void) krb5_db_fini(context); (void) krb5_db_destroy(context, tempdbname); com_err(PROGNAME, retval, "while adding K/M to the database"); @@ -390,15 +402,16 @@ master key name '%s'\n", /* clean up; rename temporary database if there were no errors */ if (retval == 0) { - if (retval = krb5_db_fini (context)) + retval = krb5_db_fini (context); + if (retval) com_err(PROGNAME, retval, "while shutting down database"); else if (tempdb && (retval = krb5_db_rename(context, tempdbname, - dbname))) + dbname))) com_err(PROGNAME, retval, "while renaming temporary database"); } else { (void) krb5_db_fini (context); if (tempdb) - (void) krb5_db_destroy (context, tempdbname); + (void) krb5_db_destroy (context, tempdbname); } memset((char *)master_keyblock.contents, 0, master_keyblock.length); @@ -421,7 +434,8 @@ master key name '%s'\n", /* * Create the magic principals in the database. */ - if (retval = kadm5_create_magic_princs(&newparams, context)) { + retval = kadm5_create_magic_princs(&newparams, context); + if (retval) { com_err(PROGNAME, retval, "while creating KADM5 principals"); krb5_free_context(context); return; @@ -509,22 +523,25 @@ Principal *princ; return 0; } memset((char *) &entry, 0, sizeof(entry)); - if (retval = krb5_425_conv_principal(context, princ->name, princ->instance, - realm, &entry.princ)) + retval = krb5_425_conv_principal(context, princ->name, princ->instance, + realm, &entry.princ); + if (retval) return retval; if (verbose) { - if (retval = krb5_unparse_name(context, entry.princ, &name)) + retval = krb5_unparse_name(context, entry.princ, &name); + if (retval) name = strdup(""); if (verbose) printf("\ntranslating %s...", name); free(name); } - if (retval = krb5_build_principal(context, &mod_princ, - strlen(realm), - realm, princ->mod_name, - princ->mod_instance[0] ? princ->mod_instance : 0, - 0)) { + retval = krb5_build_principal(context, &mod_princ, + strlen(realm), realm, princ->mod_name, + princ->mod_instance[0] ? + princ->mod_instance : 0, + 0); + if (retval) { krb5_free_principal(context, entry.princ); return retval; } @@ -586,10 +603,11 @@ Principal *princ; if (!retval && !strcmp(princ->name, "krbtgt") && strcmp(princ->instance, realm) && princ->instance[0]) { krb5_free_principal(context, entry.princ); - if (retval = krb5_build_principal(context, &entry.princ, - strlen(princ->instance), - princ->instance, - "krbtgt", realm, 0)) + retval = krb5_build_principal(context, &entry.princ, + strlen(princ->instance), + princ->instance, + "krbtgt", realm, 0); + if (retval) return retval; retval = krb5_db_put_principal(context, &entry, &nentries); } @@ -612,23 +630,25 @@ struct realm_info *pblock; krb5_keyblock rkey; int nentries = 1; krb5_timestamp mod_time; - krb5_principal mod_princ; memset((char *) &entry, 0, sizeof(entry)); - if (retval = krb5_copy_principal(context, princ, &entry.princ)) + retval = krb5_copy_principal(context, princ, &entry.princ); + if (retval) return(retval); entry.max_life = pblock->max_life; entry.max_renewable_life = pblock->max_rlife; entry.len = KRB5_KDB_V1_BASE_LENGTH; entry.expiration = pblock->expiration; - if ((retval = krb5_timeofday(context, &mod_time))) { + retval = krb5_timeofday(context, &mod_time); + if (retval) { krb5_db_free_principal(context, &entry, 1); return retval; } entry.attributes = pblock->flags; - if (retval = krb5_dbe_create_key_data(context, &entry)) { + retval = krb5_dbe_create_key_data(context, &entry); + if (retval) { krb5_db_free_principal(context, &entry, 1); return(retval); } @@ -636,24 +656,26 @@ struct realm_info *pblock; switch (op) { case MASTER_KEY: entry.attributes |= KRB5_KDB_DISALLOW_ALL_TIX; - if (retval = krb5_dbekd_encrypt_key_data(context, pblock->key, - &master_keyblock, - (krb5_keysalt *) NULL, 1, - &entry.key_data[0])) { + retval = krb5_dbekd_encrypt_key_data(context, pblock->key, + &master_keyblock, + (krb5_keysalt *) NULL, 1, + &entry.key_data[0]); + if (retval) { krb5_db_free_principal(context, &entry, 1); return retval; } break; case RANDOM_KEY: - if (retval = krb5_c_make_random_key(context, pblock->key->enctype, - &rkey)) { + retval = krb5_c_make_random_key(context, pblock->key->enctype, + &rkey); + if (retval) { krb5_db_free_principal(context, &entry, 1); return retval; } - if (retval = krb5_dbekd_encrypt_key_data(context, pblock->key, - &rkey, - (krb5_keysalt *) NULL, 1, - &entry.key_data[0])) { + retval = krb5_dbekd_encrypt_key_data(context, pblock->key, + &rkey, (krb5_keysalt *) NULL, + 1, &entry.key_data[0]); + if (retval) { krb5_db_free_principal(context, &entry, 1); return(retval); } @@ -803,7 +825,6 @@ long default_exp_time; char exp_date_str[50]; char mod_date_str[50]; int temp1, temp2, temp3; - long time_explode(); input_file = fopen(dumpfile, "r"); if (!input_file) @@ -814,7 +835,7 @@ long default_exp_time; memset((char *)&aprinc, 0, sizeof(aprinc)); nread = fscanf(input_file, - "%s %s %d %d %d %hd %x %x %s %s %s %s\n", + "%s %s %d %d %d %hd %lx %lx %s %s %s %s\n", aprinc.name, aprinc.instance, &temp1, @@ -846,7 +867,8 @@ long default_exp_time; aprinc.mod_name[0] = '\0'; if (aprinc.mod_instance[0] == '*') aprinc.mod_instance[0] = '\0'; - if (retval = enter_in_v5_db(context, realm, &aprinc)) + retval = enter_in_v5_db(context, realm, &aprinc); + if (retval) break; } (void) fclose(input_file); @@ -866,7 +888,6 @@ long *exptime; char exp_date_str[50]; char mod_date_str[50]; int temp1, temp2, temp3; - long time_explode(); long foundtime, guess1, guess2; /* kdb_init is usually the only thing to touch the time in the @@ -901,7 +922,7 @@ long *exptime; memset((char *)&aprinc, 0, sizeof(aprinc)); nread = fscanf(input_file, - "%s %s %d %d %d %hd %x %x %s %s %s %s\n", + "%s %s %d %d %d %hd %lx %lx %s %s %s %s\n", aprinc.name, aprinc.instance, &temp1, @@ -930,7 +951,7 @@ long *exptime; } else if (foundtime == guess2) { printf("Cygnus CNS post 96q1 value (2009)"); } else { - printf("non-default start time (%d,%s)", + printf("non-default start time (%ld,%s)", foundtime, exp_date_str); } } @@ -950,9 +971,11 @@ static krb5_error_code fixup_database(context, realm) int nprincs; krb5_boolean more; + nprincs = 1; - if (retval = krb5_db_get_principal(context, &tgt_princ, &entry, - &nprincs, &more)) + retval = krb5_db_get_principal(context, &tgt_princ, &entry, + &nprincs, &more); + if (retval) return retval; if (nprincs == 0) diff --git a/src/kadmin/dbutil/ovload.c b/src/kadmin/dbutil/ovload.c index 6cecac7d7..e8075f114 100644 --- a/src/kadmin/dbutil/ovload.c +++ b/src/kadmin/dbutil/ovload.c @@ -7,13 +7,14 @@ #include #include "import_err.h" +#include "kdb5_util.h" char *nstrtok(); #define LINESIZE 32768 /* XXX */ #define PLURAL(count) (((count) == 1) ? error_message(IMPORT_SINGLE_RECORD) : error_message(IMPORT_PLURAL_RECORDS)) -int parse_pw_hist_ent(current, hist) +static int parse_pw_hist_ent(current, hist) char *current; osa_pw_hist_ent *hist; { @@ -108,7 +109,7 @@ int process_ov_principal(fname, kcontext, filep, verbose, linenop, pol_db) krb5_db_entry kdb; char *current; char *cp; - int tmp, x, i, one; + int x, one; krb5_boolean more; char line[LINESIZE]; @@ -186,16 +187,16 @@ int process_ov_principal(fname, kcontext, filep, verbose, linenop, pol_db) tl_data.tl_data_contents = (krb5_octet *) xdralloc_getdata(&xdrs); one = 1; - ret = krb5_db_get_principal(kcontext, princ, &kdb, &one, - &more); + ret = krb5_db_get_principal(kcontext, princ, &kdb, &one, &more); if (ret) goto done; - if (ret = krb5_dbe_update_tl_data(kcontext, &kdb, - &tl_data)) + ret = krb5_dbe_update_tl_data(kcontext, &kdb, &tl_data); + if (ret) goto done; - if (ret = krb5_db_put_principal(kcontext, &kdb, &one)) + ret = krb5_db_put_principal(kcontext, &kdb, &one); + if (ret) goto done; xdr_destroy(&xdrs);