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