2
* Copyright 1999-2006 University of Chicago
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
20
* @author Sam Lang, Sam Meder
22
* $RCSfile: display.c,v $
24
* $Date: 2007/08/09 14:24:23 $
28
#include "globus_i_gss_assist.h"
34
#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
37
* @ingroup globus_gsi_gss_assist
38
* Concatenate the four message strings, realloc if needed.
42
* char * to string or null (realloacted if needed)
44
* char * to first string or null
46
* char * (may not be null terminated) to first string or null
48
* length of msgring or null
50
* char * to last string or null
53
* char * to reallocated string. NULL on error
56
globus_gss_assist_strcatr(
65
static char * _function_name_ =
66
"globus_gss_assist_strcatr";
67
GLOBUS_I_GSI_GSS_ASSIST_DEBUG_ENTER;
69
len = 1 + (str ? strlen(str) : 0)
70
+ (pre ? strlen(pre) : 0)
72
+ (post ? strlen(post) : 0);
76
new = (char *)realloc(str,len);
90
new = (char *)malloc(len);
99
strncat(new,msg,msglen);
104
GLOBUS_I_GSI_GSS_ASSIST_DEBUG_EXIT;
107
#endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */
110
* @name Display Status
114
* @ingroup globus_gsi_gss_assist
115
* Display the messages for the major and minor status
116
* on the file pointed at by fp.
117
* Takes care of the overloaded major_status if there
118
* was a problem with the get_token or send_token routines.
123
* String to print out before other error messages.
124
* @param major_status
125
* The major status to display
126
* @param minor_status
127
* The minor status to display
132
globus_gss_assist_display_status(
135
OM_uint32 major_status,
136
OM_uint32 minor_status,
141
static char * _function_name_ =
142
"globus_gss_assist_display_status";
143
GLOBUS_I_GSI_GSS_ASSIST_DEBUG_ENTER;
145
ret = globus_gss_assist_display_status_str(&msg,
151
fprintf(fp, "%s", msg);
154
GLOBUS_I_GSI_GSS_ASSIST_DEBUG_EXIT;
160
* @name Display Status String
164
* @ingroup globus_gsi_gss_assist
165
* Display the messages for the major and minor status
166
* and return a string with the messages.
167
* Takes care of the overloaded major_status if there
168
* was a problem with the get_token or send_token routines.
171
* pointer to char * for returned string. Must be freed
173
* String to print out before other error messages.
174
* @param major_status
175
* The major status to display
176
* @param minor_status
177
* The minor status to display
183
globus_gss_assist_display_status_str(
186
OM_uint32 major_status,
187
OM_uint32 minor_status,
190
OM_uint32 minor_status2;
191
OM_uint32 message_context;
192
gss_buffer_desc status_string_desc
193
= GSS_C_EMPTY_BUFFER;
194
gss_buffer_t status_string = &status_string_desc;
195
char * reason1 = (char *) 0;
196
char * reason2 = (char *) 0;
200
static char * _function_name_ =
201
"globus_gss_assist_display_status_str";
202
GLOBUS_I_GSI_GSS_ASSIST_DEBUG_ENTER;
206
return GSS_S_FAILURE;
211
msg = globus_gss_assist_strcatr(msg,
212
comment ? comment : _GASL("GSS failure: "),
217
return GSS_S_FAILURE;
220
if(token_status == 0)
224
if (gss_display_status(&minor_status2,
229
status_string) == GSS_S_COMPLETE)
231
if (status_string->length)
233
tmp = globus_gss_assist_strcatr(
235
(char *) status_string->value,
236
status_string->length, "");
240
return GSS_S_FAILURE;
244
gss_release_buffer(&minor_status2, status_string);
247
while (message_context != 0);
249
/* make no assumptions about minor status */
253
if (gss_display_status(&minor_status2,
258
status_string) == GSS_S_COMPLETE)
260
if (status_string->length)
262
tmp = globus_gss_assist_strcatr(
264
(char *) status_string->value,
265
status_string->length, "");
269
return GSS_S_FAILURE;
273
gss_release_buffer(&minor_status2, status_string);
276
while (message_context != 0);
280
if (GSS_CALLING_ERROR(major_status) ==
281
GSS_S_CALL_INACCESSIBLE_READ)
283
reason1 = _GASL("read failure:");
285
else if (GSS_CALLING_ERROR(major_status) ==
286
GSS_S_CALL_INACCESSIBLE_WRITE)
288
reason1 = _GASL("write failure:");
292
reason1 = _GASL("failure:");
295
if (token_status > 0)
297
switch (token_status)
299
case GLOBUS_GSS_ASSIST_TOKEN_ERR_MALLOC:
300
reason2 = _GASL("malloc failed");
302
case GLOBUS_GSS_ASSIST_TOKEN_ERR_BAD_SIZE:
303
reason2 = _GASL("token length invalid");
305
case GLOBUS_GSS_ASSIST_TOKEN_EOF:
306
reason2 = _GASL("Connection closed");
309
reason2 = _GASL("unknown");
317
reason2 = strerror(-token_status);
322
reason2 = _GASL("unknown");
325
sprintf(buf," globus_gss_assist token :%d: %s %s\n",
326
token_status, reason1, reason2);
327
tmp = globus_gss_assist_strcatr(msg,
334
return GSS_S_FAILURE;
341
GLOBUS_I_GSI_GSS_ASSIST_DEBUG_EXIT;