blob: 1548ffadc3b30911def8df9eb9cabfd9ed1a64da [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 \
Patrick Williams864cc432023-02-09 14:54:44 -060026 file://0007-Deleted-settiong-of-python-to-fix-the-install-confli.patch \
Andrew Geissler517393d2023-01-13 08:55:19 -060027 "
28
29SRC_URI:append:libc-musl = " \
30 file://samba-pam.patch \
31 file://samba-4.3.9-remove-getpwent_r.patch \
32 file://cmocka-uintptr_t.patch \
33 "
34
Patrick Williams864cc432023-02-09 14:54:44 -060035SRC_URI[sha256sum] = "ebb7880d474ffc09d73b5fc77bcbd657f6235910337331a9c24d7f69ca11442b"
Andrew Geissler517393d2023-01-13 08:55:19 -060036
37UPSTREAM_CHECK_REGEX = "samba\-(?P<pver>4\.17(\.\d+)+).tar.gz"
38
39inherit systemd waf-samba cpan-base perlnative update-rc.d perl-version pkgconfig
40
41# CVE-2011-2411 is valnerble only on HP NonStop Servers.
42CVE_CHECK_IGNORE += "CVE-2011-2411"
43# Patch for CVE-2018-1050 is applied in version 4.5.15, 4.6.13, 4.7.5.
44CVE_CHECK_IGNORE += "CVE-2018-1050"
45# Patch for CVE-2018-1057 is applied in version 4.3.13, 4.4.16.
46CVE_CHECK_IGNORE += "CVE-2018-1057"
47
48# remove default added RDEPENDS on perl
49RDEPENDS:${PN}:remove = "perl"
50
51DEPENDS += "readline virtual/libiconv zlib popt libtalloc libtdb libtevent libldb libaio libpam libtasn1 jansson libparse-yapp-perl-native gnutls"
52
53inherit features_check
54REQUIRED_DISTRO_FEATURES = "pam"
55
56DEPENDS:append:libc-musl = " libtirpc"
57CFLAGS:append:libc-musl = " -I${STAGING_INCDIR}/tirpc"
58LDFLAGS:append:libc-musl = " -ltirpc"
59
60COMPATIBLE_HOST:riscv32 = "null"
61
62INITSCRIPT_NAME = "samba"
63INITSCRIPT_PARAMS = "start 20 3 5 . stop 20 0 1 6 ."
64
65SYSTEMD_PACKAGES = "${PN}-base ${PN}-ad-dc winbind ctdb"
66SYSTEMD_SERVICE:${PN}-base = "nmb.service smb.service"
67SYSTEMD_SERVICE:${PN}-ad-dc = "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'samba.service', '', d)}"
68SYSTEMD_SERVICE:winbind = "winbind.service"
69SYSTEMD_SERVICE:ctdb = "ctdb.service"
70
71# There are prerequisite settings to enable ad-dc, so disable the service by default.
72# Reference:
73# https://wiki.samba.org/index.php/Setting_up_Samba_as_an_Active_Directory_Domain_Controller
74SYSTEMD_AUTO_ENABLE:${PN}-ad-dc = "disable"
75
76#cross_compile cannot use preforked process, since fork process earlier than point subproces.popen
77#to cross Popen
78export WAF_NO_PREFORK="yes"
79
80# Use krb5. Build active domain controller.
81#
82PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd zeroconf', d)} \
83 acl cups ad-dc ldap mitkrb5 \
84"
85
86PACKAGECONFIG[acl] = "--with-acl-support,--without-acl-support,acl"
87PACKAGECONFIG[fam] = "--with-fam,--without-fam,gamin"
88PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,cups"
89PACKAGECONFIG[ldap] = "--with-ldap,--without-ldap,openldap"
90PACKAGECONFIG[sasl] = ",,cyrus-sasl"
91PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
92PACKAGECONFIG[dmapi] = "--with-dmapi,--without-dmapi,dmapi"
93PACKAGECONFIG[zeroconf] = "--enable-avahi,--disable-avahi,avahi"
94PACKAGECONFIG[valgrind] = ",--without-valgrind,valgrind,"
95PACKAGECONFIG[lttng] = "--with-lttng,--without-lttng,lttng-ust"
96PACKAGECONFIG[archive] = "--with-libarchive,--without-libarchive,libarchive"
97PACKAGECONFIG[libunwind] = "--with-libunwind,--without-libunwind,libunwind"
98PACKAGECONFIG[gpgme] = "--with-gpgme,--without-gpgme,gpgme"
99PACKAGECONFIG[lmdb] = ",--without-ldb-lmdb,lmdb"
100PACKAGECONFIG[libbsd] = "--with-libbsd,--without-libbsd,libbsd"
101PACKAGECONFIG[ad-dc] = "--with-experimental-mit-ad-dc,--without-ad-dc,python3-markdown python3-dnspython,"
102PACKAGECONFIG[mitkrb5] = "--with-system-mitkrb5 --with-system-mitkdc=/usr/sbin/krb5kdc,,krb5,"
103
104SAMBA4_IDMAP_MODULES="idmap_ad,idmap_rid,idmap_adex,idmap_hash,idmap_tdb2"
105SAMBA4_PDB_MODULES="pdb_tdbsam,${@bb.utils.contains('PACKAGECONFIG', 'ldap', 'pdb_ldap,', '', d)}pdb_ads,pdb_smbpasswd,pdb_wbc_sam,pdb_samba4"
106SAMBA4_AUTH_MODULES="auth_unix,auth_wbc,auth_server,auth_netlogond,auth_script,auth_samba4"
107SAMBA4_MODULES="${SAMBA4_IDMAP_MODULES},${SAMBA4_PDB_MODULES},${SAMBA4_AUTH_MODULES}"
108
109# These libraries are supposed to replace others supplied by packages, but decorate the names of
110# .so files so there will not be a conflict. This is not done consistantly, so be very careful
111# when adding to this list.
112#
113SAMBA4_LIBS="heimdal,cmocka,NONE"
114
115EXTRA_OECONF += "--enable-fhs \
116 --with-piddir=/run \
117 --with-sockets-dir=/run/samba \
118 --with-modulesdir=${libdir}/samba \
119 --with-privatelibdir=${libdir}/samba \
120 --with-lockdir=${localstatedir}/lib/samba \
121 --with-cachedir=${localstatedir}/lib/samba \
122 --disable-rpath-install \
123 --disable-rpath \
124 --with-shared-modules=${SAMBA4_MODULES} \
125 --bundled-libraries=${SAMBA4_LIBS} \
126 ${@oe.utils.conditional('TARGET_ARCH', 'x86_64', '', '--disable-glusterfs', d)} \
127 --with-cluster-support \
128 --with-profiling-data \
129 --with-libiconv=${STAGING_DIR_HOST}${prefix} \
130 --with-pam --with-pammodulesdir=${base_libdir}/security \
131 "
132
133LDFLAGS += "-Wl,-z,relro,-z,now ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
134
135do_configure:append() {
136 cd ${S}/pidl/
137 perl Makefile.PL PREFIX=${prefix}
138 sed -e 's,VENDORPREFIX)/lib/perl,VENDORPREFIX)/${baselib}/perl,g' \
139 -e 's,PERLPREFIX)/lib/perl,PERLPREFIX)/${baselib}/perl,g' -i Makefile
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 ctdb ctdb-tests \
221 ${PN}-common ${PN}-base ${PN}-ad-dc \
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"
260
261RDEPENDS:${PN}-ad-dc = "krb5-kdc"
262
263FILES:ctdb = "${bindir}/ctdb \
264 ${bindir}/ctdb_diagnostics \
265 ${bindir}/ltdbtool \
266 ${bindir}/onnode \
267 ${bindir}/ping_pong \
268 ${sbindir}/ctdbd \
269 ${datadir}/ctdb \
270 ${libexecdir}/ctdb \
271 ${localstatedir}/lib/ctdb \
272 ${sysconfdir}/ctdb \
273 ${sysconfdir}/sudoers.d/ctdb \
274 ${systemd_system_unitdir}/ctdb.service \
275"
276
277FILES:ctdb-tests = "${bindir}/ctdb_run_tests \
278 ${bindir}/ctdb_run_cluster_tests \
279 ${datadir}/ctdb-tests \
280 ${datadir}/ctdb/tests \
281"
282
283RDEPENDS:ctdb-tests += "bash util-linux-getopt ctdb"
284
285FILES:${BPN}-common = "${sysconfdir}/default \
286 ${sysconfdir}/samba \
287 ${sysconfdir}/tmpfiles.d \
288 ${localstatedir}/lib/samba \
289 ${localstatedir}/spool/samba \
290"
291
292FILES:${PN} += "${libdir}/vfs/*.so \
293 ${libdir}/charset/*.so \
294 ${libdir}/*.dat \
295 ${libdir}/auth/*.so \
296"
297
298FILES:${PN}-dsdb-modules = "${libdir}/samba/ldb"
299
300FILES:${PN}-testsuite = "${bindir}/gentest \
301 ${bindir}/locktest \
302 ${bindir}/masktest \
303 ${bindir}/ndrdump \
304 ${bindir}/smbtorture"
305
306FILES:registry-tools = "${bindir}/regdiff \
307 ${bindir}/regpatch \
308 ${bindir}/regshell \
309 ${bindir}/regtree"
310
311FILES:winbind = "${sbindir}/winbindd \
312 ${bindir}/wbinfo \
313 ${bindir}/ntlm_auth \
314 ${libdir}/samba/idmap \
315 ${libdir}/samba/nss_info \
316 ${libdir}/winbind_krb5_locator.so \
317 ${libdir}/winbind-krb5-localauth.so \
318 ${sysconfdir}/init.d/winbind \
319 ${systemd_system_unitdir}/winbind.service"
320
321FILES:${PN}-python3 = "${PYTHON_SITEPACKAGES_DIR}"
322
323FILES:smbclient = "${bindir}/cifsdd \
324 ${bindir}/rpcclient \
325 ${bindir}/smbcacls \
326 ${bindir}/smbclient \
327 ${bindir}/smbcquotas \
328 ${bindir}/smbget \
329 ${bindir}/smbspool \
330 ${bindir}/smbtar \
331 ${bindir}/smbtree \
332 ${libdir}/samba/smbspool_krb5_wrapper"
333
334FILES:${PN}-pidl = "${bindir}/pidl \
335 ${libdir}/perl5 \
336 "
337RDEPENDS:${PN}-pidl:append = " perl libparse-yapp-perl"
338
339RDEPENDS:${PN}-client = "\
340 smbclient \
341 winbind \
342 registry-tools \
343 ${PN}-pidl \
344 "
345
346ALLOW_EMPTY:${PN}-client = "1"
347
348RDEPENDS:${PN}-server = "\
349 ${PN} \
350 winbind \
351 registry-tools \
352 "
353
354ALLOW_EMPTY:${PN}-server = "1"
355
356RDEPENDS:${PN}-test = "\
357 ctdb-tests \
358 ${PN}-testsuite \
359 "
360
361ALLOW_EMPTY:${PN}-test = "1"