xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-connectivity/openssh/openssh_8.9p1.bb (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1SUMMARY = "A suite of security-related network utilities based on \
2the SSH protocol including the ssh client and sshd server"
3DESCRIPTION = "Secure rlogin/rsh/rcp/telnet replacement (OpenSSH) \
4Ssh (Secure Shell) is a program for logging into a remote machine \
5and for executing commands on a remote machine."
6HOMEPAGE = "http://www.openssh.com/"
7SECTION = "console/network"
8LICENSE = "BSD-2-Clause & BSD-3-Clause & ISC & MIT"
9LIC_FILES_CHKSUM = "file://LICENCE;md5=8baf365614c9bdd63705f298c9afbfb9"
10
11DEPENDS = "zlib openssl virtual/crypt"
12DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
13
14SRC_URI = "http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${PV}.tar.gz \
15           file://sshd_config \
16           file://ssh_config \
17           file://init \
18           ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} \
19           file://sshd.socket \
20           file://sshd@.service \
21           file://sshdgenkeys.service \
22           file://volatiles.99_sshd \
23           file://run-ptest \
24           file://fix-potential-signed-overflow-in-pointer-arithmatic.patch \
25           file://sshd_check_keys \
26           file://add-test-support-for-busybox.patch \
27           file://f107467179428a0e3ea9e4aa9738ac12ff02822d.patch \
28           file://0001-Default-to-not-using-sandbox-when-cross-compiling.patch \
29           "
30SRC_URI[sha256sum] = "fd497654b7ab1686dac672fb83dfb4ba4096e8b5ffcdaccd262380ae58bec5e7"
31
32# This CVE is specific to OpenSSH with the pam opie which we don't build/use here
33CVE_CHECK_IGNORE += "CVE-2007-2768"
34
35# This CVE is specific to OpenSSH server, as used in Fedora and Red Hat Enterprise Linux 7
36# and when running in a Kerberos environment. As such it is not relevant to OpenEmbedded
37CVE_CHECK_IGNORE += "CVE-2014-9278"
38
39# CVE only applies to some distributed RHEL binaries
40CVE_CHECK_IGNORE += "CVE-2008-3844"
41
42PAM_SRC_URI = "file://sshd"
43
44inherit manpages useradd update-rc.d update-alternatives systemd
45
46USERADD_PACKAGES = "${PN}-sshd"
47USERADD_PARAM:${PN}-sshd = "--system --no-create-home --home-dir /var/run/sshd --shell /bin/false --user-group sshd"
48INITSCRIPT_PACKAGES = "${PN}-sshd"
49INITSCRIPT_NAME:${PN}-sshd = "sshd"
50INITSCRIPT_PARAMS:${PN}-sshd = "defaults 9"
51
52SYSTEMD_PACKAGES = "${PN}-sshd"
53SYSTEMD_SERVICE:${PN}-sshd = "sshd.socket"
54
55inherit autotools-brokensep ptest
56
57PACKAGECONFIG ??= ""
58PACKAGECONFIG[kerberos] = "--with-kerberos5,--without-kerberos5,krb5"
59PACKAGECONFIG[ldns] = "--with-ldns,--without-ldns,ldns"
60PACKAGECONFIG[libedit] = "--with-libedit,--without-libedit,libedit"
61PACKAGECONFIG[manpages] = "--with-mantype=man,--with-mantype=cat"
62
63EXTRA_AUTORECONF += "--exclude=aclocal"
64
65# login path is hardcoded in sshd
66EXTRA_OECONF = "'LOGIN_PROGRAM=${base_bindir}/login' \
67                ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '--with-pam', '--without-pam', d)} \
68                --without-zlib-version-check \
69                --with-privsep-path=${localstatedir}/run/sshd \
70                --sysconfdir=${sysconfdir}/ssh \
71                --with-xauth=${bindir}/xauth \
72                --disable-strip \
73                "
74
75# musl doesn't implement wtmp/utmp and logwtmp
76EXTRA_OECONF:append:libc-musl = " --disable-wtmp --disable-lastlog"
77
78# Since we do not depend on libbsd, we do not want configure to use it
79# just because it finds libutil.h.  But, specifying --disable-libutil
80# causes compile errors, so...
81CACHED_CONFIGUREVARS += "ac_cv_header_bsd_libutil_h=no ac_cv_header_libutil_h=no"
82
83# passwd path is hardcoded in sshd
84CACHED_CONFIGUREVARS += "ac_cv_path_PATH_PASSWD_PROG=${bindir}/passwd"
85
86# We don't want to depend on libblockfile
87CACHED_CONFIGUREVARS += "ac_cv_header_maillock_h=no"
88
89do_configure:prepend () {
90	export LD="${CC}"
91	install -m 0644 ${WORKDIR}/sshd_config ${B}/
92	install -m 0644 ${WORKDIR}/ssh_config ${B}/
93}
94
95do_compile_ptest() {
96	oe_runmake regress-binaries regress-unit-binaries
97}
98
99do_install:append () {
100	if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
101		install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
102		sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/sshd_config
103	fi
104
105	if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then
106		sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' ${D}${sysconfdir}/ssh/sshd_config
107	fi
108
109	install -d ${D}${sysconfdir}/init.d
110	install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/sshd
111	rm -f ${D}${bindir}/slogin ${D}${datadir}/Ssh.bin
112	rmdir ${D}${localstatedir}/run/sshd ${D}${localstatedir}/run ${D}${localstatedir}
113	install -d ${D}/${sysconfdir}/default/volatiles
114	install -m 644 ${WORKDIR}/volatiles.99_sshd ${D}/${sysconfdir}/default/volatiles/99_sshd
115	install -m 0755 ${S}/contrib/ssh-copy-id ${D}${bindir}
116
117	# Create config files for read-only rootfs
118	install -d ${D}${sysconfdir}/ssh
119	install -m 644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_readonly
120	sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
121	echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
122	echo "HostKey /var/run/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
123	echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
124
125	install -d ${D}${systemd_system_unitdir}
126	install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
127	install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
128	install -c -m 0644 ${WORKDIR}/sshdgenkeys.service ${D}${systemd_system_unitdir}
129	sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
130		-e 's,@SBINDIR@,${sbindir},g' \
131		-e 's,@BINDIR@,${bindir},g' \
132		-e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
133		${D}${systemd_system_unitdir}/sshd.socket ${D}${systemd_system_unitdir}/*.service
134
135	sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
136		${D}${sysconfdir}/init.d/sshd
137
138	install -D -m 0755 ${WORKDIR}/sshd_check_keys ${D}${libexecdir}/${BPN}/sshd_check_keys
139}
140
141do_install_ptest () {
142	sed -i -e "s|^SFTPSERVER=.*|SFTPSERVER=${libexecdir}/sftp-server|" regress/test-exec.sh
143	cp -r regress ${D}${PTEST_PATH}
144	cp config.h ${D}${PTEST_PATH}
145}
146
147ALLOW_EMPTY:${PN} = "1"
148
149PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server"
150FILES:${PN}-scp = "${bindir}/scp.${BPN}"
151FILES:${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
152FILES:${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd ${systemd_system_unitdir}"
153FILES:${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config ${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd"
154FILES:${PN}-sshd += "${libexecdir}/${BPN}/sshd_check_keys"
155FILES:${PN}-sftp = "${bindir}/sftp"
156FILES:${PN}-sftp-server = "${libexecdir}/sftp-server"
157FILES:${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*"
158FILES:${PN}-keygen = "${bindir}/ssh-keygen"
159
160RDEPENDS:${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen ${PN}-sftp-server"
161RDEPENDS:${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
162# break dependency on base package for -dev package
163# otherwise SDK fails to build as the main openssh and dropbear packages
164# conflict with each other
165RDEPENDS:${PN}-dev = ""
166# gdb would make attach-ptrace test pass rather than skip but not worth the build dependencies
167RDEPENDS:${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make sed sudo coreutils"
168
169RPROVIDES:${PN}-ssh = "ssh"
170RPROVIDES:${PN}-sshd = "sshd"
171
172RCONFLICTS:${PN} = "dropbear"
173RCONFLICTS:${PN}-sshd = "dropbear"
174
175CONFFILES:${PN}-sshd = "${sysconfdir}/ssh/sshd_config"
176CONFFILES:${PN}-ssh = "${sysconfdir}/ssh/ssh_config"
177
178ALTERNATIVE_PRIORITY = "90"
179ALTERNATIVE:${PN}-scp = "scp"
180ALTERNATIVE:${PN}-ssh = "ssh"
181
182BBCLASSEXTEND += "nativesdk"
183