-
-krb5_error_code KRB5_CALLCONV
-krb5_copy_context(krb5_context ctx, krb5_context *nctx_out)
-{
- krb5_error_code ret;
- krb5_context nctx;
-
- *nctx_out = NULL;
- if (ctx == NULL)
- return EINVAL; /* XXX */
-
- nctx = malloc(sizeof(*nctx));
- if (nctx == NULL)
- return ENOMEM;
-
- *nctx = *ctx;
-
- nctx->in_tkt_etypes = NULL;
- nctx->tgs_etypes = NULL;
- nctx->default_realm = NULL;
- nctx->profile = NULL;
- nctx->dal_handle = NULL;
- nctx->ser_ctx_count = 0;
- nctx->ser_ctx = NULL;
- nctx->prompt_types = NULL;
- nctx->os_context.default_ccname = NULL;
-
- memset(&nctx->preauth_plugins, 0, sizeof(nctx->preauth_plugins));
- nctx->preauth_context = NULL;
-
- memset(&nctx->libkrb5_plugins, 0, sizeof(nctx->libkrb5_plugins));
- nctx->vtbl = NULL;
- nctx->locate_fptrs = NULL;
-
- memset(&nctx->err, 0, sizeof(nctx->err));
-
- ret = copy_enctypes(nctx, ctx->in_tkt_etypes, &nctx->in_tkt_etypes);
- if (ret)
- goto errout;
- ret = copy_enctypes(nctx, ctx->tgs_etypes, &nctx->tgs_etypes);
- if (ret)
- goto errout;
-
- if (ctx->os_context.default_ccname != NULL) {
- nctx->os_context.default_ccname =
- strdup(ctx->os_context.default_ccname);
- if (nctx->os_context.default_ccname == NULL) {
- ret = ENOMEM;
- goto errout;
- }
- }
- ret = krb5_get_profile(ctx, &nctx->profile);
- if (ret)
- goto errout;
-
-errout:
- if (ret) {
- krb5_free_context(nctx);
- } else {
- *nctx_out = nctx;
- }
- return ret;
-}
-
-krb5_error_code KRB5_CALLCONV
-krb5_get_profile (krb5_context ctx, profile_t *profile)
-{
- return profile_copy (ctx->profile, profile);
-}