make this match the MIT function
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9450 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997 - 2000 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1997 - 2001 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -38,8 +38,9 @@ RCSID("$Id$");
|
|||||||
krb5_error_code
|
krb5_error_code
|
||||||
krb5_rd_cred(krb5_context context,
|
krb5_rd_cred(krb5_context context,
|
||||||
krb5_auth_context auth_context,
|
krb5_auth_context auth_context,
|
||||||
krb5_ccache ccache,
|
krb5_data *in_data,
|
||||||
krb5_data *in_data)
|
krb5_creds ***ret_creds,
|
||||||
|
krb5_replay_data *out_data)
|
||||||
{
|
{
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -153,51 +154,104 @@ krb5_rd_cred (krb5_context context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX - check replay cache */
|
if(out_data != NULL) {
|
||||||
|
if(enc_krb_cred_part.timestamp)
|
||||||
|
out_data->timestamp = *enc_krb_cred_part.timestamp;
|
||||||
|
else
|
||||||
|
out_data->timestamp = 0;
|
||||||
|
if(enc_krb_cred_part.usec)
|
||||||
|
out_data->usec = *enc_krb_cred_part.usec;
|
||||||
|
else
|
||||||
|
out_data->usec = 0;
|
||||||
|
if(enc_krb_cred_part.nonce)
|
||||||
|
out_data->seq = *enc_krb_cred_part.nonce;
|
||||||
|
else
|
||||||
|
out_data->seq = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Store the creds in the ccache */
|
/* Convert to NULL terminated list of creds */
|
||||||
|
|
||||||
|
*ret_creds = calloc(enc_krb_cred_part.ticket_info.len + 1,
|
||||||
|
sizeof(**ret_creds));
|
||||||
|
|
||||||
for (i = 0; i < enc_krb_cred_part.ticket_info.len; ++i) {
|
for (i = 0; i < enc_krb_cred_part.ticket_info.len; ++i) {
|
||||||
KrbCredInfo *kci = &enc_krb_cred_part.ticket_info.val[i];
|
KrbCredInfo *kci = &enc_krb_cred_part.ticket_info.val[i];
|
||||||
krb5_creds creds;
|
krb5_creds *creds;
|
||||||
u_char buf[1024];
|
u_char buf[1024];
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
memset (&creds, 0, sizeof(creds));
|
creds = calloc(1, sizeof(*creds));
|
||||||
|
if(creds == NULL) {
|
||||||
|
ret = ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = encode_Ticket (buf + sizeof(buf) - 1, sizeof(buf),
|
ret = encode_Ticket (buf + sizeof(buf) - 1, sizeof(buf),
|
||||||
&cred.tickets.val[i],
|
&cred.tickets.val[i],
|
||||||
&len);
|
&len);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
krb5_data_copy (&creds.ticket, buf + sizeof(buf) - len, len);
|
krb5_data_copy (&creds->ticket, buf + sizeof(buf) - len, len);
|
||||||
copy_EncryptionKey (&kci->key, &creds.session);
|
copy_EncryptionKey (&kci->key, &creds->session);
|
||||||
if (kci->prealm && kci->pname)
|
if (kci->prealm && kci->pname)
|
||||||
principalname2krb5_principal (&creds.client,
|
principalname2krb5_principal (&creds->client,
|
||||||
*kci->pname,
|
*kci->pname,
|
||||||
*kci->prealm);
|
*kci->prealm);
|
||||||
if (kci->flags)
|
if (kci->flags)
|
||||||
creds.flags.b = *kci->flags;
|
creds->flags.b = *kci->flags;
|
||||||
if (kci->authtime)
|
if (kci->authtime)
|
||||||
creds.times.authtime = *kci->authtime;
|
creds->times.authtime = *kci->authtime;
|
||||||
if (kci->starttime)
|
if (kci->starttime)
|
||||||
creds.times.starttime = *kci->starttime;
|
creds->times.starttime = *kci->starttime;
|
||||||
if (kci->endtime)
|
if (kci->endtime)
|
||||||
creds.times.endtime = *kci->endtime;
|
creds->times.endtime = *kci->endtime;
|
||||||
if (kci->renew_till)
|
if (kci->renew_till)
|
||||||
creds.times.renew_till = *kci->renew_till;
|
creds->times.renew_till = *kci->renew_till;
|
||||||
if (kci->srealm && kci->sname)
|
if (kci->srealm && kci->sname)
|
||||||
principalname2krb5_principal (&creds.server,
|
principalname2krb5_principal (&creds->server,
|
||||||
*kci->sname,
|
*kci->sname,
|
||||||
*kci->srealm);
|
*kci->srealm);
|
||||||
if (kci->caddr)
|
if (kci->caddr)
|
||||||
krb5_copy_addresses (context,
|
krb5_copy_addresses (context,
|
||||||
kci->caddr,
|
kci->caddr,
|
||||||
&creds.addresses);
|
&creds->addresses);
|
||||||
krb5_cc_store_cred (context, ccache, &creds);
|
|
||||||
|
(*ret_creds)[i] = creds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
(*ret_creds)[i] = NULL;
|
||||||
|
return 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free_KRB_CRED (&cred);
|
free_KRB_CRED (&cred);
|
||||||
|
if(*ret_creds) {
|
||||||
|
for(i = 0; (*ret_creds)[i]; i++)
|
||||||
|
krb5_free_creds(context, (*ret_creds)[i]);
|
||||||
|
free(*ret_creds);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
krb5_error_code
|
||||||
|
krb5_rd_cred2 (krb5_context context,
|
||||||
|
krb5_auth_context auth_context,
|
||||||
|
krb5_ccache ccache,
|
||||||
|
krb5_data *in_data)
|
||||||
|
{
|
||||||
|
krb5_error_code ret;
|
||||||
|
krb5_creds **creds;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
ret = krb5_rd_cred(context, auth_context, in_data, &creds, NULL);
|
||||||
|
if(ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* Store the creds in the ccache */
|
||||||
|
|
||||||
|
for(i = 0; creds && creds[i]; i++) {
|
||||||
|
krb5_cc_store_cred(context, ccache, creds[i]);
|
||||||
|
krb5_free_creds(context, creds[i]);
|
||||||
|
}
|
||||||
|
free(creds);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user