Esempio n. 1
0
void
mshim_herror2merror(krb5_context context, const krb5_error *h, mit_krb5_error *m)
{
    LOG_ENTRY();
    memset(m, 0, sizeof(*m));

    m->magic = MIT_KV5M_ERROR;
    if (h->ctime)
	m->ctime = *h->ctime;
    if (h->cusec)
	m->cusec = *h->cusec;
    m->stime = h->stime;
    m->susec = h->susec;
#if 0
    m->client = mshim_hprinc2mprinc(context, h->client);
    m->server = mshim_hprinc2mprinc(context, h->server);
#endif
    m->error = h->error_code;
    if (h->e_text) {
	m->text.magic = MIT_KV5M_DATA;
	m->text.data = strdup(*(h->e_text));
	m->text.length = strlen(*(h->e_text));
    }
    if (h->e_data)
	mshim_hdata2mdata(h->e_data, &m->e_data);
#if 0
    krb5_principal client;		/* client's principal identifier;
					   optional */
    krb5_principal server;		/* server's principal identifier */
#endif
}
Esempio n. 2
0
void
mshim_hcred2mcred(krb5_context context, krb5_creds *h, mit_krb5_creds *m)
{
    memset(m, 0, sizeof(*m));

    m->magic = MIT_KV5M_CREDS;
    m->client = mshim_hprinc2mprinc(context, h->client);
    m->server = mshim_hprinc2mprinc(context, h->server);

    mshim_hkeyblock2mkeyblock(&h->session, &m->keyblock);

    mshim_hdata2mdata(&h->ticket, &m->ticket);

    m->times.authtime = h->times.authtime;
    m->times.starttime = h->times.starttime;
    m->times.endtime = h->times.endtime;
    m->times.renew_till = h->times.renew_till;

    m->ticket_flags = 0;
    if (h->flags.b.forwardable)
	m->ticket_flags |= MIT_TKT_FLG_FORWARDABLE;
    if (h->flags.b.forwarded)
	m->ticket_flags |= MIT_TKT_FLG_FORWARDED;
    if (h->flags.b.proxiable)
	m->ticket_flags |= MIT_TKT_FLG_PROXIABLE;
    if (h->flags.b.proxy)
	m->ticket_flags |= MIT_TKT_FLG_PROXY;
    if (h->flags.b.may_postdate)
	m->ticket_flags |= MIT_TKT_FLG_MAY_POSTDATE;
    if (h->flags.b.postdated)
	m->ticket_flags |= MIT_TKT_FLG_POSTDATED;
    if (h->flags.b.invalid)
	m->ticket_flags |= MIT_TKT_FLG_INVALID;
    if (h->flags.b.renewable)
	m->ticket_flags |= MIT_TKT_FLG_RENEWABLE;
    if (h->flags.b.initial)
	m->ticket_flags |= MIT_TKT_FLG_INITIAL;
    if (h->flags.b.pre_authent)
	m->ticket_flags |= MIT_TKT_FLG_PRE_AUTH;
    if (h->flags.b.hw_authent)
	m->ticket_flags |= MIT_TKT_FLG_HW_AUTH;
    if (h->flags.b.transited_policy_checked)
	m->ticket_flags |= MIT_TKT_FLG_TRANSIT_POLICY_CHECKED;
    if (h->flags.b.ok_as_delegate)
	m->ticket_flags |= MIT_TKT_FLG_OK_AS_DELEGATE;
    if (h->flags.b.anonymous)
	m->ticket_flags |= MIT_TKT_FLG_ANONYMOUS;
}
mit_krb5_error_code KRB5_CALLCONV
krb5_copy_principal(mit_krb5_context context,
		    mit_krb5_const_principal from,
		    mit_krb5_principal *to)
{
    struct comb_principal *p = (struct comb_principal *)from;
    LOG_ENTRY();
    *to = mshim_hprinc2mprinc(HC(context), p->heim);
    return 0;
}
mit_krb5_error_code KRB5_CALLCONV
krb5_sname_to_principal(mit_krb5_context context,
			const char *hostname, const char *service, 
			mit_krb5_int32 type,
			mit_krb5_principal *principal)
{
    krb5_error_code ret;
    krb5_principal p;

    LOG_ENTRY();

    *principal = NULL;

    ret = heim_krb5_sname_to_principal(HC(context), hostname, service, type, &p);
    if (ret)
	return ret;

    *principal = mshim_hprinc2mprinc(HC(context), p);
    heim_krb5_free_principal(HC(context), p);
    return 0;
}
mit_krb5_error_code KRB5_CALLCONV
krb5_kt_next_entry(mit_krb5_context context, mit_krb5_keytab keytab,
		   mit_krb5_keytab_entry *entry, mit_krb5_kt_cursor *cursor)
{
    krb5_error_code ret;
    krb5_keytab_entry e;

    LOG_ENTRY();

    ret = heim_krb5_kt_next_entry(HC(context), (krb5_keytab)keytab,
				  &e, (krb5_kt_cursor *)*cursor);
    if (ret)
	return ret;

    entry->magic = 0;
    entry->principal = mshim_hprinc2mprinc(HC(context), e.principal);
    entry->timestamp = e.timestamp;
    entry->vno = e.vno;
    mshim_hkeyblock2mkeyblock(&e.keyblock, &entry->key);

    heim_krb5_kt_free_entry(HC(context), &e);

    return 0;
}