mech-gssapi.c revision a64adf62fa33f2463a86f990217b0c9078531a40
/*
* GSSAPI Module
*
* Copyright (c) 2005 Jelmer Vernooij <jelmer@samba.org>
*
* Related standards:
* - draft-ietf-sasl-gssapi-03
* - RFC2222
*
* Some parts inspired by an older patch from Colin Walters
*
* This software is released under the MIT license.
*/
#include "common.h"
#include "env-util.h"
#include "str.h"
#include "str-sanitize.h"
#include "hex-binary.h"
#include "safe-memset.h"
#include "mech.h"
#include "passdb.h"
#include <stdlib.h>
#ifdef HAVE_GSSAPI
#ifndef HAVE___GSS_USEROK
# define USE_KRB5_USEROK
# include <krb5.h>
#endif
#ifdef HAVE_GSSAPI_GSSAPI_H
#elif defined (HAVE_GSSAPI_H)
# include <gssapi.h>
#endif
#ifdef HAVE_GSSAPI_GSSAPI_KRB5_H
# include <gssapi/gssapi_krb5.h>
#elif defined (HAVE_GSSAPI_KRB5_H)
# include <gssapi_krb5.h>
#else
#endif
#ifdef HAVE_GSSAPI_GSSAPI_EXT_H
# include <gssapi/gssapi_ext.h>
#endif
/* Non-zero flags defined in RFC 2222 */
enum sasl_gssapi_qop {
SASL_GSSAPI_QOP_UNSPECIFIED = 0x00,
SASL_GSSAPI_QOP_AUTH_ONLY = 0x01,
SASL_GSSAPI_QOP_AUTH_INT = 0x02,
SASL_GSSAPI_QOP_AUTH_CONF = 0x04
};
struct gssapi_auth_request {
struct auth_request auth_request;
enum {
};
static bool gssapi_initialized = FALSE;
const char *description)
{
OM_uint32 message_context = 0;
do {
"While %s: %s", description,
} while (message_context != 0);
}
{
if (*path != '\0') {
/* environment may be used by Kerberos 5 library directly */
#elif defined (HAVE_KRB5_GSS_REGISTER_ACCEPTOR_IDENTITY)
#endif
}
}
static struct auth_request *mech_gssapi_auth_new(void)
{
struct gssapi_auth_request *request;
return &request->auth_request;
}
{
const char *service_name;
if (!gssapi_initialized) {
}
"Using all keytab entries");
return GSS_S_COMPLETE;
}
/* The standard POP3 service name with GSSAPI is called
just "pop". */
service_name = "pop";
} else {
}
if (GSS_ERROR(major_status)) {
"importing principal name");
return major_status;
}
if (GSS_ERROR(major_status)) {
"acquiring service credentials");
"acquiring service credentials");
return major_status;
}
return major_status;
}
#ifndef HAVE___GSS_USEROK
static gss_name_t
{
&name_buf,
&name);
if (GSS_ERROR(major_status)) {
GSS_C_GSS_CODE, "gss_import_name");
return GSS_C_NO_NAME;
}
return name;
}
#endif
{
&inbuf,
NULL, /* mech_type */
&outbuf,
NULL, /* ret_flags */
NULL, /* time_rec */
NULL /* delegated_cred_handle */
);
if (GSS_ERROR(major_status)) {
"processing incoming data");
"processing incoming data");
return;
}
if (major_status == GSS_S_COMPLETE) {
"security context state completed.");
} else {
"Processed incoming packet correctly, "
"waiting for another.");
}
}
{
unsigned char ret[4];
/* The clients return data should be empty here */
/* Only authentication, no integrity or confidentiality
protection (yet?) */
ret[0] = (SASL_GSSAPI_QOP_UNSPECIFIED |
if (GSS_ERROR(major_status)) {
GSS_C_GSS_CODE, "sending security layer negotiation");
GSS_C_MECH_CODE, "sending security layer negotiation");
return;
}
"Negotiated security layer");
}
#ifdef USE_KRB5_USEROK
{
const char *princ_display_name;
/* Parse out the principal's username */
&princ_name, &name_type);
if (major_status != GSS_S_COMPLETE) {
"gssapi_krb5_userok");
return FALSE;
}
if (name_type != GSS_KRB5_NT_PRINCIPAL_NAME) {
"OID not kerberos principal name");
return FALSE;
}
/* Init a krb5 context and parse the principal username */
if (krb5_err != 0) {
"krb5_init_context() failed: %d", (int)krb5_err);
return FALSE;
}
if (krb5_err != 0) {
/* writing the error string would be better, but we probably
rarely get here and there doesn't seem to be a standard
way of getting it */
"krb5_parse_name() failed: %d",
(int)krb5_err);
} else {
/* See if the principal is authorized to act as the
specified user */
}
return ret;
}
#endif
{
int equal_authn_authz = 0;
if (GSS_ERROR(major_status)) {
"final negotiation: gss_unwrap");
return;
}
"Invalid response length");
return;
}
#ifdef HAVE___GSS_USEROK
/* Solaris __gss_userok() correctly handles cross-realm
authentication. */
if (GSS_ERROR(major_status)) {
"__gss_userok failed");
return;
}
if (equal_authn_authz == 0) {
"credentials not valid");
return;
}
#else
/* XXX (pod): is this check necessary? */
"one of authn_name or authz_name not determined");
return;
}
#ifdef USE_KRB5_USEROK
if (equal_authn_authz == 0)
#endif
if (equal_authn_authz == 0) {
"authn_name and authz_name differ: not supported");
return;
}
#endif
}
static void
{
struct gssapi_auth_request *gssapi_request =
(struct gssapi_auth_request *)request;
switch (gssapi_request->sasl_gssapi_state) {
case GSS_STATE_SEC_CONTEXT:
break;
case GSS_STATE_WRAP:
break;
case GSS_STATE_UNWRAP:
break;
}
}
static void
{
struct gssapi_auth_request *gssapi_request =
(struct gssapi_auth_request *)request;
if (GSS_ERROR(major_status)) {
return;
}
if (data_size == 0) {
/* The client should go first */
NULL, 0);
} else {
}
}
static void
{
struct gssapi_auth_request *gssapi_request =
(struct gssapi_auth_request *)request;
}
}
}
}
const struct mech_module mech_gssapi = {
"GSSAPI",
};
/* MTI Kerberos v1.5+ and Heimdal v0.7+ supports SPNEGO for Kerberos tickets
internally. Nothing else needs to be done here. Note however that this does
not support SPNEGO when the only available credential is NTLM.. */
const struct mech_module mech_gssapi_spnego = {
"GSS-SPNEGO",
};
#ifndef BUILTIN_GSSAPI
void mech_gssapi_init(void);
void mech_gssapi_deinit(void);
void mech_gssapi_init(void)
{
#ifdef HAVE_GSSAPI_SPNEGO
#endif
}
void mech_gssapi_deinit(void)
{
#ifdef HAVE_GSSAPI_SPNEGO
#endif
}
#endif
#endif