summaryrefslogtreecommitdiff
path: root/portable/gssapi.h
blob: 82b430cb8de0b3f903298e8a747d2e7eed118f04 (plain)
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
/*
 * Portability wrapper around <gssapi.h>.
 *
 * This header tries to encapsulate the differences between the MIT and
 * Heimdal GSS-API implementations and the differences between various
 * versions.
 *
 * The canonical version of this file is maintained in the rra-c-util package,
 * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
 *
 * Written by Russ Allbery <eagle@eyrie.org>
 *
 * The authors hereby relinquish any claim to any copyright that they may have
 * in this work, whether granted under contract or by operation of law or
 * international treaty, and hereby commit to the public, at large, that they
 * shall not, at any time in the future, seek to enforce any copyright in this
 * work against any person or entity, or prevent any person or entity from
 * copying, publishing, distributing or creating derivative works of this
 * work.
 */

#ifndef PORTABLE_GSSAPI_H
#define PORTABLE_GSSAPI_H 1

#include <config.h>
#include <portable/system.h>

#ifdef HAVE_GSSAPI_GSSAPI_H
# include <gssapi/gssapi.h>
#else
# include <gssapi.h>
#endif
#ifdef HAVE_GSSAPI_GSSAPI_KRB5_H
# include <gssapi/gssapi_krb5.h>
#endif

/* Handle compatibility to older versions of MIT Kerberos. */
#ifndef HAVE_GSS_RFC_OIDS
# include <gssapi/gssapi_generic.h>
# define GSS_C_NT_USER_NAME gss_nt_user_name
# define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
#endif

/*
 * Heimdal provides a nice #define for this.  Sun, on the other hand,
 * provides no standard define at all, so configure has to add gssapi-mech.c
 * to the build and we declare the external symbol that will point to a
 * hard-coded GSS-API OID struct.
 */
#if !HAVE_DECL_GSS_KRB5_MECHANISM
# if !HAVE_DECL_GSS_MECH_KRB5
extern const gss_OID_desc * const gss_mech_krb5;
# endif
# define GSS_KRB5_MECHANISM gss_mech_krb5
#endif

/*
 * Older versions of Heimdal are missing gss_oid_equal.  Replace with an
 * expression to check the struct members directly.
 */
#ifndef HAVE_GSS_OID_EQUAL
# define gss_oid_equal(x, y)                                    \
    ((x)->length == (y)->length &&                              \
     memcmp((x)->elements, (y)->elements, (x)->length) == 0)
#endif

#endif /* PORTABLE_GSSAPI_H */