From: Ezra Peisach Date: Tue, 4 Nov 1997 17:55:07 +0000 (+0000) Subject: * kdb5_util.c: Add flag indicating that policy db is to be closed. X-Git-Tag: krb5-1.1-beta1~965 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fac816f81b161c1d8c188a5997d5710af5267e59;p=krb5.git * kdb5_util.c: Add flag indicating that policy db is to be closed. Change '-f" option to "-sf" to indicate stash file on command line. * kdb5_stash.c (kdb5_stash): Indicate that policy db should be closed, free context when done. * kadm5_create.c (kadm5_create): Fix up memory leaks. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10265 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/dbutil/ChangeLog b/src/kadmin/dbutil/ChangeLog index 892ba1db3..03bf5d9e4 100644 --- a/src/kadmin/dbutil/ChangeLog +++ b/src/kadmin/dbutil/ChangeLog @@ -1,3 +1,14 @@ +Sun Nov 2 19:09:17 1997 Ezra Peisach + + * kdb5_util.c: Add flag indicating that policy db is to be closed. + Change '-f" option to "-sf" to indicate stash file on + command line. + + * kdb5_stash.c (kdb5_stash): Indicate that policy db should be + closed, free context when done. + + * kadm5_create.c (kadm5_create): Fix up memory leaks. + Wed Oct 22 15:39:38 1997 Ezra Peisach * tcl_wrapper.c: Include either tcl.h or tcl/tcl.h diff --git a/src/kadmin/dbutil/kadm5_create.c b/src/kadmin/dbutil/kadm5_create.c index e4341d1fd..b60ec9759 100644 --- a/src/kadmin/dbutil/kadm5_create.c +++ b/src/kadmin/dbutil/kadm5_create.c @@ -53,6 +53,7 @@ int kadm5_create(kadm5_config_params *params) krb5_context context; FILE *f; + kadm5_config_params lparams; if (retval = krb5_init_context(&context)) exit(ERR); @@ -62,18 +63,19 @@ int kadm5_create(kadm5_config_params *params) * params->admin_lockfile may not be set yet... */ if (retval = kadm5_get_config_params(context, NULL, NULL, - params, params)) { + params, &lparams)) { com_err(progname, retval, str_INITING_KCONTEXT); return 1; } - if (retval = osa_adb_create_policy_db(params)) { + if (retval = osa_adb_create_policy_db(&lparams)) { com_err(progname, retval, str_CREATING_POLICY_DB); return 1; } - retval = kadm5_create_magic_princs(params, context); + retval = kadm5_create_magic_princs(&lparams, context); + kadm5_free_config_params(context, &lparams); krb5_free_context(context); return retval; diff --git a/src/kadmin/dbutil/kdb5_stash.c b/src/kadmin/dbutil/kdb5_stash.c index 1d29de0f5..9502c0952 100644 --- a/src/kadmin/dbutil/kdb5_stash.c +++ b/src/kadmin/dbutil/kdb5_stash.c @@ -37,6 +37,7 @@ extern krb5_encrypt_block master_encblock; extern kadm5_config_params global_params; extern int exit_status; +extern int close_policy_db; void kdb5_stash(argc, argv) @@ -59,6 +60,9 @@ char *argv[]; if (strrchr(argv[0], '/')) argv[0] = strrchr(argv[0], '/')+1; + /* Tell upwards to close the policy db cause we don't */ + close_policy_db = 1; + krb5_init_context(&context); dbname = global_params.dbname; @@ -138,6 +142,7 @@ char *argv[]; exit_status++; return; } + krb5_free_context(context); exit_status = 0; return; } diff --git a/src/kadmin/dbutil/kdb5_util.c b/src/kadmin/dbutil/kdb5_util.c index aafdb5ef0..ead82aa63 100644 --- a/src/kadmin/dbutil/kdb5_util.c +++ b/src/kadmin/dbutil/kdb5_util.c @@ -70,6 +70,7 @@ extern krb5_encrypt_block master_encblock; krb5_db_entry master_entry; krb5_pointer master_random; int valid_master_key = 0; +int close_policy_db = 0; char *progname; krb5_boolean manual_mkey = FALSE; @@ -169,7 +170,7 @@ int main(argc, argv) } else if (strcmp(*argv, "-M") == 0 && ARG_VAL) { global_params.mkey_name = optarg; global_params.mask |= KADM5_CONFIG_MKEY_NAME; - } else if (strcmp(*argv, "-f") == 0 && ARG_VAL) { + } else if (strcmp(*argv, "-sf") == 0 && ARG_VAL) { global_params.stash_file = optarg; global_params.mask |= KADM5_CONFIG_STASH_FILE; } else if (strcmp(*argv, "-m") == 0) { @@ -223,6 +224,12 @@ int main(argc, argv) return exit_status; (*cmd->func)(cmd_argc, cmd_argv); + + if(close_policy_db) { + (void) osa_adb_close_policy(policy_db); + } + kadm5_free_config_params(util_context, &global_params); + krb5_free_context(util_context); return exit_status; }