blob: f88dee6175c5317e23ccb678426d4da6731ca83c [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001HOMEPAGE = "https://www.samba.org/"
2SECTION = "console/network"
3
4LICENSE = "GPL-3.0-or-later & LGPL-3.0-or-later & GPL-2.0-or-later"
5LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504 \
6 file://${COREBASE}/meta/files/common-licenses/LGPL-3.0-or-later;md5=c51d3eef3be114124d11349ca0d7e117 \
7 file://${COREBASE}/meta/files/common-licenses/GPL-2.0-or-later;md5=fed54355545ffd980b814dab4a3b312c"
8
9SAMBA_MIRROR = "http://samba.org/samba/ftp"
10MIRRORS += "\
11${SAMBA_MIRROR} http://mirror.internode.on.net/pub/samba \n \
12${SAMBA_MIRROR} http://www.mirrorservice.org/sites/ftp.samba.org \n \
13"
14
15SRC_URI = "${SAMBA_MIRROR}/stable/samba-${PV}.tar.gz \
16 file://smb.conf \
17 file://volatiles.03_samba \
18 file://0001-Don-t-check-xsltproc-manpages.patch \
19 file://0002-do-not-import-target-module-while-cross-compile.patch \
20 file://0003-Add-config-option-without-valgrind.patch \
21 file://0004-Add-options-to-configure-the-use-of-libbsd.patch \
22 file://0005-samba-build-dnsserver_common-code.patch \
23 file://0001-Fix-pyext_PATTERN-for-cross-compilation.patch \
24 file://0001-smbtorture-skip-test-case-tfork_cmd_send.patch \
25 file://0001-waf-Fix-errors-with-Werror-implicit-function-declara.patch \
26 "
27
28SRC_URI:append:libc-musl = " \
29 file://netdb_defines.patch \
30 file://samba-pam.patch \
31 file://samba-4.3.9-remove-getpwent_r.patch \
32 file://cmocka-uintptr_t.patch \
33 file://samba-fix-musl-lib-without-innetgr.patch \
34 "
35
36SRC_URI[sha256sum] = "abd5e9e6aa45e55114b188ba189ebdfc8fd3d7718d43f749e477ce7f791e5519"
37
38UPSTREAM_CHECK_REGEX = "samba\-(?P<pver>4\.14(\.\d+)+).tar.gz"
39
40inherit systemd waf-samba cpan-base perlnative update-rc.d perl-version pkgconfig
41
42# CVE-2011-2411 is valnerble only on HP NonStop Servers.
43CVE_CHECK_IGNORE += "CVE-2011-2411"
44
45# remove default added RDEPENDS on perl
46RDEPENDS:${PN}:remove = "perl"
47
48DEPENDS += "readline virtual/libiconv zlib popt libtalloc libtdb libtevent libldb libaio libpam libtasn1 jansson libparse-yapp-perl-native gnutls"
49
50inherit features_check
51REQUIRED_DISTRO_FEATURES = "pam"
52
53DEPENDS:append:libc-musl = " libtirpc"
54CFLAGS:append:libc-musl = " -I${STAGING_INCDIR}/tirpc"
55LDFLAGS:append:libc-musl = " -ltirpc"
56
57COMPATIBLE_HOST:riscv32 = "null"
58
59INITSCRIPT_NAME = "samba"
60INITSCRIPT_PARAMS = "start 20 3 5 . stop 20 0 1 6 ."
61
62SYSTEMD_PACKAGES = "${PN}-base ${PN}-ad-dc winbind"
63SYSTEMD_SERVICE:${PN}-base = "nmb.service smb.service"
64SYSTEMD_SERVICE:${PN}-ad-dc = "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'samba.service', '', d)}"
65SYSTEMD_SERVICE:winbind = "winbind.service"
66
67# There are prerequisite settings to enable ad-dc, so disable the service by default.
68# Reference:
69# https://wiki.samba.org/index.php/Setting_up_Samba_as_an_Active_Directory_Domain_Controller
70SYSTEMD_AUTO_ENABLE:${PN}-ad-dc = "disable"
71
72#cross_compile cannot use preforked process, since fork process earlier than point subproces.popen
73#to cross Popen
74export WAF_NO_PREFORK="yes"
75
76# Use krb5. Build active domain controller.
77#
78PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd zeroconf', d)} \
79 acl cups ad-dc ldap mitkrb5 \
80"
81
82RDEPENDS:${PN}-ctdb-tests += "bash util-linux-getopt"
83
84PACKAGECONFIG[acl] = "--with-acl-support,--without-acl-support,acl"
85PACKAGECONFIG[fam] = "--with-fam,--without-fam,gamin"
86PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,cups"
87PACKAGECONFIG[ldap] = "--with-ldap,--without-ldap,openldap"
88PACKAGECONFIG[sasl] = ",,cyrus-sasl"
89PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
90PACKAGECONFIG[dmapi] = "--with-dmapi,--without-dmapi,dmapi"
91PACKAGECONFIG[zeroconf] = "--enable-avahi,--disable-avahi,avahi"
92PACKAGECONFIG[valgrind] = ",--without-valgrind,valgrind,"
93PACKAGECONFIG[lttng] = "--with-lttng, --without-lttng,lttng-ust"
94PACKAGECONFIG[archive] = "--with-libarchive, --without-libarchive, libarchive"
95PACKAGECONFIG[libunwind] = ", , libunwind"
96PACKAGECONFIG[gpgme] = ",--without-gpgme,,"
97PACKAGECONFIG[lmdb] = ",--without-ldb-lmdb,lmdb,"
98PACKAGECONFIG[libbsd] = "--with-libbsd, --without-libbsd, libbsd"
99PACKAGECONFIG[ad-dc] = "--with-experimental-mit-ad-dc,--without-ad-dc,python3-markdown python3-dnspython,"
100PACKAGECONFIG[mitkrb5] = "--with-system-mitkrb5 --with-system-mitkdc=/usr/sbin/krb5kdc,,krb5,"
101
102SAMBA4_IDMAP_MODULES="idmap_ad,idmap_rid,idmap_adex,idmap_hash,idmap_tdb2"
103SAMBA4_PDB_MODULES="pdb_tdbsam,${@bb.utils.contains('PACKAGECONFIG', 'ldap', 'pdb_ldap,', '', d)}pdb_ads,pdb_smbpasswd,pdb_wbc_sam,pdb_samba4"
104SAMBA4_AUTH_MODULES="auth_unix,auth_wbc,auth_server,auth_netlogond,auth_script,auth_samba4"
105SAMBA4_MODULES="${SAMBA4_IDMAP_MODULES},${SAMBA4_PDB_MODULES},${SAMBA4_AUTH_MODULES}"
106
107# These libraries are supposed to replace others supplied by packages, but decorate the names of
108# .so files so there will not be a conflict. This is not done consistantly, so be very careful
109# when adding to this list.
110#
111SAMBA4_LIBS="heimdal,cmocka,NONE"
112
113EXTRA_OECONF += "--enable-fhs \
114 --with-piddir=/run \
115 --with-sockets-dir=/run/samba \
116 --with-modulesdir=${libdir}/samba \
117 --with-privatelibdir=${libdir}/samba \
118 --with-lockdir=${localstatedir}/lib/samba \
119 --with-cachedir=${localstatedir}/lib/samba \
120 --disable-rpath-install \
121 --disable-rpath \
122 --with-shared-modules=${SAMBA4_MODULES} \
123 --bundled-libraries=${SAMBA4_LIBS} \
124 ${@oe.utils.conditional('TARGET_ARCH', 'x86_64', '', '--disable-glusterfs', d)} \
125 --with-cluster-support \
126 --with-profiling-data \
127 --with-libiconv=${STAGING_DIR_HOST}${prefix} \
128 --with-pam --with-pammodulesdir=${base_libdir}/security \
129 "
130
131LDFLAGS += "-Wl,-z,relro,-z,now ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
132
133do_configure:append () {
134 cd ${S}/pidl/
135 perl Makefile.PL PREFIX=${prefix}
136 sed -e 's,VENDORPREFIX)/lib/perl,VENDORPREFIX)/${baselib}/perl,g' \
137 -e 's,PERLPREFIX)/lib/perl,PERLPREFIX)/${baselib}/perl,g' -i Makefile
138
139}
140
141do_compile:append () {
142 oe_runmake -C ${S}/pidl
143}
144
145do_install:append() {
146 for section in 1 5 7; do
147 install -d ${D}${mandir}/man$section
148 install -m 0644 ctdb/doc/*.$section ${D}${mandir}/man$section
149 done
150 for section in 1 5 7 8; do
151 install -d ${D}${mandir}/man$section
152 install -m 0644 docs/manpages/*.$section ${D}${mandir}/man$section
153 done
154
155 install -d ${D}${systemd_system_unitdir}
156 install -m 0644 ${S}/bin/default/packaging/systemd/*.service ${D}${systemd_system_unitdir}/
157 sed -e 's,\(ExecReload=\).*\(/kill\),\1${base_bindir}\2,' \
158 -e 's,/etc/sysconfig/samba,${sysconfdir}/default/samba,' \
159 -i ${D}${systemd_system_unitdir}/*.service
160
161 if [ "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'yes', 'no', d)}" = "no" ]; then
162 rm -f ${D}${systemd_system_unitdir}/samba.service
163 fi
164
165 install -d ${D}${sysconfdir}/tmpfiles.d
166 install -m644 packaging/systemd/samba.conf.tmp ${D}${sysconfdir}/tmpfiles.d/samba.conf
167 echo "d ${localstatedir}/log/samba 0755 root root -" \
168 >> ${D}${sysconfdir}/tmpfiles.d/samba.conf
169 install -d ${D}${sysconfdir}/init.d
170 install -m 0755 packaging/sysv/samba.init ${D}${sysconfdir}/init.d/samba
171 sed -e 's,/opt/samba/bin,${sbindir},g' \
172 -e 's,/opt/samba/smb.conf,${sysconfdir}/samba/smb.conf,g' \
173 -e 's,/opt/samba/log,${localstatedir}/log/samba,g' \
174 -e 's,/etc/init.d/samba.server,${sysconfdir}/init.d/samba,g' \
175 -e 's,/usr/bin,${base_bindir},g' \
176 -i ${D}${sysconfdir}/init.d/samba
177
178 install -d ${D}${sysconfdir}/samba
179 echo "127.0.0.1 localhost" > ${D}${sysconfdir}/samba/lmhosts
180 install -m644 ${WORKDIR}/smb.conf ${D}${sysconfdir}/samba/smb.conf
181 install -D -m 644 ${WORKDIR}/volatiles.03_samba ${D}${sysconfdir}/default/volatiles/03_samba
182
183 install -d ${D}${sysconfdir}/default
184 install -m644 packaging/systemd/samba.sysconfig ${D}${sysconfdir}/default/samba
185
186 # the items are from ctdb/tests/run_tests.sh
187 for d in cunit eventd eventscripts onnode shellcheck takeover takeover_helper tool; do
188 testdir=${D}${datadir}/ctdb-tests/UNIT/$d
189 install -d $testdir
190 cp ${S}/ctdb/tests/UNIT/$d/*.sh $testdir
191 cp -r ${S}/ctdb/tests/UNIT/$d/scripts ${S}/ctdb/tests/UNIT/$d/stubs $testdir || true
192 done
193
194 # fix file-rdeps qa warning
195 if [ -f ${D}${bindir}/onnode ]; then
196 sed -i 's:\(#!/bin/\)bash:\1sh:' ${D}${bindir}/onnode
197 fi
198
199 chmod 0750 ${D}${sysconfdir}/sudoers.d || true
200 rm -rf ${D}/run ${D}${localstatedir}/run ${D}${localstatedir}/log
201
202 for f in samba-gpupdate samba_upgradedns samba_spnupdate samba_kcc samba_dnsupdate samba_downgrade_db; do
203 if [ -f "${D}${sbindir}/$f" ]; then
204 sed -i -e 's,${PYTHON},/usr/bin/env python3,g' ${D}${sbindir}/$f
205 fi
206 done
207 if [ -f "${D}${bindir}/samba-tool" ]; then
208 sed -i -e 's,${PYTHON},/usr/bin/env python3,g' ${D}${bindir}/samba-tool
209 fi
210
211 oe_runmake -C ${S}/pidl DESTDIR=${D} install_vendor
212 find ${D}${libdir}/ -type f -name "perllocal.pod" | xargs rm -f
213 rm -rf ${D}${libdir}/perl5/vendor_perl/${PERLVERSION}/${BUILD_SYS}/auto/Parse/Pidl/.packlist
214 sed -i -e '1s,#!.*perl,#!${bindir}/env perl,' ${D}${bindir}/pidl
215}
216
217PACKAGES =+ "${PN}-python3 ${PN}-pidl \
218 ${PN}-dsdb-modules ${PN}-testsuite registry-tools \
219 winbind \
220 ${PN}-common ${PN}-base ${PN}-ad-dc ${PN}-ctdb-tests \
221 smbclient ${PN}-client ${PN}-server ${PN}-test"
222
223python samba_populate_packages() {
224 def module_hook(file, pkg, pattern, format, basename):
225 pn = d.getVar('PN')
226 d.appendVar('RRECOMMENDS:%s-base' % pn, ' %s' % pkg)
227
228 mlprefix = d.getVar('MLPREFIX') or ''
229 pam_libdir = d.expand('${base_libdir}/security')
230 pam_pkgname = mlprefix + 'pam-plugin%s'
231 do_split_packages(d, pam_libdir, r'^pam_(.*)\.so$', pam_pkgname, 'PAM plugin for %s', extra_depends='', prepend=True)
232
233 libdir = d.getVar('libdir')
234 do_split_packages(d, libdir, r'^lib(.*)\.so\..*$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True, allow_links=True)
235 pkglibdir = '%s/samba' % libdir
236 do_split_packages(d, pkglibdir, r'^lib(.*)\.so$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True)
237 moduledir = '%s/samba/auth' % libdir
238 do_split_packages(d, moduledir, r'^(.*)\.so$', 'samba-auth-%s', 'Samba %s authentication backend', hook=module_hook, extra_depends='', prepend=True)
239 moduledir = '%s/samba/pdb' % libdir
240 do_split_packages(d, moduledir, r'^(.*)\.so$', 'samba-pdb-%s', 'Samba %s password backend', hook=module_hook, extra_depends='', prepend=True)
241}
242
243PACKAGESPLITFUNCS:prepend = "samba_populate_packages "
244PACKAGES_DYNAMIC = "samba-auth-.* samba-pdb-.*"
245
246RDEPENDS:${PN} += "${PN}-base ${PN}-python3 ${PN}-dsdb-modules python3"
247RDEPENDS:${PN}-python3 += "pytalloc python3-tdb pyldb"
248
249FILES:${PN}-base = "${sbindir}/nmbd \
250 ${sbindir}/smbd \
251 ${sysconfdir}/init.d \
252 ${systemd_system_unitdir}/nmb.service \
253 ${systemd_system_unitdir}/smb.service"
254
255FILES:${PN}-ad-dc = "${sbindir}/samba \
256 ${systemd_system_unitdir}/samba.service \
257 ${libdir}/krb5/plugins/kdb/samba.so \
258"
259RDEPENDS:${PN}-ad-dc = "krb5-kdc"
260
261FILES:${PN}-ctdb-tests = "${bindir}/ctdb_run_tests \
262 ${bindir}/ctdb_run_cluster_tests \
263 ${sysconfdir}/ctdb/nodes \
264 ${datadir}/ctdb-tests \
265 ${datadir}/ctdb/tests \
266 ${localstatedir}/lib/ctdb \
267 "
268
269FILES:${BPN}-common = "${sysconfdir}/default \
270 ${sysconfdir}/samba \
271 ${sysconfdir}/tmpfiles.d \
272 ${localstatedir}/lib/samba \
273 ${localstatedir}/spool/samba \
274"
275
276FILES:${PN} += "${libdir}/vfs/*.so \
277 ${libdir}/charset/*.so \
278 ${libdir}/*.dat \
279 ${libdir}/auth/*.so \
280 ${datadir}/ctdb/events/* \
281"
282
283FILES:${PN}-dsdb-modules = "${libdir}/samba/ldb"
284
285FILES:${PN}-testsuite = "${bindir}/gentest \
286 ${bindir}/locktest \
287 ${bindir}/masktest \
288 ${bindir}/ndrdump \
289 ${bindir}/smbtorture"
290
291FILES:registry-tools = "${bindir}/regdiff \
292 ${bindir}/regpatch \
293 ${bindir}/regshell \
294 ${bindir}/regtree"
295
296FILES:winbind = "${sbindir}/winbindd \
297 ${bindir}/wbinfo \
298 ${bindir}/ntlm_auth \
299 ${libdir}/samba/idmap \
300 ${libdir}/samba/nss_info \
301 ${libdir}/winbind_krb5_locator.so \
302 ${libdir}/winbind-krb5-localauth.so \
303 ${sysconfdir}/init.d/winbind \
304 ${systemd_system_unitdir}/winbind.service"
305
306FILES:${PN}-python3 = "${PYTHON_SITEPACKAGES_DIR}"
307
308FILES:smbclient = "${bindir}/cifsdd \
309 ${bindir}/rpcclient \
310 ${bindir}/smbcacls \
311 ${bindir}/smbclient \
312 ${bindir}/smbcquotas \
313 ${bindir}/smbget \
314 ${bindir}/smbspool \
315 ${bindir}/smbtar \
316 ${bindir}/smbtree \
317 ${libdir}/samba/smbspool_krb5_wrapper"
318
319RDEPENDS:${PN}-pidl:append = " perl libparse-yapp-perl"
320FILES:${PN}-pidl = "${bindir}/pidl \
321 ${libdir}/perl5 \
322 "
323
324RDEPENDS:${PN}-client = "\
325 smbclient \
326 winbind \
327 registry-tools \
328 ${PN}-pidl \
329 "
330
331ALLOW_EMPTY:${PN}-client = "1"
332
333RDEPENDS:${PN}-server = "\
334 ${PN} \
335 winbind \
336 registry-tools \
337 "
338
339ALLOW_EMPTY:${PN}-server = "1"
340
341RDEPENDS:${PN}-test = "\
342 ${PN}-ctdb-tests \
343 ${PN}-testsuite \
344 "
345
346ALLOW_EMPTY:${PN}-test = "1"
347
348# Patch for CVE-2018-1050 is applied in version 4.5.15, 4.6.13, 4.7.5.
349# Patch for CVE-2018-1057 is applied in version 4.3.13, 4.4.16.
350CVE_CHECK_IGNORE += "CVE-2018-1050"
351CVE_CHECK_IGNORE += "CVE-2018-1057"