1 | #!/usr/bin/env python
|
---|
2 |
|
---|
3 | import Options
|
---|
4 | from optparse import SUPPRESS_HELP
|
---|
5 |
|
---|
6 | def set_options(opt):
|
---|
7 | # allow users to disable gnutls
|
---|
8 | opt.add_option('--enable-gnutls',
|
---|
9 | help=("Enable use of gnutls"),
|
---|
10 | action="store_true", dest='enable_gnutls', default=True)
|
---|
11 | opt.add_option('--disable-gnutls', help=SUPPRESS_HELP, action="store_false", dest='enable_gnutls')
|
---|
12 |
|
---|
13 |
|
---|
14 | def configure(conf):
|
---|
15 | conf.env.enable_gnutls = Options.options.enable_gnutls
|
---|
16 | if not conf.env.enable_gnutls:
|
---|
17 | conf.SET_TARGET_TYPE('gnutls', 'DISABLED')
|
---|
18 | conf.SET_TARGET_TYPE('gcrypt', 'DISABLED')
|
---|
19 | conf.SET_TARGET_TYPE('gpg-error', 'DISABLED')
|
---|
20 | if 'AD_DC_BUILD_IS_ENABLED' in conf.env:
|
---|
21 | conf.fatal("--disable-gnutls given: Building the AD DC requires GnuTLS (eg libgnutls-dev, gnutls-devel) for ldaps:// support and for the BackupKey protocol")
|
---|
22 | return
|
---|
23 |
|
---|
24 | if Options.options.with_system_mitkrb5 and conf.env.AD_DC_BUILD_IS_ENABLED:
|
---|
25 | conf.CHECK_CFG(package='gnutls',
|
---|
26 | args='"gnutls >= 3.4.7" --cflags --libs',
|
---|
27 | msg='Checking for gnutls >= 3.4.7',
|
---|
28 | mandatory=True)
|
---|
29 | conf.DEFINE('HAVE_GNUTLS_3_4_7', 1)
|
---|
30 | conf.DEFINE('HAVE_GNUTLS3', 1)
|
---|
31 | else:
|
---|
32 | if conf.CHECK_CFG(package='gnutls',
|
---|
33 | args='"gnutls >= 3.4.7" --cflags --libs',
|
---|
34 | msg='Checking for gnutls >= 3.4.7',
|
---|
35 | mandatory=False):
|
---|
36 | conf.DEFINE('HAVE_GNUTLS_3_4_7', 1)
|
---|
37 | conf.DEFINE('HAVE_GNUTLS3', 1)
|
---|
38 | elif conf.CHECK_CFG(package='gnutls',
|
---|
39 | args='"gnutls >= 3.0.0" --cflags --libs',
|
---|
40 | msg='Checking for gnutls >= 3.0.0s', mandatory=False):
|
---|
41 | conf.DEFINE('HAVE_GNUTLS3', 1)
|
---|
42 | else:
|
---|
43 | conf.CHECK_CFG(package='gnutls',
|
---|
44 | args='"gnutls >= 1.4.0 gnutls != 2.2.4 gnutls != 2.8.0 gnutls != 2.8.1" --cflags --libs',
|
---|
45 | msg='Checking for gnutls >= 1.4.0 and broken versions', mandatory=False)
|
---|
46 |
|
---|
47 | if 'HAVE_GNUTLS' in conf.env:
|
---|
48 | conf.DEFINE('ENABLE_GNUTLS', 1)
|
---|
49 | else:
|
---|
50 | if 'AD_DC_BUILD_IS_ENABLED' in conf.env:
|
---|
51 | conf.fatal("Building the AD DC requires GnuTLS (eg libgnutls-dev, gnutls-devel) for ldaps:// support and for the BackupKey protocol")
|
---|
52 |
|
---|
53 | conf.CHECK_FUNCS_IN('gnutls_global_init', 'gnutls',
|
---|
54 | headers='gnutls/gnutls.h')
|
---|
55 |
|
---|
56 | conf.CHECK_FUNCS_IN('gnutls_certificate_verify_peers3', 'gnutls',
|
---|
57 | headers='gnutls/gnutls.h')
|
---|
58 | conf.CHECK_DECLS('GNUTLS_CERT_EXPIRED GNUTLS_CERT_NOT_ACTIVATED GNUTLS_CERT_UNEXPECTED_OWNER',
|
---|
59 | headers='gnutls/gnutls.h gnutls/x509.h')
|
---|
60 |
|
---|
61 | conf.CHECK_VARIABLE('gnutls_x509_crt_set_version',
|
---|
62 | headers='gnutls/gnutls.h gnutls/x509.h',
|
---|
63 | define='HAVE_GNUTLS_X509_CRT_SET_VERSION',
|
---|
64 | lib='gnutls')
|
---|
65 | conf.CHECK_VARIABLE('gnutls_x509_crt_set_subject_key_id',
|
---|
66 | headers='gnutls/gnutls.h gnutls/x509.h',
|
---|
67 | define='HAVE_GNUTLS_X509_CRT_SET_SUBJECT_KEY_ID',
|
---|
68 | lib='gnutls')
|
---|
69 |
|
---|
70 | # check for gnutls_datum types
|
---|
71 | conf.CHECK_TYPES('gnutls_datum gnutls_datum_t',
|
---|
72 | headers='gnutls/gnutls.h', lib='gnutls')
|
---|
73 |
|
---|
74 | # GnuTLS3 moved to libnettle, so only do this in the < 3.0 case
|
---|
75 | if not 'HAVE_GNUTLS3' in conf.env:
|
---|
76 | conf.CHECK_FUNCS_IN('gcry_control', 'gcrypt', headers='gcrypt.h')
|
---|
77 | conf.CHECK_FUNCS_IN('gpg_err_code_from_errno', 'gpg-error')
|
---|
78 | else:
|
---|
79 | conf.SET_TARGET_TYPE('gcrypt', 'DISABLED')
|
---|
80 | conf.SET_TARGET_TYPE('gpg-error', 'DISABLED')
|
---|
81 |
|
---|
82 |
|
---|
83 | def build(bld):
|
---|
84 | bld.SAMBA_SUBSYSTEM('LIBTLS',
|
---|
85 | source='tls.c tlscert.c tls_tstream.c',
|
---|
86 | public_deps='talloc gnutls gcrypt samba-hostconfig samba_socket LIBTSOCKET tevent tevent-util'
|
---|
87 | )
|
---|