mirror of
https://git.freebsd.org/ports.git
synced 2025-04-29 18:16:48 -04:00
This is an initial attempt to add Samba to the FreeBSD after major rewrite of the VFS code in the upstream. Most of the port development is now carried in: https://gitlab.com/samba-freebsd Due to the way how new Samba VFS code is written there is a constrain that Samba 4.14+ can run only on FreeBSD 13.1+, as it requires support of the `nodup` option for the `fdesc` file system, as well as it's presence in the system in general. https://gitlab.com/samba-freebsd/-/wikis/The-New-VFS I'd like to thank CyberSecure Pty Ltd. company for their supoort of the port development and Andrew Walker from iXsystems Inc. for the patches he created and made available for the Samba4 on TrueNAS. PR: 263874
292 lines
12 KiB
Diff
292 lines
12 KiB
Diff
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
|
|
|