store_cred.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <k5-int.h>
#include <gssapiP_krb5.h>
#include <memory.h>
#include <assert.h>
static
const krb5_gss_cred_id_t cred;
int dflt;
{
if (minor_status == NULL)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor_status = 0;
/* Get current ccache -- respect KRB5CCNAME, or use OS default */
*minor_status = code;
return (GSS_S_FAILURE);
}
/*
* Here we should do something like:
*
* a) take all the initial tickets from the current ccache for
* client principals other than the given cred's
* b) copy them to a tmp MEMORY ccache
* c) copy the given cred's tickets to that same tmp ccache
* d) initialize the current ccache with either the same default
* princ as before (!dflt) or with the input cred's princ as the
* default princ (dflt) and copy the tmp ccache's creds to it.
*
* However, for now we just initialize the current ccache, if
* (dflt), and copy the input cred's tickets to it.
*
* To support the above ideal we'd need a variant of
* krb5_cc_copy_creds(). But then, preserving any tickets from
* the current ccache may be problematic if the ccache has many,
* many service tickets in it as that makes ccache enumeration
* really, really slow; we might want to address ccache perf
* first.
*
* So storing of non-default credentials is not supported.
*/
if (dflt) {
/* Treat this as "caller asks to initialize ccache" */
/* LINTED */
*minor_status = code;
maj = GSS_S_FAILURE;
goto cleanup;
}
} else {
maj = GSS_S_FAILURE;
goto cleanup;
}
*minor_status = code;
maj = GSS_S_FAILURE;
goto cleanup;
}
/* LINTED */
return (maj);
}
void *ct;
const gss_cred_id_t input_cred;
{
return (ret);
}
void *ct;
const gss_cred_id_t input_cred;
{
if (input_cred == GSS_C_NO_CREDENTIAL)
return (GSS_S_CALL_INACCESSIBLE_READ);
/* Initialize output parameters */
if (minor_status == NULL)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor_status = 0;
if (elements_stored != NULL)
if (cred_usage_stored != NULL)
/* Sanity check cred_usage */
cred_usage != GSS_C_ACCEPT) {
return (GSS_S_CALL_BAD_STRUCTURE);
}
/* Not supported: storing acceptor creds -- short cut now */
if (cred_usage == GSS_C_ACCEPT) {
return (GSS_S_FAILURE);
}
if (cred_usage == GSS_C_BOTH)
/* * Find out the name, lifetime and cred usage of the input cred */
goto cleanup;
/* Check that the input cred isn't expired */
if (in_time_rec == 0) {
goto cleanup;
}
/* The requested and input cred usage must agree */
maj = GSS_S_NO_CRED;
goto cleanup;
}
if (in_usage == GSS_C_ACCEPT) {
maj = GSS_S_FAILURE;
goto cleanup;
}
/* Get current cred, if any */
if (desired_mech != GSS_C_NULL_OID) {
/* assume that libgss gave us one of our mech OIDs */
return (maj);
goto cleanup;
}
0, desired_mechs, cred_usage,
if (maj == GSS_S_COMPLETE) {
goto cleanup;
}
/*
* Handle overwrite_cred option. If overwrite_cred == FALSE
* then we must be careful not to overwrite an existing
* credential for the same name.
*/
if (cur_time_rec > 0 && !overwrite_cred) {
goto cleanup;
}
/* Ready to store -- store_init_cred() handles default_cred */
goto cleanup;
/* Output parameters */
if (cred_usage_stored != NULL)
if (elements_stored != NULL) {
goto cleanup;
goto cleanup;
(const gss_OID)gss_mech_krb5,
goto cleanup;
}
if (desired_mechs != GSS_C_NULL_OID_SET)
(gss_cred_id_t *)&cur_cred);
if (in_name != GSS_C_NO_NAME)
if (cur_name != GSS_C_NO_NAME)
return (maj);
}