1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
/*
* dsp_status.c --- display_status
*
* $Source$
* $Author$
* $Header$
*
* Copyright 1991 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* For copying and distribution information, please see the file
* <krb5/copyright.h>.
*
*/
#include <gssapi.h>
#define GSS_CE_MASK 0xFF000000
#define GSS_RE_MASK 0x00FF0000
#define GSS_SS_MASK 0x0000FFFF
#define GSS_CONTEXT_THIS(i) ((i) & 0xFFFF)
#define GSS_CONTEXT_NEXT(i) ((i) >> 16)
struct gss_error_table {
int code;
int mask;
char *string;
};
static struct gss_error_table table[] = {
{ GSS_S_CALL_INACCESSIBLE_READ, GSS_CE_MASK,
"GSSAPI Calling Error: Inaccessible read" },
{ GSS_S_CALL_INACCESSIBLE_WRITE, GSS_CE_MASK,
"GSSAPI Calling Error: Inaccessible write" },
{ GSS_S_CALL_BAD_STRUCTURE, GSS_CE_MASK,
"GSSAPI Calling Error: Bad Structure" },
{ GSS_S_BAD_MECH, GSS_RE_MASK,
"GSSAPI Routine Error: Bad Mechanism" },
{ GSS_S_BAD_NAME, GSS_RE_MASK,
"GSSAPI Routine Error: Bad Name" },
{ GSS_S_BAD_NAMETYPE, GSS_RE_MASK,
"GSSAPI Routine Error: Bad Nametype" },
{ GSS_S_BAD_BINDINGS, GSS_RE_MASK,
"GSSAPI Routine Error: Bad Bindings" },
{ GSS_S_BAD_STATUS, GSS_RE_MASK,
"GSSAPI Routine Error: Bad Status" },
{ GSS_S_BAD_SIG, GSS_RE_MASK,
"GSSAPI Routine Error: Invalid Signature" },
{ GSS_S_NO_CRED, GSS_RE_MASK,
"GSSAPI Routine Error: Missing Credentials" },
{ GSS_S_NO_CONTEXT, GSS_RE_MASK,
"GSSAPI Routine Error: Missing Context" },
{ GSS_S_DEFECTIVE_TOKEN, GSS_RE_MASK,
"GSSAPI Routine Error: Defective Token" },
{ GSS_S_DEFECTIVE_CREDENTIAL, GSS_RE_MASK,
"GSSAPI Routine Error: Defective Credential" },
{ GSS_S_CREDENTIALS_EXPIRED, GSS_RE_MASK,
"GSSAPI Routine Error: Credentials Expired" },
{ GSS_S_CONTEXT_EXPIRED, GSS_RE_MASK,
"GSSAPI Routine Error: Context expired" },
{ GSS_S_FAILURE, GSS_RE_MASK,
"GSSAPI Routine Error: Mechanism-specific failure" },
};
static int nentries = sizeof (struct gss_error_table) / sizeof (*table);
OM_uint32 gss_display_status(minor_status, status_value, status_type,
mech_type, message_context, status_string)
OM_uint32 *minor_status;
int status_value;
int status_type;
gss_OID mech_type;
int *message_context;
gss_buffer_t status_string;
{
const char *str;
int next;
int retval;
*minor_status = 0;
if (status_type == GSS_C_MECH_CODE) {
/*
* We only handle Kerberos V5...
*/
if ((mech_type != GSS_C_NULL_OID) &&
!gss_compare_OID(mech_type, &gss_OID_krb5)) {
return(GSS_S_BAD_MECH);
}
str = error_message(status_value);
retval = GSS_S_COMPLETE;
goto return_message_found;
} else {
next = *message_context;
if (next < 0 || next >= nentries) {
return(GSS_S_FAILURE);
}
if (next == 0) {
while (next < nentries) {
if ((status_value & table[next].mask) ==
table[next].code)
break;
next++;
}
if (next >= nentries)
return(GSS_S_BAD_STATUS);
}
str = table[next].string;
next++;
while (next < nentries) {
if ((status_value & table[next].mask) ==
table[next].code)
break;
next++;
}
if (next >= nentries)
retval = GSS_S_COMPLETE;
else
retval = GSS_S_CONTINUE_NEEDED;
*message_context = next;
}
return_message_found:
status_string->length = strlen(str);
if (!(status_string->value = malloc(status_string->length))) {
*minor_status = ENOMEM;
return(GSS_S_FAILURE);
}
strcpy(status_string->value, str);
return(GSS_S_COMPLETE);
}
|