git: c4455146d799 - main - net/samba423: Repocopy from net/samba422

From: Mateusz Piotrowski <0mp_at_FreeBSD.org>
Date: Mon, 15 Dec 2025 13:46:10 UTC
The branch main has been updated by 0mp:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c4455146d79911440df41f51bdb980f68b5a698e

commit c4455146d79911440df41f51bdb980f68b5a698e
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2025-12-14 18:28:55 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2025-12-15 13:44:41 +0000

    net/samba423: Repocopy from net/samba422
    
    PR:     290327
---
 net/samba423/Makefile                              | 518 +++++++++++++++
 net/samba423/distinfo                              |   3 +
 ...-simplify-modules-build-and-config-genera.patch | 292 +++++++++
 ...gen.sh-script-to-run-under-FreeBSD-with-i.patch |  35 +
 ...CLang-prototype-warnings-in-kadm5-admin.h.patch |  32 +
 ...date-1-has-different-semantics-than-on-Li.patch |  38 ++
 ...alloc-jemalloc.h-if-ENABLE_JEMALLOC-is-se.patch |  26 +
 ...tall-nss_-modules-into-PAMMODULESDIR-path.patch |  32 +
 ...alue-as-a-default-backlog-size-for-the-li.patch | 105 +++
 ...-work-around-usage-of-Linux-specific-m-fl.patch | 111 ++++
 ...hat-config-checks-fail-if-the-warning-is-.patch |  39 ++
 ...with-pkgconfigdir-to-specify-alternative-.patch |  54 ++
 ...vided-by-port-location-of-the-XML-catalog.patch |  28 +
 ...ed-libraries-according-to-the-FreeBSD-spe.patch |  29 +
 ...to-disable-CTDB-tests-failing-on-FreeBSD-.patch |  77 +++
 ...-debug-class-to-trck-down-DB-locking-code.patch | 132 ++++
 ...hema_attribute_compare-a-stable-comparisi.patch |  29 +
 ...dom-when-available-to-generate-random-tal.patch |  49 ++
 ...ration-option-that-allows-to-choose-alter.patch |  65 ++
 ...a1afeb0b920e60e14846987ae1d2d7dca4-Mon-Se.patch | 544 ++++++++++++++++
 ...between-r336017-and-r342928-wrongfuly-ret.patch |  35 +
 ...g-warnings-in-the-nfs_quota-debug-message.patch |  36 ++
 ...MP-handling-code-and-add-FreeBSD-support..patch | 332 ++++++++++
 ..._quota-test-function-into-vfstest-to-test.patch | 121 ++++
 ...869a8f4018ebee302aae8246bf29f60309-Mon-Se.patch |  94 +++
 ...ompatibility-option-to-the-vfs_streams_xa.patch | 335 ++++++++++
 ...s3-lib-system-add-FreeBSD-proc_fd_pattern.patch | 121 ++++
 net/samba423/files/README.FreeBSD.in               |  91 +++
 .../patch-docs-xml_manpages_vfs__freebsd.8.xml     | 172 +++++
 net/samba423/files/patch-docs-xml_wscript__build   |  10 +
 .../files/patch-examples_pdb_wscript__build        |  11 +
 net/samba423/files/patch-lib_talloc_wscript        |  11 +
 net/samba423/files/patch-lib_util_util_crypt_c     |  15 +
 net/samba423/files/patch-python_samba_join.py      |  11 +
 .../patch-python_samba_provision_____init____.py   |  71 +++
 net/samba423/files/patch-source3_lib_sysacls.c     |  19 +
 net/samba423/files/patch-source3_lib_util.c        |  14 +
 .../files/patch-source3_librpc_crypto_gse.c        |  16 +
 .../files/patch-source3_modules_vfs__freebsd.c     | 702 +++++++++++++++++++++
 ...patch-source3_modules_vfs__virusfilter__utils.c |  36 ++
 .../files/patch-source3_modules_vfs__zfsacl.c      | 182 ++++++
 .../files/patch-source3_modules_wscript__build     |  16 +
 net/samba423/files/patch-source3_param_loadparm.c  |  32 +
 .../patch-source3_registry_tests_test__regfio.c    |  10 +
 net/samba423/files/patch-source3_smbd_pysmbd.c     | 230 +++++++
 .../files/patch-source3_winbindd_wscript__build    |  11 +
 net/samba423/files/pkg-message.in                  |  31 +
 net/samba423/files/samba_server.in                 | 253 ++++++++
 net/samba423/pkg-descr                             |   6 +
 net/samba423/pkg-plist                             | 480 ++++++++++++++
 net/samba423/pkg-plist.ad_dc                       | 181 ++++++
 net/samba423/pkg-plist.cluster                     |  83 +++
 net/samba423/pkg-plist.python                      | 597 ++++++++++++++++++
 53 files changed, 6603 insertions(+)

diff --git a/net/samba423/Makefile b/net/samba423/Makefile
new file mode 100644
index 000000000000..f6186ea648be
--- /dev/null
+++ b/net/samba423/Makefile
@@ -0,0 +1,518 @@
+PORTNAME=			samba422
+DISTVERSION=			4.22.6
+PORTREVISION=			6
+CATEGORIES?=			net
+MASTER_SITES=			SAMBA/samba/stable SAMBA/samba/rc
+DISTNAME=			samba-${DISTVERSION:S|.p|pre|:S|.r|rc|:S|.t|tp|:S|.a|alpha|}
+
+MAINTAINER=			samba@FreeBSD.org
+COMMENT=			Free SMB/CIFS and AD/DC server and client for Unix
+WWW=				https://gitlab.com/samba-freebsd/
+
+LICENSE=			GPLv3+
+LICENSE_FILE=			${WRKSRC}/COPYING
+
+# The SAMBA4_BUNDLED_* variables are deprecated.
+.for bvar in SAMBA4_BUNDLED_CMOCKA SAMBA4_BUNDLED_TALLOC SAMBA4_BUNDLED_TDB SAMBA4_BUNDLED_TEVENT
+.  if defined(${bvar}) && ${${bvar}} == yes
+IGNORE=				does not support bundling dependencies via ${bvar}; use option ${bvar:S/^SAMBA4_//} instead
+.  endif
+.endfor
+
+BUILD_DEPENDS=			${_JANSSON_DEPENDS} \
+				${_LIBARCHIVE_DEPENDS} \
+				${_TASN1_DEPENDS} \
+				p5-Parse-Yapp>=0:devel/p5-Parse-Yapp
+# Unconditional dependencies which can't be switched off if present:
+# - GnuTLS: libgnutls.so and libgcrypt.so
+# - Iconv
+# - inotify
+# - libsunacl: provides NFSv4 ACL glue.
+# - libicu
+# - unwind
+# - p5-Parse-Yapp: needed for the IDL compiler.
+# - popt
+# - Readline: required by Python; USES=readline pollutes CPPFLAGS, so we add
+#   devel/readline to LIB_DEPENDS explicitly instead.
+LIB_DEPENDS=			libgnutls.so:security/gnutls \
+				libgcrypt.so:security/libgcrypt \
+				libiconv.so:converters/libiconv \
+				libinotify.so:devel/libinotify \
+				libsunacl.so:sysutils/libsunacl \
+				libreadline.so:devel/readline \
+				libpopt.so:devel/popt \
+				libunwind.so:devel/libunwind \
+				libicui18n.so:devel/icu \
+				libicuuc.so:devel/icu \
+				${_VFS_SNAPPER_LIB_DEPENDS}
+RUN_DEPENDS=			${_JANSSON_DEPENDS} \
+				${_LIBARCHIVE_DEPENDS} \
+				${_TASN1_DEPENDS}
+TEST_DEPENDS=			bash:shells/bash \
+				tshark:net/wireshark@nox11
+
+USES=				cpe compiler:c++11-lang iconv \
+				localbase:ldflags ncurses perl5 pkgconfig \
+				shebangfix waf gettext-runtime samba:self
+CPE_VENDOR=			samba
+CPE_PRODUCT=			samba
+USE_LDCONFIG=			${SAMBA_LIBDIR}
+USE_PERL5=			build
+USE_RC_SUBR=			samba_server
+WAF_CMD=			buildtools/bin/waf
+# Make sure that the right version of Python is used by the tools
+# https://bugzilla.samba.org/show_bug.cgi?id=7305
+SHEBANG_FILES=			source3/script* source4/scripting/bin/* selftest/*
+
+CONFIGURE_LOG=			bin/config.log
+CONFIGURE_ARGS=			--mandir="${PREFIX}/share/man" \
+				--sysconfdir="${_CONFDIR}" \
+				--includedir="${SAMBA_INCLUDEDIR}" \
+				--datadir="${DATADIR}" \
+				--libdir="${SAMBA_LIBDIR}" \
+				--with-privatelibdir="${SAMBA_LIBDIR}/private" \
+				--with-pammodulesdir="${_PAMDIR}" \
+				--with-modulesdir="${SAMBA_MODULESDIR}" \
+				--with-ldbmodulesdir="${SAMBA_LDB_MODULESDIR}" \
+				--with-pkgconfigdir="${_PKGCONFIGDIR}" \
+				--localstatedir="${VARDIR}" \
+				--with-piddir="${_RUNDIR}" \
+				--with-sockets-dir="${_RUNDIR}" \
+				--with-privileged-socket-dir="${_RUNDIR}" \
+				--with-lockdir="${_LOCKDIR}" \
+				--with-statedir="${_LOCKDIR}" \
+				--with-cachedir="${_LOCKDIR}" \
+				--with-bind-dns-dir=${_BINDDNSDIR} \
+				--with-privatedir="${_PRIVATEDIR}" \
+				--with-logfilebase="${_LOGDIR}"
+CONFIGURE_ARGS+=		\
+				--with-pam \
+				--with-iconv \
+				--with-libiconv="${ICONV_PREFIX}" \
+				--with-winbind \
+				--with-regedit \
+				--disable-rpath \
+				--without-lttng \
+				--without-gettext \
+				--enable-pthreadpool \
+				--without-fake-kaserver \
+				--without-systemd \
+				--with-libarchive \
+				--with-acl-support \
+				--with-sendfile-support \
+				--disable-ctdb-tests \
+				--disable-spotlight
+CONFIGURE_ARGS+=		${_PRIVATE_LIBS:D--private-libraries="${_PRIVATE_LIBS:Q:C|(\\\\ )+|,|g:S|\\||g}"}
+CONFIGURE_ARGS+=		${_BUNDLED_LIBS:D--bundled-libraries="${_BUNDLED_LIBS:Q:C|(\\\\ )+|,|g:S|\\||g}"}
+CONFIGURE_ARGS+=		${_SHARED_MODULES:D--with-shared-modules="${_SHARED_MODULES:C|-|_|:Q:C|(\\\\ )+|,|g:S|\\||g}"}
+CONFIGURE_ARGS+=		${WITH_DEBUG:D --verbose --enable-debug}
+CONFIGURE_ENV=			PTHREAD_LDFLAGS="-lpthread" \
+				PYTHONHASHSEED=1
+
+MAKE_ARGS=			${WITH_DEBUG:D --verbose}
+MAKE_ENV=			PYTHONHASHSEED=1 \
+				RPCGEN_CPP="${CPP}"
+TEST_ENV=			PYTHON="${PYTHON_CMD}" \
+				SHA1SUM=/sbin/sha1 \
+				SHA256SUM=${SHA256} \
+				MD5SUM=${MD5} \
+				PYTHONDONTWRITEBYTECODE=1
+
+# No fancy color error messages
+CFLAGS+=			${_CFLAGS_${CHOSEN_COMPILER_TYPE}}
+.ifnmake portclippy
+_CFLAGS_clang=			-fno-color-diagnostics
+.endif
+CONFIGURE_ENV+=			NOCOLOR=yes WAF_LOG_FORMAT='%(c1)s%(zone)s%(c2)s %(message)s'
+MAKE_ENV+=			NOCOLOR=yes WAF_LOG_FORMAT='%(c1)s%(zone)s%(c2)s %(message)s'
+# for libexecinfo: (so that __builtin_frame_address() finds the top of the stack)
+CFLAGS_amd64+=			-fno-omit-frame-pointer
+DEBUG_FLAGS?=			-g -ggdb3 -O0
+# Some symbols in samba's linker version scripts are not defined, but since the
+# scripts are generated dynamically, suppress errors with lld >= 17 due to these
+# undefined symbols.
+LDFLAGS+=			-Wl,--undefined-version
+
+CONFLICTS_INSTALL=		ldb2[0-9]-* samba4*
+
+EXTRA_PATCHES=			\
+				${PATCHDIR}/0001-Compact-and-simplify-modules-build-and-config-genera.patch:-p1 \
+				${PATCHDIR}/0002-Adjust-abi_gen.sh-script-to-run-under-FreeBSD-with-i.patch:-p1 \
+				${PATCHDIR}/0003-Mask-CLang-prototype-warnings-in-kadm5-admin.h.patch:-p1 \
+				${PATCHDIR}/0004-On-FreeBSD-date-1-has-different-semantics-than-on-Li.patch:-p1 \
+				${PATCHDIR}/0005-Include-jemalloc-jemalloc.h-if-ENABLE_JEMALLOC-is-se.patch:-p1 \
+				${PATCHDIR}/0006-Install-nss_-modules-into-PAMMODULESDIR-path.patch:-p1 \
+				${PATCHDIR}/0007-Use-macro-value-as-a-default-backlog-size-for-the-li.patch:-p1 \
+				${PATCHDIR}/0008-Brute-force-work-around-usage-of-Linux-specific-m-fl.patch:-p1 \
+				${PATCHDIR}/0009-Make-sure-that-config-checks-fail-if-the-warning-is-.patch:-p1 \
+				${PATCHDIR}/0010-Add-option-with-pkgconfigdir-to-specify-alternative-.patch:-p1 \
+				${PATCHDIR}/0011-Use-provided-by-port-location-of-the-XML-catalog.patch:-p1 \
+				${PATCHDIR}/0012-Create-shared-libraries-according-to-the-FreeBSD-spe.patch:-p1 \
+				${PATCHDIR}/0014-Add-option-to-disable-CTDB-tests-failing-on-FreeBSD-.patch:-p1 \
+				${PATCHDIR}/0015-Add-extra-debug-class-to-trck-down-DB-locking-code.patch:-p1 \
+				${PATCHDIR}/0016-Make-ldb_schema_attribute_compare-a-stable-comparisi.patch:-p1 \
+				${PATCHDIR}/0017-Use-arc4random-when-available-to-generate-random-tal.patch:-p1 \
+				${PATCHDIR}/0018-Add-configuration-option-that-allows-to-choose-alter.patch:-p1 \
+				${PATCHDIR}/0019-From-923bc7a1afeb0b920e60e14846987ae1d2d7dca4-Mon-Se.patch:-p1 \
+				${PATCHDIR}/0020-FreeBSD-12-between-r336017-and-r342928-wrongfuly-ret.patch:-p1 \
+				${PATCHDIR}/0021-Fix-casting-warnings-in-the-nfs_quota-debug-message.patch:-p1 \
+				${PATCHDIR}/0022-Clean-up-UTMP-handling-code-and-add-FreeBSD-support..patch:-p1 \
+				${PATCHDIR}/0023-Add-cmd_get_quota-test-function-into-vfstest-to-test.patch:-p1 \
+				${PATCHDIR}/0025-From-d9b748869a8f4018ebee302aae8246bf29f60309-Mon-Se.patch:-p1 \
+				${PATCHDIR}/0028-s3-lib-system-add-FreeBSD-proc_fd_pattern.patch \
+
+SUB_FILES=			pkg-message README.FreeBSD
+SUB_LIST=			PKGCONFIGDIR=${_PKGCONFIGDIR_REL} \
+				${_SAMBA_SUB}
+
+# PLIST must be defined here explicitly as we append to PLIST later on to
+# handle extra pkg-plist files like pkg-plist.python.
+PLIST?=				${PKGDIR}/pkg-plist
+PLIST_DIRS=			${SAMBA_MODULESDIR} \
+				${_MODULE_CLASSES:S|^|${SAMBA_MODULESDIR}/|}
+# ":C|_|/|:C|-|_|" is a workaround for turning "nss-info_*" modules into "nss_info/*".
+PLIST_FILES+=			${_SHARED_MODULES:C|_|/|:C|-|_|:S|^|${SAMBA_MODULESDIR}/|:S|$|.so|}
+PLIST_SUB=			PKGCONFIGDIR=${_PKGCONFIGDIR_REL} \
+				${_SAMBA_SUB}
+PORTDOCS=			README.FreeBSD
+
+OPTIONS_DEFINE=			AD_DC ADS CLUSTER CUPS DOCS FAM LDAP GPGME \
+				MANPAGES PROFILE PYTHON3 QUOTAS \
+				SYSLOG UTMP
+OPTIONS_DEFAULT=		AD_DC ADS DOCS FAM LDAP MANPAGES \
+				PROFILE PYTHON3 QUOTAS SYSLOG UTMP \
+				FRUIT GSSAPI_BUILTIN AVAHI
+OPTIONS_GROUP=			BUNDLED_DEPS DEVELOPMENT VFS
+OPTIONS_GROUP_BUNDLED_DEPS=	BUNDLED_CMOCKA BUNDLED_TALLOC BUNDLED_TDB BUNDLED_TEVENT
+OPTIONS_GROUP_DEVELOPMENT=	DEVELOPER MEMORY_DEBUG PICKY_DEVELOPER TEST
+OPTIONS_GROUP_VFS=		FRUIT GLUSTERFS
+OPTIONS_SINGLE=			GSSAPI ZEROCONF
+OPTIONS_SINGLE_GSSAPI=		GSSAPI_BUILTIN GSSAPI_MIT
+OPTIONS_SINGLE_ZEROCONF=	ZEROCONF_NONE AVAHI MDNSRESPONDER
+OPTIONS_SUB=			yes
+
+ADS_DESC=			Active Directory client
+AD_DC_DESC=			Active Directory Domain Controller(implies PYTHON3)
+BUNDLED_CMOCKA_DESC=		Bundle cmocka instead of depending on a standalone port
+BUNDLED_DEPS_DESC=		Bundled dependencies
+BUNDLED_TALLOC_DESC=		Bundle talloc instead of depending on a standalone port
+BUNDLED_TDB_DESC=		Bundle TDB instead of depending on a standalone port
+BUNDLED_TEVENT_DESC=		Bundle Tevent instead of depending on a standalone port
+CLUSTER_DESC=			Clustering support
+DEVELOPER_DESC=			With developer framework
+DEVELOPMENT_DESC=		Testing, debugging, and development
+FAM_DESC=			File Alteration Monitor
+FRUIT_DESC=			MacOSX and TimeMachine support
+GLUSTERFS_DESC=			GlusterFS support
+GPGME_DESC=			GpgME support
+GSSAPI_BUILTIN_DESC=		GSSAPI support via bundled Heimdal
+LDAP_DESC=			LDAP client
+MEMORY_DEBUG_DESC=		Debug memory allocator
+PICKY_DEVELOPER_DESC=		Treat compiler warnings as errors(implies DEVELOPER)
+PROFILE_DESC=			Profiling data
+QUOTAS_DESC=			Disk quota support
+UTMP_DESC=			UTMP accounting
+VFS_DESC=			VFS modules
+ZEROCONF_DESC=			Zero configuration networking
+ZEROCONF_NONE_DESC=		Zeroconf support is absent
+
+ADS_IMPLIES=			LDAP
+ADS_CONFIGURE_WITH=		ads
+# List of extra modules taken from RHEL build
+# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197320
+ADS_VARS=			_SHARED_MODULES+="idmap_ad idmap_rfc2307 nss-info_template nss-info_rfc2307 nss-info_sfu nss-info_sfu20"
+
+AD_DC_IMPLIES=			ADS PYTHON3
+AD_DC_BUILD_DEPENDS=		${_LMDB_DEPDENDS}
+AD_DC_RUN_DEPENDS=		${_LMDB_DEPDENDS}
+AD_DC_CONFIGURE_OFF=		--without-ad-dc --without-ldb-lmdb
+AD_DC_VARS=			PLIST+=${PKGDIR}/pkg-plist.ad_dc
+# samba-tool requires those for *upgrade
+AD_DC_BUILD_DEPENDS+=		${PYTHON_PKGNAMEPREFIX}markdown>=3.3.7:textproc/py-markdown@${PY_FLAVOR} \
+				${PYTHON_PKGNAMEPREFIX}dnspython>=2.2.1:dns/py-dnspython@${PY_FLAVOR}
+AD_DC_RUN_DEPENDS+=		${PYTHON_PKGNAMEPREFIX}markdown>=3.3.7:textproc/py-markdown@${PY_FLAVOR} \
+				${PYTHON_PKGNAMEPREFIX}dnspython>=2.2.1:dns/py-dnspython@${PY_FLAVOR}
+
+AVAHI_LIB_DEPENDS=		libavahi-client.so:net/avahi-app
+AVAHI_CONFIGURE_ENABLE=		avahi
+AVAHI_VARS=			_SAMBA_SERVICES+=avahi_daemon
+
+BUNDLED_CMOCKA_BUILD_DEPENDS_OFF=	cmocka>=1.1.3:sysutils/cmocka
+BUNDLED_CMOCKA_TEST_DEPENDS_OFF=	cmocka>=1.1.3:sysutils/cmocka
+BUNDLED_CMOCKA_CONFLICTS_INSTALL=	cmocka-1.*
+BUNDLED_CMOCKA_VARS=			_BUNDLED_LIBS+=cmocka \
+					_BUNDLED_LIB_replace=replace
+BUNDLED_CMOCKA_VARS_OFF=		_BUNDLED_LIBS+=!cmocka
+
+BUNDLED_TALLOC_BUILD_DEPENDS_OFF=	talloc243>=2.4.3:devel/talloc243
+BUNDLED_TALLOC_RUN_DEPENDS_OFF=		talloc243>=2.4.3:devel/talloc243
+BUNDLED_TALLOC_CONFLICTS_INSTALL=	talloc-* talloc2*
+BUNDLED_TALLOC_VARS=			_BUNDLED_LIBS+=talloc \
+					_BUNDLED_LIB_replace=replace
+BUNDLED_TALLOC_VARS_OFF=		_BUNDLED_LIBS+=!talloc
+
+BUNDLED_TDB_BUILD_DEPENDS_OFF=		tdb1413>=1.4.13:databases/tdb1413
+BUNDLED_TDB_RUN_DEPENDS_OFF=		tdb1413>=1.4.13:databases/tdb1413
+BUNDLED_TDB_CONFLICTS_INSTALL=		tdb-* tdb1*
+BUNDLED_TDB_VARS=			_BUNDLED_LIBS+=tdb \
+					_BUNDLED_LIB_replace=replace
+BUNDLED_TDB_VARS_OFF=			_BUNDLED_LIBS+=!tdb
+
+BUNDLED_TEVENT_BUILD_DEPENDS_OFF=	tevent017>=0.17:devel/tevent017
+BUNDLED_TEVENT_RUN_DEPENDS_OFF=		tevent017>=0.17:devel/tevent017
+BUNDLED_TEVENT_CONFLICTS_INSTALL=	tevent-* tevent0*
+BUNDLED_TEVENT_VARS=			_BUNDLED_LIBS+=tevent \
+					_BUNDLED_LIB_replace=replace
+BUNDLED_TEVENT_VARS_OFF=		_BUNDLED_LIBS+=!tevent
+
+CLUSTER_LIB_DEPENDS=		libpcap.so:net/libpcap
+CLUSTER_CONFIGURE_WITH=		cluster-support
+CLUSTER_VARS=			PLIST+=${PKGDIR}/pkg-plist.cluster
+
+CUPS_LIB_DEPENDS=		libcups.so:print/cups
+CUPS_CONFIGURE_ENABLE=		cups iprint
+
+DEVELOPER_BUILD_DEPENDS=	${_LMDB_DEPDENDS} \
+				${_GDB_CMD}:devel/gdb
+DEVELOPER_RUN_DEPENDS=		${_LMDB_DEPDENDS}
+DEVELOPER_TEST_DEPENDS=		${_GDB_CMD}:devel/gdb
+DEVELOPER_CONFIGURE_ON=		--enable-developer --enable-selftest --abi-check-disable
+DEVELOPER_CONFIGURE_ENV=	WAF_CMD_FORMAT=string
+DEVELOPER_VARS=			_SHARED_MODULES+="auth_skel pdb_test gpext_security gpext_registry \
+				gpext_scripts perfcount_test vfs_fake_dfq \
+				vfs_skel_opaque vfs_skel_transparent \
+				vfs_shadow_copy_test vfs_fake_acls \
+				vfs_nfs4acl_xattr vfs_error_inject vfs_delay_inject"
+DEVELOPER_VARS_OFF=		_GDB_CMD=true
+
+# https://bugzilla.samba.org/show_bug.cgi?id=9545
+FAM_USES=			fam
+FAM_CONFIGURE_WITH=		fam
+
+FRUIT_PREVENTS=			ZEROCONF_NONE
+FRUIT_PREVENTS_MSG=		MacOSX support requires Zeroconf(AVAHI or MDNSRESPONDER)
+FRUIT_PLIST_FILES=		%%MANPAGES%%share/man/man8/vfs_fruit.8.gz
+FRUIT_VARS=			_SHARED_MODULES+=vfs_fruit
+
+GLUSTERFS_LIB_DEPENDS=		libglusterfs.so:net/glusterfs
+GLUSTERFS_CONFIGURE_ENABLE=	glusterfs
+GLUSTERFS_PLIST_FILES=		%%MANPAGES%%share/man/man8/vfs_glusterfs.8.gz
+GLUSTERFS_VARS=			_SHARED_MODULES+=vfs_glusterfs
+
+GPGME_LIB_DEPENDS=		libgpgme.so:security/gpgme
+GPGME_RUN_DEPENDS=		${PYTHON_PKGNAMEPREFIX}gpg>=2.0.0:security/py-gpg@${PY_FLAVOR}
+GPGME_CONFIGURE_WITH=		gpgme
+
+GSSAPI_BUILTIN_USES=		bison
+
+GSSAPI_MIT_USES=		bison gssapi:mit
+GSSAPI_MIT_CONFIGURE_ON=	--with-system-mitkrb5 ${GSSAPIBASEDIR} \
+				--with-system-mitkdc=${GSSAPIBASEDIR}/sbin/krb5kdc \
+				--with-experimental-mit-ad-dc
+GSSAPI_MIT_PLIST_FILES=		${SAMBA_MODULESDIR}/krb5/winbind_krb5_localauth.so \
+				%%MANPAGES%%share/man/man8/winbind_krb5_localauth.8.gz \
+				%%AD_DC%%${SAMBA_LIBDIR}/krb5/plugins/kdb/samba.so
+
+LDAP_USES=			ldap
+LDAP_CONFIGURE_WITH=		ldap
+LDAP_VARS=			_SHARED_MODULES+=idmap_ldap
+
+MANPAGES_BUILD_DEPENDS=		${LOCALBASE}/share/xsl/docbook/manpages/docbook.xsl:textproc/docbook-xsl \
+				xsltproc:textproc/libxslt
+MANPAGES_CONFIGURE_ENV_OFF=	XSLTPROC="false"
+
+MDNSRESPONDER_LIB_DEPENDS=	libdns_sd.so:net/mDNSResponder
+MDNSRESPONDER_CONFIGURE_ENABLE=	dnssd
+MDNSRESPONDER_VARS=		_SAMBA_SERVICES+=mdnsd
+
+MEMORY_DEBUG_IMPLIES=		DEBUG
+MEMORY_DEBUG_LIB_DEPENDS=	libjemalloc.so.2:devel/jemalloc
+MEMORY_DEBUG_CONFIGURE_ENV=	ADDITIONAL_CFLAGS="-DENABLE_JEMALLOC `pkg-config --cflags jemalloc`" ADDITIONAL_LDFLAGS="`pkg-config --libs jemalloc`"
+
+# https://bugzilla.samba.org/show_bug.cgi?id=8969
+PICKY_DEVELOPER_IMPLIES=	DEVELOPER
+PICKY_DEVELOPER_CONFIGURE_ON=	--picky-developer
+
+PROFILE_CONFIGURE_WITH=		profiling-data
+
+PYTHON3_USES=			python
+PYTHON3_USES_OFF=		python:build,test
+# Don't cache Python modules
+PYTHON3_CONFIGURE_ON=		--nopycache
+# Use PYTHON3_CONFIGURE_OFF instead of PYTHON3_CONFIGURE_ENABLE=python because
+# Samba's configure script does not recognize --enable-python.
+PYTHON3_CONFIGURE_OFF=		--disable-python
+PYTHON3_MAKE_ENV=		PYTHONDONTWRITEBYTECODE=1
+PYTHON3_VARS=			PLIST+=${PKGDIR}/pkg-plist.python \
+				_BUNDLED_LIBS+="pyldb pyldb-util"
+
+QUOTAS_CONFIGURE_WITH=		quotas
+
+SYSLOG_CONFIGURE_WITH=		syslog
+
+TEST_BUILD_DEPENDS=		${_ISO8601_DEPENDS}
+TEST_RUN_DEPENDS=		${_ISO8601_DEPENDS}
+
+UTMP_CONFIGURE_WITH=		utmp
+
+ZEROCONF_NONE_MAKE_ENV=		ZEROCONF=none
+
+.ifnmake portclippy
+.  if !defined(WANT_EXP_MODULES) || empty(WANT_EXP_MODULES)
+WANT_EXP_MODULES=		vfs_cacheprime
+.  endif
+.endif
+
+# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194046
+_GDB_CMD=			${LOCALBASE}/bin/gdb
+
+_ISO8601_DEPENDS=		${PYTHON_PKGNAMEPREFIX}iso8601>=0.1.11:devel/py-iso8601@${PY_FLAVOR}
+_JANSSON_DEPENDS=		jansson>=2.10:devel/jansson
+_LIBARCHIVE_DEPENDS=		libarchive>=3.1.2:archivers/libarchive
+_TASN1_DEPENDS=			libtasn1>=3.8:security/libtasn1
+.if ${WANT_EXP_MODULES:Mvfs_snapper}
+_VFS_SNAPPER_LIB_DEPENDS=	libdbus-1.so:devel/dbus \
+				libdbus-glib-1.so:devel/dbus-glib
+.endif
+
+_BUNDLED_LIBS=			!libarchive \
+				com_err \
+				${_BUNDLED_LIB_replace}
+
+_MODULE_CLASSES=		auth bind9 gensec gpext idmap ldb nss_info \
+				pdb perfcount process_model service vfs
+_PRIVATE_LIBS=			!ldb
+_SHARED_MODULES+=		${WANT_EXP_MODULES}
+_SHARED_MODULES+=		krb5_async_dns_krb5_locator krb5_winbind_krb5_locator idmap_nss idmap_autorid \
+				idmap_rid idmap_hash idmap_tdb idmap_tdb2 idmap_script \
+				nss-info_hash
+_SHARED_MODULES+=		vfs_freebsd
+_SHARED_MODULES+=		vfs_acl_tdb vfs_acl_xattr vfs_aio_fork vfs_aio_pthread \
+				vfs_audit vfs_cap vfs_catia vfs_commit vfs_crossrename \
+				vfs_default_quota vfs_dirsort vfs_expand_msdfs \
+				vfs_extd_audit vfs_fake_perms vfs_full_audit \
+				vfs_linux_xfs_sgid vfs_media_harmony vfs_offline \
+				vfs_preopen vfs_readahead vfs_readonly vfs_recycle \
+				vfs_shadow_copy vfs_shadow_copy2 vfs_shell_snap \
+				vfs_streams_depot vfs_streams_xattr vfs_syncops \
+				vfs_time_audit vfs_unityed_media vfs_virusfilter \
+				vfs_widelinks vfs_worm vfs_xattr_tdb vfs_zfsacl
+
+_SAMBA_MAJVERNAME=		samba4
+_SAMBA_SUB=			SAMBA4_LOGDIR="${_LOGDIR}" \
+				SAMBA4_RUNDIR="${_RUNDIR}" \
+				SAMBA4_LOCKDIR="${_LOCKDIR}" \
+				SAMBA4_LIBDIR="${SAMBA_LIBDIR}" \
+				SAMBA4_MODULEDIR="${SAMBA_MODULESDIR}" \
+				SAMBA_LDB_MODULESDIR="${SAMBA_LDB_MODULESDIR}" \
+				SAMBA4_BINDDNSDIR="${_BINDDNSDIR}" \
+				SAMBA4_PRIVATEDIR="${_PRIVATEDIR}" \
+				SAMBA4_CONFDIR="${_CONFDIR}" \
+				SAMBA4_CONFIG="${_SAMBA_CONFIG}" \
+				SAMBA4_SERVICES="${_SAMBA_SERVICES}"
+
+_SAMBA_CONFIG=			smb4.conf
+
+# XXX: Instead of defining _CONFDIR we could probably just set ETCDIR.
+_CONFDIR=			${PREFIX}/etc
+_BINDDNSDIR=			${_LOCKDIR}/bind-dns
+_LOCKDIR=			${_VARDIR}/db/${_SAMBA_MAJVERNAME}
+_LOGDIR=			${_VARDIR}/log/${_SAMBA_MAJVERNAME}
+_PAMDIR=			${PREFIX}/lib
+_PKGCONFIGDIR=			${PREFIX}/${_PKGCONFIGDIR_REL}
+_PKGCONFIGDIR_REL=		libdata/pkgconfig
+_PRIVATEDIR=			${_LOCKDIR}/private
+_RUNDIR=			${_VARDIR}/run/${_SAMBA_MAJVERNAME}
+_VARDIR=			${DESTDIR}/var
+
+.include <bsd.port.options.mk>
+
+.if ${PORT_OPTIONS:MPYTHON3}
+_BUNDLED_LIBS+=			${"${PORT_OPTIONS:MBUNDLED_TALLOC}" == "BUNDLED_TALLOC":?:!}pytalloc-util
+_BUNDLED_LIBS+=			${"${PORT_OPTIONS:MBUNDLED_TEVENT}" == "BUNDLED_TEVENT":?:!}pytevent
+_BUNDLED_LIBS+=			${"${PORT_OPTIONS:MBUNDLED_TDB}" == "BUNDLED_TDB":?:!}pytdb
+.endif
+
+# Only for 64-bit architectures
+.if ${ARCH} != armv6 && ${ARCH} != armv7 && ${ARCH} != i386 && ${ARCH} != mips && ${ARCH} != powerpc && ${ARCH} != powerpcspe
+.	if (${PORT_OPTIONS:MAD_DC} || ${PORT_OPTIONS:MDEVELOPER})
+# LMDB
+_LMDB_DEPDENDS=			lmdb>=0.9.16:databases/lmdb
+PLIST_FILES+=			${SAMBA_LIBDIR}/private/libldb-mdb-int-private-samba.so \
+				${SAMBA_LDB_MODULESDIR}/mdb.so
+.	endif
+.endif
+
+post-extract:
+	@${RM} -r ${WRKSRC}/pidl/lib/Parse/Yapp
+
+post-patch:
+	@${REINPLACE_CMD} -e 's|$${PKGCONFIGDIR}|${_PKGCONFIGDIR}|g' \
+		${PATCH_WRKSRC}/buildtools/wafsamba/pkgconfig.py
+	@${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \
+		${PATCH_WRKSRC}/buildtools/wafsamba/wafsamba.py
+	@${REINPLACE_CMD} -e 's|%%GDB_CMD%%|${_GDB_CMD}|g' \
+		${PATCH_WRKSRC}/buildtools/scripts/abi_gen.sh
+	@${REINPLACE_CMD} -e 's|%%SAMBA4_CONFIG%%|${_SAMBA_CONFIG}|g' \
+		${PATCH_WRKSRC}/dynconfig/wscript
+
+post-install:
+	${RM} -r ${STAGEDIR}${PYTHON_SITELIBDIR}/samba/third_party
+	${FIND} ${STAGEDIR}${PYTHON_SITELIBDIR} -name __pycache__ \
+		-type d -print0 | ${XARGS} -0 -n 1 -t ${RM} -r
+	${FIND} ${STAGEDIR} -type f -empty -delete
+
+.for dir in ${_LOGDIR} ${_RUNDIR} ${_LOCKDIR} ${SAMBA_MODULESDIR}
+	${INSTALL} -d -m 0755 "${STAGEDIR}${dir}"
+.endfor
+	${INSTALL} -d -m 0750 "${STAGEDIR}${_BINDDNSDIR}"
+	${INSTALL} -d -m 0750 "${STAGEDIR}${_PRIVATEDIR}"
+.for module_class in ${_MODULE_CLASSES}
+	${INSTALL} -d -m 0755 "${STAGEDIR}${SAMBA_MODULESDIR}/${module_class}"
+.endfor
+.if !defined(WITH_DEBUG)
+	-${FIND} ${STAGEDIR}${PREFIX}/bin ${STAGEDIR}${PREFIX}/sbin ${STAGEDIR}${PREFIX}/libexec \
+		-type f -print0 | ${XARGS} -0 -n 1 -t ${STRIP_CMD}
+	-${FIND} ${STAGEDIR}${PREFIX}/lib -name '*.so*' \
+		-type f -print0 | ${XARGS} -0 -n 1 -t ${STRIP_CMD}
+.endif
+
+post-install-BUNDLED_TALLOC-on:
+.if ${PORT_OPTIONS:MMANPAGES}
+.  for f in talloc.3
+	${MV} ${STAGEDIR}${PREFIX}/share/man/man3/${f} ${STAGEDIR}${PREFIX}/share/man/man3/samba-${f}
+.  endfor
+.endif
+
+post-install-BUNDLED_TDB-on:
+.if ${PORT_OPTIONS:MMANPAGES}
+.  for f in tdbbackup.8 tdbdump.8 tdbrestore.8 tdbtool.8
+	${MV} ${STAGEDIR}${PREFIX}/share/man/man8/${f} ${STAGEDIR}${PREFIX}/share/man/man8/samba-${f}
+.  endfor
+.endif
+
+post-install-CLUSTER-on:
+	${RLN} ${STAGEDIR}${PREFIX}/share/ctdb/events/legacy/00.ctdb.script ${STAGEDIR}${PREFIX}/etc/ctdb/events/legacy/00.ctdb.script
+	${RLN} ${STAGEDIR}${PREFIX}/share/ctdb/events/legacy/01.reclock.script ${STAGEDIR}${PREFIX}/etc/ctdb/events/legacy/01.reclock.script
+	${RLN} ${STAGEDIR}${PREFIX}/share/ctdb/events/legacy/05.system.script ${STAGEDIR}${PREFIX}/etc/ctdb/events/legacy/05.system.script
+	${RLN} ${STAGEDIR}${PREFIX}/share/ctdb/events/legacy/10.interface.script ${STAGEDIR}${PREFIX}/etc/ctdb/events/legacy/10.interface.script
+	${RLN} ${STAGEDIR}${PREFIX}/share/ctdb/events/legacy/95.database.script ${STAGEDIR}${PREFIX}/etc/ctdb/events/legacy/95.database.script
+
+post-install-DOCS-on:
+	${MKDIR} ${STAGEDIR}${DOCSDIR}
+.for doc in ${PORTDOCS}
+	${INSTALL_DATA} ${WRKDIR}/${doc} ${STAGEDIR}${DOCSDIR}
+.endfor
+
+post-install-FRUIT-off:
+	${RM} ${STAGEDIR}${SAMBA_MODULESDIR}/vfs/fruit.so
+	${RM} ${STAGEDIR}${PREFIX}/share/man/man8/vfs_fruit.8
+
+post-install-MANPAGES-on:
+	${RLN} ${STAGEDIR}${PREFIX}/share/man/man5/smb.conf.5 ${STAGEDIR}${PREFIX}/share/man/man5/smb4.conf.5
+
+.for f in vfs_aio_linux.8 vfs_btrfs.8 vfs_ceph.8 vfs_gpfs.8
+	${RM} ${STAGEDIR}${PREFIX}/share/man/man8/${f}
+.endfor
+
+.include <bsd.port.mk>
diff --git a/net/samba423/distinfo b/net/samba423/distinfo
new file mode 100644
index 000000000000..149352634642
--- /dev/null
+++ b/net/samba423/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1764863570
+SHA256 (samba-4.22.6.tar.gz) = 8e6beb0cce87fb3c763af94c2dc21fd47b8fd02d46b3cb1deb2a72df9259c425
+SIZE (samba-4.22.6.tar.gz) = 42883971
diff --git a/net/samba423/files/0001-Compact-and-simplify-modules-build-and-config-genera.patch b/net/samba423/files/0001-Compact-and-simplify-modules-build-and-config-genera.patch
new file mode 100644
index 000000000000..d34395bf6f22
--- /dev/null
+++ b/net/samba423/files/0001-Compact-and-simplify-modules-build-and-config-genera.patch
@@ -0,0 +1,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, 920):
++    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=920',
+                   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=920',
+ 		deps='torture talloc torturemain dlz_bind9_for_torture',
+ 		internal_module=True
+ 		)
+-- 
+2.37.1
+
diff --git a/net/samba423/files/0002-Adjust-abi_gen.sh-script-to-run-under-FreeBSD-with-i.patch b/net/samba423/files/0002-Adjust-abi_gen.sh-script-to-run-under-FreeBSD-with-i.patch
new file mode 100644
index 000000000000..fec7b9d07172
--- /dev/null
+++ b/net/samba423/files/0002-Adjust-abi_gen.sh-script-to-run-under-FreeBSD-with-i.patch
@@ -0,0 +1,35 @@
+From 639b8d650685476016a6d5b1c996a04ac54f8a6f Mon Sep 17 00:00:00 2001
+From: "Timur I. Bakeyev" <timur@FreeBSD.org>
+Date: Sun, 30 May 2021 04:00:08 +0200
+Subject: [PATCH 02/28] Adjust abi_gen.sh script to run under FreeBSD with it's
+ own bintools and slightly different output of GDB.
+
+Substitution: yes
+
+Signed-off-by: Timur I. Bakeyev <timur@FreeBSD.org>
+---
+ buildtools/scripts/abi_gen.sh | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/buildtools/scripts/abi_gen.sh b/buildtools/scripts/abi_gen.sh
+index ddb0a7cc36f..d2750705ff9 100755
+--- a/buildtools/scripts/abi_gen.sh
++++ b/buildtools/scripts/abi_gen.sh
+@@ -9,6 +9,7 @@ GDBSCRIPT="gdb_syms.$$"
+ cat <<EOF
+ set height 0
+ set width 0
++set print sevenbit-strings on
+ EOF
+ 
+ # On older linker versions _init|_fini symbols are not hidden.
+@@ -22,5 +23,5 @@ done
+ ) > $GDBSCRIPT
+ 
+ # forcing the terminal avoids a problem on Fedora12
+-TERM=none gdb -n -batch -x $GDBSCRIPT "$SHAREDLIB" < /dev/null
++TERM=none %%GDB_CMD%% -n -batch -x $GDBSCRIPT "$SHAREDLIB" < /dev/null
+ rm -f $GDBSCRIPT
+-- 
+2.37.1
+
diff --git a/net/samba423/files/0003-Mask-CLang-prototype-warnings-in-kadm5-admin.h.patch b/net/samba423/files/0003-Mask-CLang-prototype-warnings-in-kadm5-admin.h.patch
new file mode 100644
index 000000000000..8540609886da
--- /dev/null
+++ b/net/samba423/files/0003-Mask-CLang-prototype-warnings-in-kadm5-admin.h.patch
@@ -0,0 +1,32 @@
+From 382c3edc95a1747e0a6edd05c76adc0ec21a66c7 Mon Sep 17 00:00:00 2001
+From: "Timur I. Bakeyev" <timur@FreeBSD.org>
+Date: Sun, 30 May 2021 03:50:17 +0200
+Subject: [PATCH 03/28] Mask CLang prototype warnings in kadm5/admin.h
+
+Signed-off-by: Timur I. Bakeyev <timur@FreeBSD.org>
+---
+ source4/kdc/kdc-service-mit.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/source4/kdc/kdc-service-mit.c b/source4/kdc/kdc-service-mit.c
+index 22663b6ecc8..5bef125206a 100644
+--- a/source4/kdc/kdc-service-mit.c
++++ b/source4/kdc/kdc-service-mit.c
+@@ -36,9 +36,13 @@
+ #include "kdc/samba_kdc.h"
+ #include "kdc/kdc-server.h"
+ #include "kdc/kpasswd-service.h"
+-#include <kadm5/admin.h>
+ #include <kdb.h>
+ 
++#pragma clang diagnostic push
++#pragma clang diagnostic ignored "-Wstrict-prototypes"
++#include <kadm5/admin.h>
++#pragma clang diagnostic pop
++
+ #include "source4/kdc/mit_kdc_irpc.h"
+ 
+ /* PROTOTYPES */
+-- 
+2.37.1
+
diff --git a/net/samba423/files/0004-On-FreeBSD-date-1-has-different-semantics-than-on-Li.patch b/net/samba423/files/0004-On-FreeBSD-date-1-has-different-semantics-than-on-Li.patch
new file mode 100644
index 000000000000..4df0249fced2
--- /dev/null
+++ b/net/samba423/files/0004-On-FreeBSD-date-1-has-different-semantics-than-on-Li.patch
@@ -0,0 +1,38 @@
+From 0eb28116ceefee7bdafabac18a1763f13cb71883 Mon Sep 17 00:00:00 2001
+From: "Timur I. Bakeyev" <timur@FreeBSD.org>
*** 6003 LINES SKIPPED ***