Skip to content

Commit

Permalink
Use context profile for libkadm5 configuration
Browse files Browse the repository at this point in the history
In kadm5_get_config_params(), uxe the context profile instead of
creating a new one with krb5_aprof_init().

In kproplog, obtain the context with kadm5_init_krb5_context() so that
KDC configuration is used.

ticket: 9059 (new)
  • Loading branch information
greghudson committed May 18, 2022
1 parent 0bfd22f commit 49a8578
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/kprop/kproplog.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ main(int argc, char **argv)
}
}

if (krb5_init_context(&context)) {
if (kadm5_init_krb5_context(&context)) {
fprintf(stderr, _("Unable to initialize Kerberos\n\n"));
exit(1);
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/kadm5/admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ typedef struct _kadm5_key_data {
* functions
*/

/* The use_kdc_config parameter is no longer used, as configuration is
* retrieved from the context profile. */
krb5_error_code kadm5_get_config_params(krb5_context context,
int use_kdc_config,
kadm5_config_params *params_in,
Expand Down
24 changes: 2 additions & 22 deletions src/lib/kadm5/alt_prof.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ krb5_error_code kadm5_get_config_params(krb5_context context,
kadm5_config_params *params_in,
kadm5_config_params *params_out)
{
char *filename, *envname, *lrealm, *svalue, *sp, *ep, *tp;
krb5_pointer aprofile = 0;
char *lrealm, *svalue, *sp, *ep, *tp;
krb5_pointer aprofile = context->profile;
const char *hierarchy[4];
krb5_int32 ivalue;
kadm5_config_params params, empty_params;
Expand Down Expand Up @@ -543,25 +543,6 @@ krb5_error_code kadm5_get_config_params(krb5_context context,
params.kvno = params_in->kvno;
params.mask |= KADM5_CONFIG_KVNO;
}
/*
* XXX These defaults should to work on both client and
* server. kadm5_get_config_params can be implemented as a
* wrapper function in each library that provides correct
* defaults for NULL values.
*/
if (use_kdc_config) {
filename = DEFAULT_KDC_PROFILE;
envname = KDC_PROFILE_ENV;
} else {
filename = DEFAULT_PROFILE_PATH;
envname = "KRB5_CONFIG";
}
if (context->profile_secure == TRUE)
envname = NULL;

ret = krb5_aprof_init(filename, envname, &aprofile);
if (ret)
goto cleanup;

/* Initialize realm parameters. */
hierarchy[0] = KRB5_CONF_REALMS;
Expand Down Expand Up @@ -814,7 +795,6 @@ krb5_error_code kadm5_get_config_params(krb5_context context,
*params_out = params;

cleanup:
krb5_aprof_finish(aprofile);
if (ret) {
kadm5_free_config_params(context, &params);
params_out->mask = 0;
Expand Down

0 comments on commit 49a8578

Please sign in to comment.