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