#include <k5-int.h>
static void
trace(krb5_context ctx, const krb5_trace_info *info, void *data)
{
}
static void
check(int cond)
{
if (!cond)
abort();
}
static void
compare_string(const char *str1, const char *str2)
{
check((str1 == NULL) == (str2 == NULL));
if (str1 != NULL)
check(strcmp(str1, str2) == 0);
}
static void
compare_etypes(krb5_enctype *list1, krb5_enctype *list2)
{
check((list1 == NULL) == (list2 == NULL));
if (list1 == NULL)
return;
while (*list1 != ENCTYPE_NULL && *list1 == *list2)
list1++, list2++;
check(*list1 == *list2);
}
static void
check_context(krb5_context c, krb5_context r)
{
int i;
compare_etypes(c->tgs_etypes, r->tgs_etypes);
check(c->os_context.time_offset == r->os_context.time_offset);
check(c->os_context.usec_offset == r->os_context.usec_offset);
check(c->os_context.os_flags == r->os_context.os_flags);
compare_string(c->os_context.default_ccname, r->os_context.default_ccname);
check(c->clockskew == r->clockskew);
check(c->kdc_default_options == r->kdc_default_options);
check(c->library_options == r->library_options);
check(c->profile_secure == r->profile_secure);
check(c->fcc_default_format == r->fcc_default_format);
check(c->udp_pref_limit == r->udp_pref_limit);
check(c->use_conf_ktypes == r->use_conf_ktypes);
check(c->allow_weak_crypto == r->allow_weak_crypto);
check(c->ignore_acceptor_hostname == r->ignore_acceptor_hostname);
check(c->enforce_ok_as_delegate == r->enforce_ok_as_delegate);
check(c->dns_canonicalize_hostname == r->dns_canonicalize_hostname);
compare_string(c->plugin_base_dir, r->plugin_base_dir);
check(c->dal_handle == NULL);
check(c->prompt_types == NULL);
check(c->libkrb5_plugins.files == NULL);
check(c->preauth_context == NULL);
check(c->ccselect_handles == NULL);
check(c->localauth_handles == NULL);
check(c->hostrealm_handles == NULL);
check(c->err.code == 0);
check(c->err.msg == NULL);
check(c->kdblog_context == NULL);
check(c->trace_callback == NULL);
check(c->trace_callback_data == NULL);
for (i = 0; i < PLUGIN_NUM_INTERFACES; i++) {
check(c->plugins[i].modules == NULL);
check(!c->plugins[i].configured);
}
}
int
main(int argc, char **argv)
{
krb5_context ctx, ctx2;
krb5_plugin_initvt_fn *mods;
const krb5_enctype etypes[] = { ENCTYPE_AES128_CTS_HMAC_SHA1_96,
ENCTYPE_AES256_CTS_HMAC_SHA1_96, 0 };
krb5_prompt_type ptypes[] = { KRB5_PROMPT_TYPE_PASSWORD };
check(krb5_init_context(&ctx) == 0);
check(krb5_copy_context(ctx, &ctx2) == 0);
check_context(ctx2, ctx);
krb5_free_context(ctx2);
ctx->allow_weak_crypto = TRUE;
check(krb5_set_default_tgs_enctypes(ctx, etypes) == 0);
check(krb5_set_debugging_time(ctx, 1234, 5678) == 0);
check(krb5_cc_set_default_name(ctx, "defccname") == 0);
check(krb5_set_default_realm(ctx, "defrealm") == 0);
ctx->clockskew = 18;
ctx->kdc_default_options = KDC_OPT_FORWARDABLE;
ctx->library_options = 0;
ctx->profile_secure = TRUE;
ctx->udp_pref_limit = 2345;
ctx->use_conf_ktypes = TRUE;
ctx->ignore_acceptor_hostname = TRUE;
ctx->enforce_ok_as_delegate = TRUE;
ctx->dns_canonicalize_hostname = CANONHOST_FALSE;
free(ctx->plugin_base_dir);
check((ctx->plugin_base_dir = strdup("/a/b/c/d")) != NULL);
ctx->prompt_types = ptypes;
check(k5_plugin_load_all(ctx, PLUGIN_INTERFACE_PWQUAL, &mods) == 0);
k5_plugin_free_modules(ctx, mods);
k5_setmsg(ctx, ENOMEM, "nooooooooo");
krb5_set_trace_callback(ctx, trace, ctx);
check(krb5_copy_context(ctx, &ctx2) == 0);
check_context(ctx2, ctx);
krb5_free_context(ctx2);
krb5_free_context(ctx);
return 0;
}