* SUCH DAMAGE.
*/
+/*
+ * Fast reauthentication support.
+ */
+
#include "gssapiP_eap.h"
#include <dlfcn.h>
enc_part.client = ctx->initiatorName->krbPrincipal;
enc_part.times.authtime = time(NULL);
enc_part.times.starttime = enc_part.times.authtime;
- enc_part.times.endtime = ctx->expiryTime
+ enc_part.times.endtime = (ctx->expiryTime != 0)
? ctx->expiryTime
: KRB5_INT32_MAX;
enc_part.times.renew_till = 0;
* if policy allows.
*/
static OM_uint32
-getReauthCredentials(OM_uint32 *minor,
- gss_cred_id_t cred,
- gss_name_t target,
- time_t now,
- OM_uint32 timeReq)
+getDefaultReauthCredentials(OM_uint32 *minor,
+ gss_cred_id_t cred,
+ gss_name_t target,
+ time_t now,
+ OM_uint32 timeReq)
{
OM_uint32 major = GSS_S_CRED_UNAVAIL;
krb5_context krbContext = NULL;
- krb5_error_code code;
+ krb5_error_code code = 0;
krb5_ccache ccache = NULL;
krb5_creds match = { 0 };
krb5_creds creds = { 0 };
assert(cred != GSS_C_NO_CREDENTIAL);
assert(target != GSS_C_NO_NAME);
- if (!reauthUseCredsCache(krbContext, cred->name->krbPrincipal))
+ if (cred->name == GSS_C_NO_NAME ||
+ !reauthUseCredsCache(krbContext, cred->name->krbPrincipal))
goto cleanup;
match.client = cred->name->krbPrincipal;
gss_name_t target,
OM_uint32 timeReq)
{
- time_t now;
+ time_t now, expiryReq;
+ OM_uint32 minor;
- if (cred == GSS_C_NO_CREDENTIAL)
- return FALSE;
+ assert(cred != GSS_C_NO_CREDENTIAL);
now = time(NULL);
+ expiryReq = now;
+ if (timeReq != GSS_C_INDEFINITE)
+ expiryReq += timeReq;
- if (cred->krbCredCache != NULL &&
- cred->expiryTime > time(NULL) + (timeReq ? timeReq : 0))
+ if (cred->krbCredCache != NULL && cred->expiryTime > expiryReq)
return TRUE;
- if (cred->name != GSS_C_NO_NAME) {
- OM_uint32 major, minor;
-
- major = getReauthCredentials(&minor, cred, target, now, timeReq);
-
- return !GSS_ERROR(major);
- }
+ if (getDefaultReauthCredentials(&minor, cred, target,
+ now, timeReq) == GSS_S_COMPLETE)
+ return TRUE;
return FALSE;
}
krb5_free_principal(krbContext, cred->name->krbPrincipal);
cred->name->krbPrincipal = canonPrinc;
- cred->expiryTime = creds[0]->times.endtime;
+ if (creds[0]->times.endtime == KRB5_INT32_MAX)
+ cred->expiryTime = 0;
+ else
+ cred->expiryTime = creds[0]->times.endtime;
if (cred->krbCredCache == NULL) {
if (reauthUseCredsCache(krbContext, creds[0]->client) &&
gss_buffer_t,
int *);
-#define NEXT_SYMBOL(local, global) ((local) = dlsym(RTLD_NEXT, (global)))
+#define NEXT_SYMBOL(local, global) do { \
+ ((local) = dlsym(RTLD_NEXT, (global))); \
+ if ((local) == NULL) { \
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL; \
+ major = GSS_S_UNAVAILABLE; \
+ /* but continue */ \
+ } \
+ } while (0)
OM_uint32
gssEapReauthInitialize(OM_uint32 *minor)
{
+ OM_uint32 major = GSS_S_COMPLETE;
+
NEXT_SYMBOL(gssInitSecContextNext, "gss_init_sec_context");
NEXT_SYMBOL(gssAcceptSecContextNext, "gss_accept_sec_context");
NEXT_SYMBOL(gssReleaseCredNext, "gss_release_cred");
NEXT_SYMBOL(gssStoreCredNext, "gss_store_cred");
NEXT_SYMBOL(gssGetNameAttributeNext, "gss_get_name_attribute");
- return GSS_S_COMPLETE;
+ return major;
}
OM_uint32
OM_uint32 *ret_flags,
OM_uint32 *time_rec)
{
- if (gssInitSecContextNext == NULL)
+ if (gssInitSecContextNext == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssInitSecContextNext(minor, cred, context_handle,
target_name, mech_type, req_flags,
OM_uint32 *time_rec,
gss_cred_id_t *delegated_cred_handle)
{
- if (gssAcceptSecContextNext == NULL)
+ if (gssAcceptSecContextNext == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssAcceptSecContextNext(minor, context_handle, cred,
input_token, input_chan_bindings,
gssReleaseCred(OM_uint32 *minor,
gss_cred_id_t *cred_handle)
{
- if (gssReleaseCredNext == NULL)
+ if (gssReleaseCredNext == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssReleaseCredNext(minor, cred_handle);
}
gssReleaseName(OM_uint32 *minor,
gss_name_t *name)
{
- if (gssReleaseName == NULL)
+ if (gssReleaseName == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssReleaseNameNext(minor, name);
}
gss_ctx_id_t *context_handle,
gss_buffer_t output_token)
{
- if (gssDeleteSecContextNext == NULL)
+ if (gssDeleteSecContextNext == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssDeleteSecContextNext(minor, context_handle, output_token);
}
gss_buffer_t buffer,
gss_OID *name_type)
{
- if (gssDisplayNameNext == NULL)
+ if (gssDisplayNameNext == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssDisplayNameNext(minor, name, buffer, name_type);
}
gss_OID name_type,
gss_name_t *name)
{
- if (gssImportNameNext == NULL)
+ if (gssImportNameNext == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssImportNameNext(minor, buffer, name_type, name);
}
const gss_OID desired_object,
gss_buffer_set_t *data_set)
{
- if (gssInquireSecContextByOidNext == NULL)
+ if (gssInquireSecContextByOidNext == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssInquireSecContextByOidNext(minor, context_handle,
desired_object, data_set);
gss_OID_set *elements_stored,
gss_cred_usage_t *cred_usage_stored)
{
- if (gssStoreCredNext == NULL)
+ if (gssStoreCredNext == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssStoreCredNext(minor, input_cred_handle, input_usage,
desired_mech, overwrite_cred, default_cred,
gss_buffer_t display_value,
int *more)
{
- if (gssGetNameAttributeNext == NULL)
+ if (gssGetNameAttributeNext == NULL) {
+ *minor = GSSEAP_NO_MECHGLUE_SYMBOL;
return GSS_S_UNAVAILABLE;
+ }
return gssGetNameAttributeNext(minor, name, attr, authenticated, complete,
value, display_value, more);