-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkrb5_portability.h
52 lines (51 loc) · 1.71 KB
/
krb5_portability.h
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
#ifdef HAVE_KRB5_KEYBLOCK_ENCTYPE
#define Z_keydata(keyblock) ((keyblock)->contents)
#define Z_keylen(keyblock) ((keyblock)->length)
#define Z_enctype(keyblock) ((keyblock)->enctype)
#else
#define Z_keydata(keyblock) ((keyblock)->keyvalue.data)
#define Z_keylen(keyblock) ((keyblock)->keyvalue.length)
#define Z_enctype(keyblock) ((keyblock)->keytype)
#endif
#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK
#define kte_keyblock(kte) (&(kte)->keyblock)
#else
#define kte_keyblock(kte) (&(kte)->key)
#endif
#if HAVE_DECL_KRB5_FREE_KEYTAB_ENTRY_CONTENTS
/* nothing */
#elif HAVE_DECL_KRB5_KT_FREE_ENTRY
#define krb5_free_keytab_entry_contents krb5_kt_free_entry
#else
static inline int krb5_free_keytab_entry_contents(krb5_context ctx,
krb5_keytab_entry *ent) {
krb5_free_principal(ctx, ent->principal);
krb5_free_keyblock_contents(ctx, kte_keyblock(ent));
return 0;
}
#endif
#if !HAVE_DECL_KRB5_GET_ERR_TEXT
#ifdef HAVE_COM_ERR_H
#include <com_err.h>
#else
#ifdef HAVE_ET_COM_ERR_H
#include <et/com_err.h>
#endif
#endif
#define krb5_get_err_text(c, r) error_message(r)
#endif
#if HAVE_DECL_KRB5_C_MAKE_RANDOM_KEY && !HAVE_DECL_KRB5_GENERATE_RANDOM_KEYBLOCK
#define krb5_generate_random_keyblock krb5_c_make_random_key
#endif
#if HAVE_DECL_KRB5_C_VALID_ENCTYPE && !HAVE_DECL_KRB5_ENCTYPE_VALID
#define krb5_enctype_valid(ctx, et) krb5_c_valid_enctype((et))
#endif
/* On old (pre-0.7) heimdal, krb5_enctype_valid returns a boolean,
like MIT's krb5_c_valid_enctype.
From 0.7 through 1.2 (and maybe beyond), heimdal provides both functions
and they return 0 or an error code */
#ifdef ENCTYPE_VALID_RETURNS_BOOLEAN
#define ENCTYPE_VALID 1
#else
#define ENCTYPE_VALID 0
#endif