Move kerberos_kinit_keyblock_cc to krb5samba lib
[idra/samba.git] / source4 / heimdal_build / wscript_configure
1 #!/usr/bin/env python
2 # Waf build script for Samba 4's bundled Heimdal.
3
4 # Unless explicitly requested by the user (e.g.
5 # "./configure --bundled-libraries=!asn1_compile") this will always use the
6 # bundled Heimdal, even if a system heimdal was found. The reason
7 # for this is that our checks for the system heimdal are not accurate
8 # enough yet to know if it is usable (some bug fix might be missing,
9 # compile_et might not generate the expected code, etc).
10
11 import Logs, sys
12
13 conf.CHECK_TYPE('u_char', 'uint8_t')
14 conf.CHECK_TYPE('u_int32_t', 'uint32_t')
15
16 conf.CHECK_HEADERS('err.h')
17
18 conf.CHECK_HEADERS('ifaddrs.h')
19 conf.CHECK_HEADERS('''crypt.h errno.h inttypes.h netdb.h signal.h sys/bswap.h
20                   sys/file.h sys/stropts.h sys/timeb.h sys/times.h sys/uio.h sys/un.h
21               sys/utsname.h time.h timezone.h ttyname.h netinet/in.h
22               netinet/in6.h netinet6/in6.h libintl.h''')
23
24 conf.CHECK_HEADERS('curses.h term.h termcap.h', together=True)
25
26 conf.CHECK_FUNCS('''atexit cgetent getprogname setprogname gethostname
27                     putenv rcmd readv sendmsg setitimer strlwr strncasecmp
28             strptime strsep strsep_copy    strtok_r strupr swab umask uname unsetenv
29             closefrom err warn errx warnx flock writev''')
30
31 conf.CHECK_FUNCS_IN('hstrerror', 'resolv socket nsl', checklibc=True)
32 conf.CHECK_FUNCS_IN('''getnameinfo sendmsg socket getipnodebyname gethostent gethostent_r
33                        sethostent endhostent getipnodebyaddr freehostent gethostbyname
34                        gethostbyname_r gethostbyaddr''',
35                     'socket nsl',
36                     checklibc=True)
37
38 conf.CHECK_FUNCS_IN('dgettext gettext', 'intl', headers='libintl.h')
39
40 conf.CHECK_FUNCS('iruserok')
41
42 conf.CHECK_FUNCS('bswap16')
43 conf.CHECK_FUNCS('bswap32')
44
45 conf.CHECK_TYPE('struct winsize', define='HAVE_STRUCT_WINSIZE', headers='sys/termios.h sys/ioctl.h')
46 conf.CHECK_STRUCTURE_MEMBER('struct winsize', 'ws_xpixel',
47                     define='HAVE_WS_XPIXEL', headers='sys/termios.h sys/ioctl.h')
48 conf.CHECK_STRUCTURE_MEMBER('struct winsize', 'ws_ypixel',
49                     define='HAVE_WS_YPIXEL', headers='sys/termios.h sys/ioctl.h')
50 conf.DEFINE('HAVE_KRB_STRUCT_WINSIZE', 1)
51 conf.DEFINE('VOID_RETSIGTYPE', 1)
52
53 conf.CHECK_VARIABLE('h_errno', headers='netdb.h')
54
55 # strangely enough, we need it with another define too
56 conf.CHECK_DECLS('h_errno', headers='netdb.h')
57
58 conf.CHECK_FUNCS_IN('res_search res_nsearch res_ndestroy dns_search dn_expand', 'resolv',
59                     checklibc=True, headers='netinet/in.h arpa/nameser.h resolv.h dns.h')
60 conf.CHECK_VARIABLE('_res', headers='netinet/in.h arpa/nameser.h resolv.h')
61 conf.CHECK_DECLS('_res', headers='netinet/in.h arpa/nameser.h resolv.h')
62 conf.CHECK_FUNCS_IN('openpty', 'util', checklibc=True, headers='pty.h util.h libutil.h')
63
64 conf.DEFINE('HAVE_KRB5',1)
65
66 conf.CHECK_FUNCS('dirfd', headers='dirent.h')
67 conf.CHECK_DECLS('dirfd', reverse=True, headers='dirent.h')
68 conf.CHECK_STRUCTURE_MEMBER('DIR', 'dd_fd', define='HAVE_DIR_DD_FD',  headers='dirent.h')
69
70 conf.DEFINE('SAMBA4_USES_HEIMDAL', 1)
71
72 # setup the right defines for a in-tree heimdal build
73 Logs.info("Using in-tree heimdal kerberos defines")
74 conf.define('HAVE_GSSAPI_GSSAPI_H', 1)
75 conf.define('HAVE_GSSAPI_GSSAPI_KRB5_H', 1)
76 conf.define('HAVE_AP_OPTS_USE_SUBKEY', 1)
77 conf.define('HAVE_KRB5_ADDRESSES', 1)
78 conf.define('HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK', 1)
79 conf.define('HAVE_KRB5_SET_REAL_TIME', 1)
80 conf.define('HAVE_COM_ERR_H', 1)
81 conf.define('HAVE_ADDR_TYPE_IN_KRB5_ADDRESS', 1)
82 conf.define('HAVE_GSS_DISPLAY_STATUS', 1)
83 conf.define('HAVE_GSS_WRAP_IOV', 1)
84 conf.define('HAVE_GSS_KRB5_IMPORT_CRED', 1)
85 conf.define('HAVE_GSS_OID_EQUAL', 1)
86 conf.define('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID', 1)
87 conf.define('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT', 1)
88 conf.define('HAVE_GSSKRB5_GET_SUBKEY', 1)
89 conf.define('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT', 1)
90 conf.define('HAVE_LIBGSSAPI', 1)
91 conf.define('HAVE_ADDR_TYPE_IN_KRB5_ADDRESS', 1)
92 conf.define('HAVE_CHECKSUM_IN_KRB5_CHECKSUM', 1)
93 conf.define('HAVE_DECL_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE', 0)
94 conf.define('HAVE_DECL_KRB5_GET_CREDENTIALS_FOR_USER', 0)
95 conf.define('HAVE_E_DATA_POINTER_IN_KRB5_ERROR', 1)
96 conf.define('HAVE_INITIALIZE_KRB5_ERROR_TABLE', 1)
97 conf.define('HAVE_KRB5_ADDRESSES', 1)
98 conf.define('HAVE_KRB5_AUTH_CON_SETKEY', 1)
99 conf.define('HAVE_KRB5_CRYPTO', 1)
100 conf.define('HAVE_KRB5_CRYPTO_DESTROY', 1)
101 conf.define('HAVE_KRB5_CRYPTO_INIT', 1)
102 conf.define('HAVE_KRB5_C_VERIFY_CHECKSUM', 1)
103 conf.define('HAVE_KRB5_ENCTYPE_TO_STRING', 1)
104 conf.define('HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG', 1)
105 conf.define('HAVE_KRB5_FREE_ERROR_CONTENTS', 1)
106 conf.define('HAVE_KRB5_FREE_HOST_REALM', 1)
107 conf.define('HAVE_KRB5_FWD_TGT_CREDS', 1)
108 conf.define('HAVE_KRB5_GET_CREDS', 1)
109 conf.define('HAVE_KRB5_GET_CREDS_OPT_ALLOC', 1)
110 conf.define('HAVE_KRB5_GET_CREDS_OPT_SET_IMPERSONATE', 1)
111 conf.define('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES', 1)
112 conf.define('HAVE_KRB5_GET_HOST_REALM', 1)
113 conf.define('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC', 1)
114 conf.define('HAVE_KRB5_GET_INIT_CREDS_OPT_FREE', 1)
115 conf.define('HAVE_KRB5_GET_INIT_CREDS_OPT_GET_ERROR', 1)
116 conf.define('HAVE_KRB5_GET_INIT_CREDS_OPT_SET_PAC_REQUEST', 1)
117 conf.define('HAVE_KRB5_GET_INIT_CREDS_KEYBLOCK', 1)
118 conf.define('HAVE_KRB5_GET_PW_SALT', 1)
119 conf.define('HAVE_KRB5_GET_RENEWED_CREDS', 1)
120 conf.define('HAVE_KRB5_KEYBLOCK_KEYVALUE', 1)
121 conf.define('HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK', 1)
122 conf.define('HAVE_KRB5_KRBHST_GET_ADDRINFO', 1)
123 conf.define('HAVE_KRB5_KRBHST_INIT', 1)
124 conf.define('HAVE_KRB5_KT_COMPARE', 1)
125 conf.define('HAVE_KRB5_KT_FREE_ENTRY', 1)
126 conf.define('HAVE_KRB5_KU_OTHER_CKSUM', 1)
127 conf.define('HAVE_KRB5_LOCATE_PLUGIN_H', 1)
128 conf.define('HAVE_KRB5_MK_REQ_EXTENDED', 1)
129 conf.define('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM', 1)
130 conf.define('HAVE_KRB5_PRINCIPAL_GET_COMP_STRING', 1)
131 conf.define('HAVE_KRB5_PRINCIPAL_GET_REALM', 1)
132 conf.define('HAVE_KRB5_REALM_TYPE', 1)
133 conf.define('HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES', 1)
134 conf.define('HAVE_KRB5_SET_REAL_TIME', 1)
135 conf.define('HAVE_KRB5_STRING_TO_KEY', 1)
136 conf.define('HAVE_KRB5_STRING_TO_KEY_SALT', 1)
137 conf.define('HAVE_LIBKRB5', 1)
138 conf.define('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT', 1)
139 conf.define('HAVE_ETYPE_IN_ENCRYPTEDDATA', 1)
140 conf.define('KRB5_PRINC_REALM_RETURNS_REALM', 1)
141 conf.define('HAVE_KRB5_PRINCIPAL_GET_REALM', 1)
142 conf.define('HAVE_KRB5_H', 1)
143 conf.define('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', 1)
144 conf.define('HAVE_AP_OPTS_USE_SUBKEY', 1)
145 conf.define('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', 1)
146 conf.define('HAVE_ENCTYPE_ARCFOUR_HMAC', 1)
147 conf.define('HAVE_KRB5_PDU_NONE_DECL', 1)
148 conf.define('HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96', 1)
149 conf.define('HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96', 1)
150 conf.define('HAVE_KRB5_KRB5_PRINCIPAL_GET_NUM_COMP', 1)
151 conf.define('HAVE_GSSAPI_GSSAPI_SPNEGO_H', 1)
152
153 heimdal_includedirs = []
154 heimdal_libdirs = []
155 krb5_config = conf.find_program("krb5-config.heimdal", var="HEIMDAL_KRB5_CONFIG")
156 if not krb5_config:
157     krb5_config = conf.find_program("krb5-config", var="HEIMDAL_KRB5_CONFIG")
158 if krb5_config:
159     # Not ideal, but seems like the best way to get at these paths:
160     f = open(krb5_config, 'r')
161     try:
162         for l in f:
163             if l.startswith("libdir="):
164                 heimdal_libdirs.append(l.strip()[len("libdir="):])
165             elif l.startswith("includedir="):
166                 heimdal_includedirs.append(l.strip()[len("includedir="):])
167     finally:
168         f.close()
169
170 if conf.CHECK_BUNDLED_SYSTEM('com_err', checkfunctions='com_right_r com_err', headers='com_err.h'):
171     conf.define('USING_SYSTEM_COM_ERR', 1)
172
173 def check_system_heimdal_lib(name, functions='', headers='', onlyif=None):
174     # Only use system library if the user requested the bundled one not be
175     # used.
176     if conf.LIB_MAY_BE_BUNDLED(name):
177         return False
178     setattr(conf.env, "CPPPATH_%s" % name.upper(), heimdal_includedirs)
179     setattr(conf.env, "LIBPATH_%s" % name.upper(), heimdal_libdirs)
180     conf.CHECK_BUNDLED_SYSTEM(name, checkfunctions=functions, headers=headers,
181         onlyif=onlyif)
182     conf.define('USING_SYSTEM_%s' % name.upper(), 1)
183     return True
184
185 def check_system_heimdal_binary(name):
186     if conf.LIB_MAY_BE_BUNDLED(name):
187         return False
188     if not conf.find_program(name, var=name.upper()):
189         return False
190     conf.define('USING_SYSTEM_%s' % name.upper(), 1)
191     return True
192
193 if check_system_heimdal_lib("roken", "rk_socket_set_reuseaddr", "roken.h"):
194     conf.env.CPPPATH_ROKEN_HOSTCC = conf.env.CPPPATH_ROKEN
195     conf.env.LIBPATH_ROKEN_HOSTCC = conf.env.LIBPATH_ROKEN
196     conf.env.LIB_ROKEN_HOSTCC = "roken"
197     conf.SET_TARGET_TYPE("ROKEN_HOSTCC", 'SYSLIB')
198 check_system_heimdal_lib("wind", "wind_stringprep", "wind.h", onlyif="roken")
199 check_system_heimdal_lib("hx509", "hx509_bitstring_print", "hx509.h", onlyif="roken wind")
200 check_system_heimdal_lib("asn1", "initialize_asn1_error_table", "asn1_err.h", onlyif="roken com_err")
201 check_system_heimdal_lib("heimbase", "heim_cmp", "heimbase.h", onlyif="roken")
202 check_system_heimdal_lib("hcrypto", "MD4_Init", "hcrypto/md4.h",
203     onlyif="asn1 roken com_err")
204 if check_system_heimdal_lib("krb5", "krb5_anyaddr", "krb5.h",
205     onlyif="roken wind asn1 hx509 hcrypto com_err heimbase"):
206     conf.CHECK_FUNCS_IN('krb5_free_unparsed_name', 'krb5', headers="krb5.h")
207 check_system_heimdal_lib("gssapi", "gss_oid_to_name", "gssapi.h",
208     onlyif="hcrypto asn1 roken krb5 com_err wind")
209 check_system_heimdal_lib("heimntlm", "heim_ntlm_ntlmv2_key", "heimntlm.h",
210     onlyif="roken hcrypto krb5")
211 check_system_heimdal_lib("hdb", "hdb_db_dir", "krb5.h hdb.h",
212     onlyif="roken krb5 hcrypto com_err wind")
213 check_system_heimdal_lib("kdc", "kdc_log", "kdc.h",
214     onlyif="roken krb5 hdb asn1 heimntlm hcrypto com_err wind heimbase")
215
216
217 # With the proper checks in place we should be able to build against the system libtommath.
218 # conf.CHECK_BUNDLED_SYSTEM('tommath', checkfunctions='mp_init', headers='tommath.h')
219 # conf.define('USING_SYSTEM_TOMMATH', 1)
220
221 check_system_heimdal_binary("compile_et")
222 check_system_heimdal_binary("asn1_compile")