/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Solaris Kerberos: note that MIT has a file also named store_cred.c with a
* different implementation of store_cred. It differs quite a bit.
*/
#include <k5-int.h>
#include <gssapiP_krb5.h>
#include <memory.h>
#include <assert.h>
#include <syslog.h>
extern uint_t kwarn_add_warning(char *, int);
extern uint_t kwarn_del_warning(char *);
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);
}
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)
if (min) {
*minor_status = min;
return (GSS_S_FAILURE);
}
/* * 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;
}
/*
* Handle overwrite_cred option. If overwrite_cred == FALSE
* then we must be careful not to overwrite an existing
* unexpired credential.
*/
0, desired_mechs, cred_usage,
&cur_time_rec);
if (cur_time_rec > 0 && !overwrite_cred) {
goto cleanup;
}
/* Ready to store -- store_init_cred() handles default_cred */
goto cleanup;
/* Alert ktkt_warnd(1M) */
goto cleanup;
(void) kwarn_del_warning(client_name);
"store_cred: kwarn_add_warning"
" failed: ktkt_warnd(1M) down? ");
}
client_name = NULL;
/* Output parameters */
if (cred_usage_stored != NULL)
if (elements_stored != NULL) {
goto cleanup;
(const gss_OID)gss_mech_krb5,
goto cleanup;
}
}
if (desired_mechs != GSS_C_NULL_OID_SET)
(void) krb5_gss_release_cred(&min,
(gss_cred_id_t *)&cur_cred);
if (in_name != GSS_C_NO_NAME)
if (ctx)
return (maj);
}