File: GSSAPI.xs

package info (click to toggle)
libgssapi-perl 0.22-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 180 kB
  • ctags: 35
  • sloc: perl: 706; makefile: 53
file content (437 lines) | stat: -rw-r--r-- 13,308 bytes parent folder | download
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#define __KRB5_MECHTYPE_OID &mygss_mech_krb5
#define __KRB5_OLD_MECHTYPE_OID &mygss_mech_krb5_old
#define __SPNEGO_MECHTYPE_OID &myspnego_oid_desc
#define __GSS_KRB5_NT_USER_NAME &mygss_nt_krb5_name
#define __GSS_KRB5_NT_PRINCIPAL_NAME &mygss_nt_krb5_principal
#define __gss_mech_krb5_v2 &mygss_mech_krb5_v2

#if defined(HEIMDAL)
#include <gssapi.h>
#endif

#if !defined(HEIMDAL)

#include <gssapi/gssapi.h>
#include <gssapi/gssapi_generic.h>
#include <gssapi/gssapi_krb5.h>
#endif

/*

See
http://mailman.mit.edu/pipermail/krbdev/2005-February/003193.html
"
*/
static gss_OID_desc  mygss_mech_krb5  = {9, (void *) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02"};
static gss_OID_desc  mygss_mech_krb5_old  = {5, (void *) "\x2b\x05\x01\x05\x02"};

static gss_OID_desc myspnego_oid_desc = {6, (void *) "\x2b\x06\x01\x05\x05\x02"};

static gss_OID_desc mygss_nt_krb5_name =  {10, (void *) "\052\206\110\206\367\022\001\002\002\001"};

static gss_OID_desc mygss_nt_krb5_principal = {10, (void *) "\052\206\110\206\367\022\001\002\002\002"};

static gss_OID_desc mygss_mech_krb5_v2 = {9, (void *) "\052\206\110\206\367\022\001\002\003"};



static double
constant(char *name, int len, int arg)
{
    warn("GSSAPI.xs - function constant() should never be called");
    return 0;

}



/*
 * These are not part of the GSSAPI C bindings, so we can't count on
 * them being defined.  They are part of the Kerberos 1.2 GSSAPI binding
 * so we'll provide them
 */

#ifndef GSS_CALLING_ERROR_FIELD
#define GSS_CALLING_ERROR_FIELD(x) \
   (((x) >> GSS_C_CALLING_ERROR_OFFSET) & GSS_C_CALLING_ERROR_MASK)
#endif
#ifndef GSS_ROUTINE_ERROR_FIELD
#define GSS_ROUTINE_ERROR_FIELD(x) \
   (((x) >> GSS_C_ROUTINE_ERROR_OFFSET) & GSS_C_ROUTINE_ERROR_MASK)
#endif
#ifndef GSS_SUPPLEMENTARY_INFO_FIELD
#define GSS_SUPPLEMENTARY_INFO_FIELD(x) \
   (((x) >> GSS_C_SUPPLEMENTARY_OFFSET) & GSS_C_SUPPLEMENTARY_MASK)
#endif


typedef struct {
    OM_uint32	major, minor;
} gss_status_desc;
typedef gss_status_desc			GSSAPI__Status;

typedef gss_name_t			GSSAPI__Name;
typedef gss_OID				GSSAPI__OID;
typedef gss_OID_set			GSSAPI__OID__Set;
typedef gss_cred_id_t			GSSAPI__Cred;
typedef gss_ctx_id_t			GSSAPI__Context;
typedef gss_channel_bindings_t		GSSAPI__Binding;

typedef const gss_OID_desc	*	GSSAPI__OID_const;
typedef const gss_OID_set_desc	*	GSSAPI__OID__Set_const;

typedef gss_ctx_id_t			GSSAPI__Context_Iopt;

typedef gss_name_t			GSSAPI__Name_out;
typedef gss_OID				GSSAPI__OID_out;
typedef gss_OID_set			GSSAPI__OID__Set_out;
typedef gss_cred_id_t			GSSAPI__Cred_out;
typedef gss_ctx_id_t			GSSAPI__Context_out;
typedef gss_channel_bindings_t		GSSAPI__Binding_out;
typedef I32				I32_out;
typedef int				int_out;
typedef gss_cred_usage_t		gss_cred_usage_t_out;
typedef U32				U32_out;
typedef OM_uint32			OM_uint32_out;

typedef gss_name_t		*	GSSAPI__Name_optout;
typedef gss_OID			*	GSSAPI__OID_optout;
typedef gss_OID_set		*	GSSAPI__OID__Set_optout;
typedef gss_cred_id_t		*	GSSAPI__Cred_optout;
typedef I32			*	I32_optout;
typedef int			*	int_optout;
typedef gss_cred_usage_t	*	gss_cred_usage_t_optout;
typedef U32			*	U32_optout;
typedef OM_uint32		*	OM_uint32_optout;

typedef gss_name_t			GSSAPI__Name_opt;
typedef gss_OID				GSSAPI__OID_opt;
typedef gss_OID_set			GSSAPI__OID__Set_opt;
typedef gss_channel_bindings_t		GSSAPI__Binding_opt;
typedef gss_cred_id_t			GSSAPI__Cred_opt;
typedef gss_ctx_id_t			GSSAPI__Context_opt;

typedef gss_buffer_desc			gss_buffer_desc_out;
typedef gss_buffer_desc			gss_buffer_desc_copy;
typedef gss_buffer_desc			gss_buffer_str;
typedef gss_buffer_desc			gss_buffer_str_out;

typedef void *				GSSAPI_obj;


int
oid_set_is_dynamic(GSSAPI__OID__Set oidset)
{
    return 1; /* 2006-02-13 all static sets are deleted */
}


MODULE = GSSAPI		PACKAGE = GSSAPI


BOOT:
{
   HV *stash = gv_stashpvn ("GSSAPI", 6, TRUE );
#if defined( GSS_C_ACCEPT )
   newCONSTSUB( stash, "GSS_C_ACCEPT", newSVuv( GSS_C_ACCEPT ) );
#endif
#if defined( GSS_C_AF_APPLETALK )
   newCONSTSUB( stash, "GSS_C_AF_APPLETALK", newSVuv( GSS_C_AF_APPLETALK ) );
#endif
#if defined( GSS_C_AF_BSC )
   newCONSTSUB( stash, "GSS_C_AF_BSC", newSVuv( GSS_C_AF_BSC ) );
#endif
#if defined( GSS_C_AF_CCITT )
   newCONSTSUB( stash, "GSS_C_AF_CCITT", newSVuv( GSS_C_AF_CCITT ) );
#endif
#if defined( GSS_C_AF_CHAOS )
   newCONSTSUB( stash, "GSS_C_AF_CHAOS", newSVuv( GSS_C_AF_CHAOS ) );
#endif
#if defined( GSS_C_AF_DATAKIT )
   newCONSTSUB( stash, "GSS_C_AF_DATAKIT", newSVuv( GSS_C_AF_DATAKIT ) );
#endif
#if defined( GSS_C_AF_DECnet )
   newCONSTSUB( stash, "GSS_C_AF_DECnet", newSVuv( GSS_C_AF_DECnet ) );
#endif
#if defined( GSS_C_AF_DLI )
   newCONSTSUB( stash, "GSS_C_AF_DLI", newSVuv( GSS_C_AF_DLI ) );
#endif
#if defined( GSS_C_AF_DSS )
   newCONSTSUB( stash, "GSS_C_AF_DSS", newSVuv( GSS_C_AF_DSS ) );
#endif
#if defined( GSS_C_AF_ECMA )
   newCONSTSUB( stash, "GSS_C_AF_ECMA", newSVuv( GSS_C_AF_ECMA ) );
#endif
#if defined( GSS_C_AF_HYLINK )
   newCONSTSUB( stash, "GSS_C_AF_HYLINK", newSVuv( GSS_C_AF_HYLINK ) );
#endif
#if defined( GSS_C_AF_IMPLINK )
   newCONSTSUB( stash, "GSS_C_AF_IMPLINK", newSVuv( GSS_C_AF_IMPLINK ) );
#endif
#if defined( GSS_C_AF_INET )
   newCONSTSUB( stash, "GSS_C_AF_INET", newSVuv( GSS_C_AF_INET ) );
#endif
#if defined( GSS_C_AF_LAT )
   newCONSTSUB( stash, "GSS_C_AF_LAT", newSVuv( GSS_C_AF_LAT ) );
#endif
#if defined( GSS_C_AF_LOCAL )
   newCONSTSUB( stash, "GSS_C_AF_LOCAL", newSVuv( GSS_C_AF_LOCAL ) );
#endif
#if defined( GSS_C_AF_NBS )
   newCONSTSUB( stash, "GSS_C_AF_NBS", newSVuv( GSS_C_AF_NBS ) );
#endif
#if defined( GSS_C_AF_NS )
   newCONSTSUB( stash, "GSS_C_AF_NS", newSVuv( GSS_C_AF_NS ) );
#endif
#if defined( GSS_C_AF_NULLADDR )
   newCONSTSUB( stash, "GSS_C_AF_NULLADDR", newSVuv( GSS_C_AF_NULLADDR ) );
#endif
#if defined( GSS_C_AF_OSI )
   newCONSTSUB( stash, "GSS_C_AF_OSI", newSVuv( GSS_C_AF_OSI ) );
#endif
#if defined( GSS_C_AF_PUP )
   newCONSTSUB( stash, "GSS_C_AF_PUP", newSVuv( GSS_C_AF_PUP ) );
#endif
#if defined( GSS_C_AF_SNA )
   newCONSTSUB( stash, "GSS_C_AF_SNA", newSVuv( GSS_C_AF_SNA ) );
#endif
#if defined( GSS_C_AF_UNSPEC )
   newCONSTSUB( stash, "GSS_C_AF_UNSPEC", newSVuv( GSS_C_AF_UNSPEC ) );
#endif
#if defined( GSS_C_AF_X25 )
   newCONSTSUB( stash, "GSS_C_AF_X25", newSVuv( GSS_C_AF_X25 ) );
#endif
#if defined( GSS_C_ANON_FLAG )
   newCONSTSUB( stash, "GSS_C_ANON_FLAG", newSVuv( GSS_C_ANON_FLAG ) );
#endif
#if defined( GSS_C_BOTH )
   newCONSTSUB( stash, "GSS_C_BOTH", newSVuv( GSS_C_BOTH ) );
#endif
#if defined( GSS_C_CALLING_ERROR_MASK )
   newCONSTSUB( stash, "GSS_C_CALLING_ERROR_MASK", newSVuv( GSS_C_CALLING_ERROR_MASK ) );
#endif
#if defined( GSS_C_CALLING_ERROR_OFFSET )
   newCONSTSUB( stash, "GSS_C_CALLING_ERROR_OFFSET", newSVuv( GSS_C_CALLING_ERROR_OFFSET ) );
#endif
#if defined( GSS_C_CONF_FLAG )
   newCONSTSUB( stash, "GSS_C_CONF_FLAG", newSVuv( GSS_C_CONF_FLAG ) );
#endif
#if defined( GSS_C_DELEG_FLAG )
   newCONSTSUB( stash, "GSS_C_DELEG_FLAG", newSVuv( GSS_C_DELEG_FLAG ) );
#endif
#if defined( GSS_C_GSS_CODE )
   newCONSTSUB( stash, "GSS_C_GSS_CODE", newSVuv( GSS_C_GSS_CODE ) );
#endif
#if defined( GSS_C_INDEFINITE )
   newCONSTSUB( stash, "GSS_C_INDEFINITE", newSVuv( GSS_C_INDEFINITE ) );
#endif
#if defined( GSS_C_INITIATE )
   newCONSTSUB( stash, "GSS_C_INITIATE", newSVuv( GSS_C_INITIATE ) );
#endif
#if defined( GSS_C_INTEG_FLAG )
   newCONSTSUB( stash, "GSS_C_INTEG_FLAG", newSVuv( GSS_C_INTEG_FLAG ) );
#endif
#if defined( GSS_C_MECH_CODE )
   newCONSTSUB( stash, "GSS_C_MECH_CODE", newSVuv( GSS_C_MECH_CODE ) );
#endif
#if defined( GSS_C_MUTUAL_FLAG )
   newCONSTSUB( stash, "GSS_C_MUTUAL_FLAG", newSVuv( GSS_C_MUTUAL_FLAG ) );
#endif
#if defined( GSS_C_PROT_READY_FLAG )
   newCONSTSUB( stash, "GSS_C_PROT_READY_FLAG", newSVuv( GSS_C_PROT_READY_FLAG ) );
#endif
#if defined( GSS_C_QOP_DEFAULT )
   newCONSTSUB( stash, "GSS_C_QOP_DEFAULT", newSVuv( GSS_C_QOP_DEFAULT ) );
#endif
#if defined( GSS_C_REPLAY_FLAG )
   newCONSTSUB( stash, "GSS_C_REPLAY_FLAG", newSVuv( GSS_C_REPLAY_FLAG ) );
#endif
#if defined( GSS_C_ROUTINE_ERROR_MASK )
   newCONSTSUB( stash, "GSS_C_ROUTINE_ERROR_MASK", newSVuv( GSS_C_ROUTINE_ERROR_MASK ) );
#endif
#if defined( GSS_C_ROUTINE_ERROR_OFFSET )
   newCONSTSUB( stash, "GSS_C_ROUTINE_ERROR_OFFSET", newSVuv( GSS_C_ROUTINE_ERROR_OFFSET ) );
#endif
#if defined( GSS_C_SEQUENCE_FLAG )
   newCONSTSUB( stash, "GSS_C_SEQUENCE_FLAG", newSVuv( GSS_C_SEQUENCE_FLAG ) );
#endif
#if defined( GSS_C_SUPPLEMENTARY_MASK )
   newCONSTSUB( stash, "GSS_C_SUPPLEMENTARY_MASK", newSVuv( GSS_C_SUPPLEMENTARY_MASK ) );
#endif
#if defined( GSS_C_SUPPLEMENTARY_OFFSET )
   newCONSTSUB( stash, "GSS_C_SUPPLEMENTARY_OFFSET", newSVuv( GSS_C_SUPPLEMENTARY_OFFSET ) );
#endif
#if defined( GSS_C_TRANS_FLAG )
   newCONSTSUB( stash, "GSS_C_TRANS_FLAG", newSVuv( GSS_C_TRANS_FLAG ) );
#endif
#if defined( GSS_S_BAD_BINDINGS )
   newCONSTSUB( stash, "GSS_S_BAD_BINDINGS", newSVuv( GSS_S_BAD_BINDINGS ) );
#endif
#if defined( GSS_S_BAD_MECH )
   newCONSTSUB( stash, "GSS_S_BAD_MECH", newSVuv( GSS_S_BAD_MECH ) );
#endif
#if defined( GSS_S_BAD_NAME )
   newCONSTSUB( stash, "GSS_S_BAD_NAME", newSVuv( GSS_S_BAD_NAME ) );
#endif
#if defined( GSS_S_BAD_NAMETYPE )
   newCONSTSUB( stash, "GSS_S_BAD_NAMETYPE", newSVuv( GSS_S_BAD_NAMETYPE ) );
#endif
#if defined( GSS_S_BAD_QOP )
   newCONSTSUB( stash, "GSS_S_BAD_QOP", newSVuv( GSS_S_BAD_QOP ) );
#endif
#if defined( GSS_S_BAD_SIG )
   newCONSTSUB( stash, "GSS_S_BAD_SIG", newSVuv( GSS_S_BAD_SIG ) );
#endif
#if defined( GSS_S_BAD_STATUS )
   newCONSTSUB( stash, "GSS_S_BAD_STATUS", newSVuv( GSS_S_BAD_STATUS ) );
#endif
#if defined( GSS_S_CALL_BAD_STRUCTURE )
   newCONSTSUB( stash, "GSS_S_CALL_BAD_STRUCTURE", newSVuv( GSS_S_CALL_BAD_STRUCTURE ) );
#endif
#if defined( GSS_S_CALL_INACCESSIBLE_READ )
   newCONSTSUB( stash, "GSS_S_CALL_INACCESSIBLE_READ", newSVuv( GSS_S_CALL_INACCESSIBLE_READ ) );
#endif
#if defined( GSS_S_CALL_INACCESSIBLE_WRITE )
   newCONSTSUB( stash, "GSS_S_CALL_INACCESSIBLE_WRITE", newSVuv( GSS_S_CALL_INACCESSIBLE_WRITE ) );
#endif
#if defined( GSS_S_COMPLETE )
   newCONSTSUB( stash, "GSS_S_COMPLETE", newSVuv( GSS_S_COMPLETE ) );
#endif
#if defined( GSS_S_CONTEXT_EXPIRED )
   newCONSTSUB( stash, "GSS_S_CONTEXT_EXPIRED", newSVuv( GSS_S_CONTEXT_EXPIRED ) );
#endif
#if defined( GSS_S_CONTINUE_NEEDED )
   newCONSTSUB( stash, "GSS_S_CONTINUE_NEEDED", newSVuv( GSS_S_CONTINUE_NEEDED ) );
#endif
#if defined( GSS_S_CREDENTIALS_EXPIRED )
   newCONSTSUB( stash, "GSS_S_CREDENTIALS_EXPIRED", newSVuv( GSS_S_CREDENTIALS_EXPIRED ) );
#endif
#if defined( GSS_S_CRED_UNAVAIL )
   newCONSTSUB( stash, "GSS_S_CRED_UNAVAIL", newSVuv( GSS_S_CRED_UNAVAIL ) );
#endif
#if defined( GSS_S_DEFECTIVE_CREDENTIAL )
   newCONSTSUB( stash, "GSS_S_DEFECTIVE_CREDENTIAL", newSVuv( GSS_S_DEFECTIVE_CREDENTIAL ) );
#endif
#if defined( GSS_S_DEFECTIVE_TOKEN )
   newCONSTSUB( stash, "GSS_S_DEFECTIVE_TOKEN", newSVuv( GSS_S_DEFECTIVE_TOKEN ) );
#endif
#if defined( GSS_S_DUPLICATE_ELEMENT )
   newCONSTSUB( stash, "GSS_S_DUPLICATE_ELEMENT", newSVuv( GSS_S_DUPLICATE_ELEMENT ) );
#endif
#if defined( GSS_S_DUPLICATE_TOKEN )
   newCONSTSUB( stash, "GSS_S_DUPLICATE_TOKEN", newSVuv( GSS_S_DUPLICATE_TOKEN ) );
#endif
#if defined( GSS_S_FAILURE )
   newCONSTSUB( stash, "GSS_S_FAILURE", newSVuv( GSS_S_FAILURE ) );
#endif
#if defined( GSS_S_GAP_TOKEN )
   newCONSTSUB( stash, "GSS_S_GAP_TOKEN", newSVuv( GSS_S_GAP_TOKEN ) );
#endif
#if defined( GSS_S_NAME_NOT_MN )
   newCONSTSUB( stash, "GSS_S_NAME_NOT_MN", newSVuv( GSS_S_NAME_NOT_MN ) );
#endif
#if defined( GSS_S_NO_CONTEXT )
   newCONSTSUB( stash, "GSS_S_NO_CONTEXT", newSVuv( GSS_S_NO_CONTEXT ) );
#endif
#if defined( GSS_S_NO_CRED )
   newCONSTSUB( stash, "GSS_S_NO_CRED", newSVuv( GSS_S_NO_CRED ) );
#endif
#if defined( GSS_S_OLD_TOKEN )
   newCONSTSUB( stash, "GSS_S_OLD_TOKEN", newSVuv( GSS_S_OLD_TOKEN ) );
#endif
#if defined( GSS_S_UNAUTHORIZED )
   newCONSTSUB( stash, "GSS_S_UNAUTHORIZED", newSVuv( GSS_S_UNAUTHORIZED ) );
#endif
#if defined( GSS_S_UNAVAILABLE )
   newCONSTSUB( stash, "GSS_S_UNAVAILABLE", newSVuv( GSS_S_UNAVAILABLE ) );
#endif
#if defined( GSS_S_UNSEQ_TOKEN )
   newCONSTSUB( stash, "GSS_S_UNSEQ_TOKEN", newSVuv( GSS_S_UNSEQ_TOKEN ) );
#endif
}


PROTOTYPES: ENABLE

int
gssapi_implementation_is_heimdal()
CODE:
#if defined(HEIMDAL)
      RETVAL = 1;
#endif
#if !defined(HEIMDAL)
      RETVAL = 0;
#endif
OUTPUT:
        RETVAL


double
constant(sv,arg)
    PREINIT:
	STRLEN		len;
    INPUT:
	SV *		sv
	char *		s = SvPV(sv, len);
	int		arg
    CODE:
	RETVAL = constant(s,len,arg);
    OUTPUT:
	RETVAL


GSSAPI::Status
indicate_mechs(oidset)
	GSSAPI::OID::Set_out	oidset
    CODE:
	RETVAL.major = gss_indicate_mechs(&RETVAL.minor, &oidset);
    OUTPUT:
	RETVAL
	oidset

bool
is_valid(object)
	GSSAPI_obj	object
    CODE:
	RETVAL = (object != NULL);
    OUTPUT:
	RETVAL


MODULE = GSSAPI		PACKAGE = GSSAPI::Status

INCLUDE: xs/Status.xs


MODULE = GSSAPI		PACKAGE = GSSAPI::Name

INCLUDE: xs/Name.xs


MODULE = GSSAPI		PACKAGE = GSSAPI::OID

INCLUDE: xs/OID.xs


MODULE = GSSAPI		PACKAGE = GSSAPI::OID::Set

INCLUDE: xs/OID__Set.xs


MODULE = GSSAPI		PACKAGE = GSSAPI::Cred

INCLUDE: xs/Cred.xs


MODULE = GSSAPI		PACKAGE = GSSAPI::Binding

INCLUDE: xs/Binding.xs


MODULE = GSSAPI		PACKAGE = GSSAPI::Context

INCLUDE: xs/Context.xs