Overriding profile settings

Mark Schreiber mark7 at maginatics.com
Mon May 13 19:41:11 EDT 2013

I'm writing some libkrb5-using code.  I'd like to override one setting
from the config files in that code, but otherwise use the settings from
the config file.

The public API for libkrb5 includes two functions,
profile_update_relation() and profile_add_relation().  The sensible
thing to do seems to be something along these lines:


    krb5_get_profile(context1, &profile);

    krbError = profile_get_values(profile, names, &values);
    if (krbError == 0) {
        profile_update_relation(profile, replacement_names, values[0],
    } else if (krbError == PROF_NO_RELATION) {
        profile_add_relation(profile, replacement_names, "true");

    krb5_init_context_profile(profile, 0, &context2);

My problem is that profile_copy(), which is internally called by
krb5_init_context_profile(), doesn't actually copy the settings from the
source destination to the destination profile, but instead re-parses the
files that the source profile uses, so that setting changes to the
source profile are dropped.

If this is intentional, it seems strange that profile_update_relation()
and profile_add_relation() would be exposed in the public API, since
they would not then seem to be useful to an external caller.  The the
modified profiles could then never be used.  External callers can't
manipulate a context's profiles (since krb5_get_profile() only returns a
copy of a context's profile) and can't create a context using modified
profiles (since changes will be thrown out when a new context is

In the presence of this behavior, the only way I see to override that
single setting is:

* dump the settings in a profile

* generate a temporary config file using these settings with any desired

* create a new profile using the generated config file

* create a context using the profile (parsing the config file)

* remove the temporary config file.

Is there a more-correct way to go about overriding a setting?

Thank you.

More information about the krbdev mailing list