xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-core/dropbear/dropbear.inc (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1SUMMARY = "A lightweight SSH and SCP implementation"
2HOMEPAGE = "http://matt.ucc.asn.au/dropbear/dropbear.html"
3DESCRIPTION = "Dropbear is a relatively small SSH server and client. It runs on a variety of POSIX-based platforms. Dropbear is open source software, distributed under a MIT-style license. Dropbear is particularly useful for "embedded"-type Linux (or other Unix) systems, such as wireless routers."
4SECTION = "console/network"
5
6# some files are from other projects and have others license terms:
7#   public domain, OpenSSH 3.5p1, OpenSSH3.6.1p2, PuTTY
8LICENSE = "MIT & BSD-3-Clause & BSD-2-Clause & PD"
9LIC_FILES_CHKSUM = "file://LICENSE;md5=25cf44512b7bc8966a48b6b1a9b7605f"
10
11DEPENDS = "zlib virtual/crypt"
12RPROVIDES:${PN} = "ssh sshd"
13RCONFLICTS:${PN} = "openssh-sshd openssh"
14
15# break dependency on base package for -dev package
16# otherwise SDK fails to build as the main openssh and dropbear packages
17# conflict with each other
18RDEPENDS:${PN}-dev = ""
19
20DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
21
22SRC_URI = "http://matt.ucc.asn.au/dropbear/releases/dropbear-${PV}.tar.bz2 \
23           file://0001-urandom-xauth-changes-to-options.h.patch \
24           file://init \
25           file://dropbearkey.service \
26           file://dropbear@.service \
27           file://dropbear.socket \
28           file://dropbear.default \
29           ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} \
30           ${@bb.utils.contains('PACKAGECONFIG', 'disable-weak-ciphers', 'file://dropbear-disable-weak-ciphers.patch', '', d)} \
31	   file://CVE-2021-36369.patch \
32	   "
33
34PAM_SRC_URI = "file://0005-dropbear-enable-pam.patch \
35               file://0006-dropbear-configuration-file.patch \
36               file://dropbear"
37
38PAM_PLUGINS = "libpam-runtime \
39	pam-plugin-deny \
40	pam-plugin-permit \
41	pam-plugin-unix \
42	"
43RDEPENDS:${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${PAM_PLUGINS}', '', d)}"
44
45inherit autotools update-rc.d systemd
46
47CVE_PRODUCT = "dropbear_ssh"
48
49INITSCRIPT_NAME = "dropbear"
50INITSCRIPT_PARAMS = "defaults 10"
51
52SYSTEMD_SERVICE:${PN} = "dropbear.socket"
53
54SBINCOMMANDS = "dropbear dropbearkey dropbearconvert"
55BINCOMMANDS = "dbclient ssh scp"
56EXTRA_OEMAKE = 'MULTI=1 SCPPROGRESS=1 PROGRAMS="${SBINCOMMANDS} ${BINCOMMANDS}"'
57
58PACKAGECONFIG ?= "disable-weak-ciphers"
59PACKAGECONFIG[system-libtom] = "--disable-bundled-libtom,--enable-bundled-libtom,libtommath libtomcrypt"
60PACKAGECONFIG[disable-weak-ciphers] = ""
61
62EXTRA_OECONF += "\
63 ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '--enable-pam', '--disable-pam', d)}"
64
65# This option appends to CFLAGS and LDFLAGS from OE
66# This is causing [textrel] QA warning
67EXTRA_OECONF += "--disable-harden"
68
69# musl does not implement wtmp/logwtmp APIs
70EXTRA_OECONF:append:libc-musl = " --disable-wtmp --disable-lastlog"
71
72do_install() {
73	install -d ${D}${sysconfdir} \
74		${D}${sysconfdir}/init.d \
75		${D}${sysconfdir}/default \
76		${D}${sysconfdir}/dropbear \
77		${D}${bindir} \
78		${D}${sbindir} \
79		${D}${localstatedir}
80
81	install -m 0644 ${WORKDIR}/dropbear.default ${D}${sysconfdir}/default/dropbear
82
83	install -m 0755 dropbearmulti ${D}${sbindir}/
84
85	for i in ${BINCOMMANDS}
86	do
87		# ssh and scp symlinks are created by update-alternatives
88		if [ $i = ssh ] || [ $i = scp ]; then continue; fi
89		ln -s ${sbindir}/dropbearmulti ${D}${bindir}/$i
90	done
91	for i in ${SBINCOMMANDS}
92	do
93		ln -s ./dropbearmulti ${D}${sbindir}/$i
94	done
95	sed -e 's,/etc,${sysconfdir},g' \
96		-e 's,/usr/sbin,${sbindir},g' \
97		-e 's,/var,${localstatedir},g' \
98		-e 's,/usr/bin,${bindir},g' \
99		-e 's,/usr,${prefix},g' ${WORKDIR}/init > ${D}${sysconfdir}/init.d/dropbear
100	chmod 755 ${D}${sysconfdir}/init.d/dropbear
101	if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
102		install -d ${D}${sysconfdir}/pam.d
103		install -m 0644 ${WORKDIR}/dropbear  ${D}${sysconfdir}/pam.d/
104	fi
105
106	# deal with systemd unit files
107	install -d ${D}${systemd_system_unitdir}
108	install -m 0644 ${WORKDIR}/dropbearkey.service ${D}${systemd_system_unitdir}
109	install -m 0644 ${WORKDIR}/dropbear@.service ${D}${systemd_system_unitdir}
110	install -m 0644 ${WORKDIR}/dropbear.socket ${D}${systemd_system_unitdir}
111	sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
112		-e 's,@BINDIR@,${bindir},g' \
113		-e 's,@SBINDIR@,${sbindir},g' \
114		${D}${systemd_system_unitdir}/dropbear.socket ${D}${systemd_system_unitdir}/*.service
115}
116
117inherit update-alternatives
118
119ALTERNATIVE_PRIORITY = "20"
120ALTERNATIVE:${PN} = "${@bb.utils.filter('BINCOMMANDS', 'scp ssh', d)}"
121
122ALTERNATIVE_TARGET = "${sbindir}/dropbearmulti"
123
124pkg_postrm:${PN} () {
125  if [ -f "${sysconfdir}/dropbear/dropbear_rsa_host_key" ]; then
126        rm ${sysconfdir}/dropbear/dropbear_rsa_host_key
127  fi
128  if [ -f "${sysconfdir}/dropbear/dropbear_dss_host_key" ]; then
129        rm ${sysconfdir}/dropbear/dropbear_dss_host_key
130  fi
131}
132
133FILES:${PN} += "${bindir}"
134