/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2007, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
*/
/*
*/
#include "gssapiP_generic.h"
#include "mglueP.h" /* Solaris Kerberos */
#include <string.h>
#ifndef _WIN32
#include <unistd.h>
#endif
/* Solaris Kerberos */
#ifdef DEBUG
#endif
/* The mapping table is 0-based, but let's export codes that are
1-based, keeping 0 for errors or unknown errors.
The elements in the mapping table currently have separate copies of
each OID stored. This is a bit wasteful, but we are assuming the
table isn't likely to grow very large. */
struct mecherror {
};
static inline int
{
return -1;
return 1;
else
return 0;
}
static inline int
{
return -1;
return 1;
return -1;
return 1;
return 0;
}
static void
{
}
static inline int
{
/* Solaris Kerberos */
return EINVAL;
return ENOMEM;
else
return 0;
}
return 0;
}
static void
{
static const struct {
} mechnames[] = {
{ "{ 1 2 840 113554 1 2 2 }", "krb5-new" },
{ "{ 1 3 5 1 5 2 }", "krb5-old" },
{ "{ 1 2 840 48018 1 2 2 }", "krb5-microsoft" },
{ "{ 1 3 6 1 5 5 2 }", "spnego" },
};
unsigned int i;
fprintf(f, "(com_err)");
return;
}
fprintf(f, "(error in conversion)");
return;
}
/* Note: generic_gss_oid_to_str returns a null-terminated string. */
break;
}
}
}
#include "errmap.h"
#include "krb5.h" /* for KRB5KRB_AP_WRONG_PRINC */
static mecherrmap m;
int gssint_mecherrmap_init(void)
{
int err;
err = mecherrmap_init(&m);
if (err)
return err;
if (err) {
mecherrmap_destroy(&m);
return err;
}
return 0;
}
/* Currently the enumeration template doesn't handle freeing
element storage when destroying the collection. */
{
}
return 0;
}
void gssint_mecherrmap_destroy(void)
{
mecherrmap_destroy(&m);
}
{
const OM_uint32 *p;
int err;
#ifdef DEBUG
FILE *f;
if (f == NULL)
f = stderr;
#endif
/* Solaris Kerberos */
if (err) {
#ifdef DEBUG
#endif
return 0;
}
/* Is this status+oid already mapped? */
p = mecherrmap_findright(&m, me);
if (p != NULL) {
#ifdef DEBUG
mecherror_print(me, f);
fprintf(f, " in map as %lu\n", (unsigned long) *p);
#endif
return *p;
}
/* Is this status code already mapped to something else
mech-specific? */
/* Map it to itself plus this mech-oid. */
new_status = minor;
} else {
/* Already assigned. Pick a fake new value and map it. */
/* There's a theoretical infinite loop risk here, if we fill
in 2**32 values. Also, returning 0 has a special
meaning. */
do {
next_fake++;
if (new_status == 0)
/* ??? */;
}
if (err) {
return err;
}
if (err) {
}
#ifdef DEBUG
mecherror_print(me, f);
mecherrmap_printmap(&m, f);
fprintf(f, "\n");
#endif
if (err)
return 0;
else
return new_status;
}
{
}
{
const struct mecherror *p;
int err;
if (minor == 0) {
return EINVAL;
}
if (err)
return err;
p = mecherrmap_findleft(&m, minor);
if (!p) {
return EINVAL;
}
*mech_minor = p->code;
return 0;
}