summaryrefslogtreecommitdiff
path: root/net/samba416/files/0001-Compact-and-simplify-modules-build-and-config-genera.patch
blob: b4bc56519f7eff5e53887fff8513e88a28c5b067 (plain) (blame)
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
From 05e3cc236406680a55e19b204202b63cdaf48ea1 Mon Sep 17 00:00:00 2001
From: "Timur I. Bakeyev" <timur@FreeBSD.org>
Date: Mon, 1 Aug 2022 04:15:43 +0200
Subject: [PATCH 01/28] Compact and simplify modules build and config
 generation for Bind 9.x AD DLZ.

Signed-off-by: Timur I. Bakeyev <timur@FreeBSD.org>
---
 python/samba/provision/sambadns.py | 68 ++++++++++++------------------
 source4/dns_server/dlz_minimal.h   | 44 +++++++++----------
 source4/dns_server/wscript_build   | 62 +++------------------------
 source4/setup/named.conf.dlz       | 25 +----------
 source4/torture/dns/wscript_build  |  2 +-
 5 files changed, 55 insertions(+), 146 deletions(-)

diff --git a/python/samba/provision/sambadns.py b/python/samba/provision/sambadns.py
index 404b346a885..8e5a8ba5f25 100644
--- a/python/samba/provision/sambadns.py
+++ b/python/samba/provision/sambadns.py
@@ -21,6 +21,7 @@
 """DNS-related provisioning"""
 
 import os
+import re
 import uuid
 import shutil
 import time
@@ -1010,52 +1011,37 @@ def create_named_conf(paths, realm, dnsdomain, dns_backend, logger):
                                      stderr=subprocess.STDOUT,
                                      cwd='.').communicate()[0]
         bind_info = get_string(bind_info)
-        bind9_8 = '#'
-        bind9_9 = '#'
-        bind9_10 = '#'
-        bind9_11 = '#'
-        bind9_12 = '#'
-        bind9_14 = '#'
-        bind9_16 = '#'
-        bind9_18 = '#'
-        if bind_info.upper().find('BIND 9.8') != -1:
-            bind9_8 = ''
-        elif bind_info.upper().find('BIND 9.9') != -1:
-            bind9_9 = ''
-        elif bind_info.upper().find('BIND 9.10') != -1:
-            bind9_10 = ''
-        elif bind_info.upper().find('BIND 9.11') != -1:
-            bind9_11 = ''
-        elif bind_info.upper().find('BIND 9.12') != -1:
-            bind9_12 = ''
-        elif bind_info.upper().find('BIND 9.14') != -1:
-            bind9_14 = ''
-        elif bind_info.upper().find('BIND 9.16') != -1:
-            bind9_16 = ''
-        elif bind_info.upper().find('BIND 9.18') != -1:
-            bind9_18 = ''
-        elif bind_info.upper().find('BIND 9.7') != -1:
-            raise ProvisioningError("DLZ option incompatible with BIND 9.7.")
-        elif bind_info.upper().find('BIND_9.13') != -1:
-            raise ProvisioningError("Only stable/esv releases of BIND are supported.")
-        elif bind_info.upper().find('BIND_9.15') != -1:
-            raise ProvisioningError("Only stable/esv releases of BIND are supported.")
-        elif bind_info.upper().find('BIND_9.17') != -1:
-            raise ProvisioningError("Only stable/esv releases of BIND are supported.")
+        bind9_release = re.search('BIND (9)\.(\d+)\.', bind_info, re.I)
+        if bind9_release:
+            bind9_disabled = ''
+            bind9_version = bind9_release.group(0) + "x"
+            bind9_version_major = int(bind9_release.group(1))
+            bind9_version_minor = int(bind9_release.group(2))
+            if bind9_version_minor == 7:
+                raise ProvisioningError("DLZ option incompatible with BIND 9.7.")
+            elif bind9_version_minor == 8:
+                bind9_dlz_version = "9"
+            elif bind9_version_minor in [13, 15, 17]:
+                raise ProvisioningError("Only stable/esv releases of BIND are supported.")
+            else:
+                bind9_dlz_version = "%d_%d" % (bind9_version_major, bind9_version_minor)
         else:
+            bind9_disabled = '# '
+            bind9_version = "BIND z.y.x"
+            bind9_dlz_version = "z_y"
             logger.warning("BIND version unknown, please modify %s manually." % paths.namedconf)
+
+        bind9_dlz = (
+            '    # For %s\n'
+            '    %sdatabase "dlopen %s/bind9/dlz_bind%s.so";'
+        ) % (
+            bind9_version, bind9_disabled, samba.param.modules_dir(), bind9_dlz_version
+        )
         setup_file(setup_path("named.conf.dlz"), paths.namedconf, {
                     "NAMED_CONF": paths.namedconf,
                     "MODULESDIR": samba.param.modules_dir(),
-                    "BIND9_8": bind9_8,
-                    "BIND9_9": bind9_9,
-                    "BIND9_10": bind9_10,
-                    "BIND9_11": bind9_11,
-                    "BIND9_12": bind9_12,
-                    "BIND9_14": bind9_14,
-                    "BIND9_16": bind9_16,
-                    "BIND9_18": bind9_18
-                    })
+                    "BIND9_DLZ": bind9_dlz
+                 })
 
 
 def create_named_txt(path, realm, dnsdomain, dnsname, binddns_dir,
diff --git a/source4/dns_server/dlz_minimal.h b/source4/dns_server/dlz_minimal.h
index b7e36e7f8e6..bbdb616deb2 100644
--- a/source4/dns_server/dlz_minimal.h
+++ b/source4/dns_server/dlz_minimal.h
@@ -26,31 +26,25 @@
 #include <stdint.h>
 #include <stdbool.h>
 
-#if defined (BIND_VERSION_9_8)
-# error Bind 9.8 is not supported!
-#elif defined (BIND_VERSION_9_9)
-# error Bind 9.9 is not supported!
-#elif defined (BIND_VERSION_9_10)
-# define DLZ_DLOPEN_VERSION 3
-# define DNS_CLIENTINFO_VERSION 1
-# define ISC_BOOLEAN_AS_BOOL 0
-#elif defined (BIND_VERSION_9_11)
-# define DLZ_DLOPEN_VERSION 3
-# define DNS_CLIENTINFO_VERSION 2
-# define ISC_BOOLEAN_AS_BOOL 0
-#elif defined (BIND_VERSION_9_12)
-# define DLZ_DLOPEN_VERSION 3
-# define DNS_CLIENTINFO_VERSION 2
-# define ISC_BOOLEAN_AS_BOOL 0
-#elif defined (BIND_VERSION_9_14)
-# define DLZ_DLOPEN_VERSION 3
-# define DNS_CLIENTINFO_VERSION 2
-#elif defined (BIND_VERSION_9_16)
-# define DLZ_DLOPEN_VERSION 3
-# define DNS_CLIENTINFO_VERSION 2
-#elif defined (BIND_VERSION_9_18)
-# define DLZ_DLOPEN_VERSION 3
-# define DNS_CLIENTINFO_VERSION 2
+#if defined (BIND_VERSION)
+# if BIND_VERSION == 908
+#  error Bind 9.8 is not supported!
+# elif BIND_VERSION == 909
+#  error Bind 9.9 is not supported!
+# elif BIND_VERSION == 910
+#  define DLZ_DLOPEN_VERSION 3
+#  define DNS_CLIENTINFO_VERSION 1
+#  define ISC_BOOLEAN_AS_BOOL 0
+# elif BIND_VERSION == 911 || BIND_VERSION == 912
+#  define DLZ_DLOPEN_VERSION 3
+#  define DNS_CLIENTINFO_VERSION 2
+#  define ISC_BOOLEAN_AS_BOOL 0
+# elif BIND_VERSION >= 914
+#  define DLZ_DLOPEN_VERSION 3
+#  define DNS_CLIENTINFO_VERSION 2
+# else
+#  error Unsupported BIND version
+# endif
 #else
 # error Unsupported BIND version
 #endif
diff --git a/source4/dns_server/wscript_build b/source4/dns_server/wscript_build
index ab0a241b937..3743753504c 100644
--- a/source4/dns_server/wscript_build
+++ b/source4/dns_server/wscript_build
@@ -20,69 +20,21 @@ bld.SAMBA_MODULE('service_dns',
         )
 
 # a bind9 dlz module giving access to the Samba DNS SAM
-bld.SAMBA_LIBRARY('dlz_bind9_10',
+for bind_version in (910, 911, 912, 914, 916, 918):
+    string_version='%d_%d' % (bind_version // 100, bind_version % 100)
+    bld.SAMBA_LIBRARY('dlz_bind%s' % (string_version),
                   source='dlz_bind9.c',
-                  cflags='-DBIND_VERSION_9_10',
+                  cflags='-DBIND_VERSION=%d' % bind_version,
                   private_library=True,
-                  link_name='modules/bind9/dlz_bind9_10.so',
-                  realname='dlz_bind9_10.so',
-                  install_path='${MODULESDIR}/bind9',
-                  deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
-                  enabled=bld.AD_DC_BUILD_IS_ENABLED())
-
-bld.SAMBA_LIBRARY('dlz_bind9_11',
-                  source='dlz_bind9.c',
-                  cflags='-DBIND_VERSION_9_11',
-                  private_library=True,
-                  link_name='modules/bind9/dlz_bind9_11.so',
-                  realname='dlz_bind9_11.so',
-                  install_path='${MODULESDIR}/bind9',
-                  deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
-                  enabled=bld.AD_DC_BUILD_IS_ENABLED())
-
-bld.SAMBA_LIBRARY('dlz_bind9_12',
-                  source='dlz_bind9.c',
-                  cflags='-DBIND_VERSION_9_12',
-                  private_library=True,
-                  link_name='modules/bind9/dlz_bind9_12.so',
-                  realname='dlz_bind9_12.so',
-                  install_path='${MODULESDIR}/bind9',
-                  deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
-                  enabled=bld.AD_DC_BUILD_IS_ENABLED())
-
-bld.SAMBA_LIBRARY('dlz_bind9_14',
-                  source='dlz_bind9.c',
-                  cflags='-DBIND_VERSION_9_14',
-                  private_library=True,
-                  link_name='modules/bind9/dlz_bind9_14.so',
-                  realname='dlz_bind9_14.so',
-                  install_path='${MODULESDIR}/bind9',
-                  deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
-                  enabled=bld.AD_DC_BUILD_IS_ENABLED())
-
-bld.SAMBA_LIBRARY('dlz_bind9_16',
-                  source='dlz_bind9.c',
-                  cflags='-DBIND_VERSION_9_16',
-                  private_library=True,
-                  link_name='modules/bind9/dlz_bind9_16.so',
-                  realname='dlz_bind9_16.so',
-                  install_path='${MODULESDIR}/bind9',
-                  deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
-                  enabled=bld.AD_DC_BUILD_IS_ENABLED())
-
-bld.SAMBA_LIBRARY('dlz_bind9_18',
-                  source='dlz_bind9.c',
-                  cflags='-DBIND_VERSION_9_18',
-                  private_library=True,
-                  link_name='modules/bind9/dlz_bind9_18.so',
-                  realname='dlz_bind9_18.so',
+                  link_name='modules/bind9/dlz_bind%s.so' % (string_version),
+                  realname='dlz_bind%s.so' % (string_version),
                   install_path='${MODULESDIR}/bind9',
                   deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
                   enabled=bld.AD_DC_BUILD_IS_ENABLED())
 
 bld.SAMBA_LIBRARY('dlz_bind9_for_torture',
                   source='dlz_bind9.c',
-                  cflags='-DBIND_VERSION_9_16',
+                  cflags='-DBIND_VERSION=918',
                   private_library=True,
                   deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
                   enabled=bld.AD_DC_BUILD_IS_ENABLED())
diff --git a/source4/setup/named.conf.dlz b/source4/setup/named.conf.dlz
index cbe7d805f58..32672768af4 100644
--- a/source4/setup/named.conf.dlz
+++ b/source4/setup/named.conf.dlz
@@ -10,28 +10,5 @@
 # Uncomment only single database line, depending on your BIND version
 #
 dlz "AD DNS Zone" {
-    # For BIND 9.8.x
-    ${BIND9_8} database "dlopen ${MODULESDIR}/bind9/dlz_bind9.so";
-
-    # For BIND 9.9.x
-    ${BIND9_9} database "dlopen ${MODULESDIR}/bind9/dlz_bind9_9.so";
-
-    # For BIND 9.10.x
-    ${BIND9_10} database "dlopen ${MODULESDIR}/bind9/dlz_bind9_10.so";
-
-    # For BIND 9.11.x
-    ${BIND9_11} database "dlopen ${MODULESDIR}/bind9/dlz_bind9_11.so";
-
-    # For BIND 9.12.x
-    ${BIND9_12} database "dlopen ${MODULESDIR}/bind9/dlz_bind9_12.so";
-
-    # For BIND 9.14.x
-    ${BIND9_14} database "dlopen ${MODULESDIR}/bind9/dlz_bind9_14.so";
-
-    # For BIND 9.16.x
-    ${BIND9_16} database "dlopen ${MODULESDIR}/bind9/dlz_bind9_16.so";
-    #
-    # For BIND 9.18.x
-    ${BIND9_18} database "dlopen ${MODULESDIR}/bind9/dlz_bind9_18.so";
+${BIND9_DLZ}
 };
-
diff --git a/source4/torture/dns/wscript_build b/source4/torture/dns/wscript_build
index 0b40e03e370..bf7415ff88a 100644
--- a/source4/torture/dns/wscript_build
+++ b/source4/torture/dns/wscript_build
@@ -5,7 +5,7 @@ if bld.AD_DC_BUILD_IS_ENABLED():
 		source='dlz_bind9.c',
 		subsystem='smbtorture',
 		init_function='torture_bind_dns_init',
-		cflags='-DBIND_VERSION_9_16',
+		cflags='-DBIND_VERSION=918',
 		deps='torture talloc torturemain dlz_bind9_for_torture',
 		internal_module=True
 		)
-- 
2.37.1