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