blob: 07cd6b74cddb2a66524cf72779f9092979196ad1 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001SUMMARY = "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"
Andrew Geissler5199d832021-09-24 16:47:35 -05008LICENSE = "BSD-2-Clause & BSD-3-Clause & BSD-4-Clause & ISC & MIT"
Andrew Geissler95ac1b82021-03-31 14:34:31 -05009LIC_FILES_CHKSUM = "file://LICENCE;md5=d9d2753bdef9f19466dc7bc959114b11"
Andrew Geissler82c905d2020-04-13 13:39:40 -050010
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 "
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050028SRC_URI[sha256sum] = "7ca34b8bb24ae9e50f33792b7091b3841d7e1b440ff57bc9fabddf01e2ed1e24"
Andrew Geissler6ce62a22020-11-30 19:58:47 -060029
William A. Kennington IIIac69b482021-06-02 12:28:27 -070030# This CVE is specific to OpenSSH with the pam opie which we don't build/use here
31CVE_CHECK_WHITELIST += "CVE-2007-2768"
32
Andrew Geissler6ce62a22020-11-30 19:58:47 -060033# This CVE is specific to OpenSSH server, as used in Fedora and Red Hat Enterprise Linux 7
34# and when running in a Kerberos environment. As such it is not relevant to OpenEmbedded
35CVE_CHECK_WHITELIST += "CVE-2014-9278"
Andrew Geissler82c905d2020-04-13 13:39:40 -050036
William A. Kennington IIIac69b482021-06-02 12:28:27 -070037# CVE only applies to some distributed RHEL binaries
38CVE_CHECK_WHITELIST += "CVE-2008-3844"
39
Andrew Geissler82c905d2020-04-13 13:39:40 -050040PAM_SRC_URI = "file://sshd"
41
42inherit manpages useradd update-rc.d update-alternatives systemd
43
44USERADD_PACKAGES = "${PN}-sshd"
Patrick Williams213cb262021-08-07 19:21:33 -050045USERADD_PARAM:${PN}-sshd = "--system --no-create-home --home-dir /var/run/sshd --shell /bin/false --user-group sshd"
Andrew Geissler82c905d2020-04-13 13:39:40 -050046INITSCRIPT_PACKAGES = "${PN}-sshd"
Patrick Williams213cb262021-08-07 19:21:33 -050047INITSCRIPT_NAME:${PN}-sshd = "sshd"
48INITSCRIPT_PARAMS:${PN}-sshd = "defaults 9"
Andrew Geissler82c905d2020-04-13 13:39:40 -050049
50SYSTEMD_PACKAGES = "${PN}-sshd"
Patrick Williams213cb262021-08-07 19:21:33 -050051SYSTEMD_SERVICE:${PN}-sshd = "sshd.socket"
Andrew Geissler82c905d2020-04-13 13:39:40 -050052
53inherit autotools-brokensep ptest
54
Andrew Geisslerc3d88e42020-10-02 09:45:00 -050055PACKAGECONFIG ??= "rng-tools"
Andrew Geissler82c905d2020-04-13 13:39:40 -050056PACKAGECONFIG[kerberos] = "--with-kerberos5,--without-kerberos5,krb5"
57PACKAGECONFIG[ldns] = "--with-ldns,--without-ldns,ldns"
58PACKAGECONFIG[libedit] = "--with-libedit,--without-libedit,libedit"
59PACKAGECONFIG[manpages] = "--with-mantype=man,--with-mantype=cat"
60
Andrew Geisslerc3d88e42020-10-02 09:45:00 -050061# Add RRECOMMENDS to rng-tools for sshd package
62PACKAGECONFIG[rng-tools] = ""
63
Andrew Geissler82c905d2020-04-13 13:39:40 -050064EXTRA_AUTORECONF += "--exclude=aclocal"
65
66# login path is hardcoded in sshd
67EXTRA_OECONF = "'LOGIN_PROGRAM=${base_bindir}/login' \
68 ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '--with-pam', '--without-pam', d)} \
69 --without-zlib-version-check \
70 --with-privsep-path=${localstatedir}/run/sshd \
71 --sysconfdir=${sysconfdir}/ssh \
72 --with-xauth=${bindir}/xauth \
73 --disable-strip \
74 "
75
Andrew Geisslerd1e89492021-02-12 15:35:20 -060076# musl doesn't implement wtmp/utmp and logwtmp
Patrick Williams213cb262021-08-07 19:21:33 -050077EXTRA_OECONF:append:libc-musl = " --disable-wtmp --disable-lastlog"
Andrew Geissler82c905d2020-04-13 13:39:40 -050078
79# Since we do not depend on libbsd, we do not want configure to use it
80# just because it finds libutil.h. But, specifying --disable-libutil
81# causes compile errors, so...
82CACHED_CONFIGUREVARS += "ac_cv_header_bsd_libutil_h=no ac_cv_header_libutil_h=no"
83
84# passwd path is hardcoded in sshd
85CACHED_CONFIGUREVARS += "ac_cv_path_PATH_PASSWD_PROG=${bindir}/passwd"
86
87# We don't want to depend on libblockfile
88CACHED_CONFIGUREVARS += "ac_cv_header_maillock_h=no"
89
Patrick Williams213cb262021-08-07 19:21:33 -050090do_configure:prepend () {
Andrew Geissler82c905d2020-04-13 13:39:40 -050091 export LD="${CC}"
92 install -m 0644 ${WORKDIR}/sshd_config ${B}/
93 install -m 0644 ${WORKDIR}/ssh_config ${B}/
94}
95
96do_compile_ptest() {
97 # skip regress/unittests/ binaries: this will silently skip
98 # unittests in run-ptests which is good because they are so slow.
99 oe_runmake regress/modpipe regress/setuid-allowed regress/netcat \
100 regress/check-perm regress/mkdtemp
101}
102
Patrick Williams213cb262021-08-07 19:21:33 -0500103do_install:append () {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500104 if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
105 install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
106 sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/sshd_config
107 fi
108
109 if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then
110 sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' ${D}${sysconfdir}/ssh/sshd_config
111 fi
112
113 install -d ${D}${sysconfdir}/init.d
114 install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/sshd
115 rm -f ${D}${bindir}/slogin ${D}${datadir}/Ssh.bin
116 rmdir ${D}${localstatedir}/run/sshd ${D}${localstatedir}/run ${D}${localstatedir}
117 install -d ${D}/${sysconfdir}/default/volatiles
118 install -m 644 ${WORKDIR}/volatiles.99_sshd ${D}/${sysconfdir}/default/volatiles/99_sshd
119 install -m 0755 ${S}/contrib/ssh-copy-id ${D}${bindir}
120
121 # Create config files for read-only rootfs
122 install -d ${D}${sysconfdir}/ssh
123 install -m 644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_readonly
124 sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
125 echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
126 echo "HostKey /var/run/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
127 echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
128
Andrew Geissler5199d832021-09-24 16:47:35 -0500129 install -d ${D}${systemd_system_unitdir}
130 install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
131 install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
132 install -c -m 0644 ${WORKDIR}/sshdgenkeys.service ${D}${systemd_system_unitdir}
Andrew Geissler82c905d2020-04-13 13:39:40 -0500133 sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
134 -e 's,@SBINDIR@,${sbindir},g' \
135 -e 's,@BINDIR@,${bindir},g' \
136 -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
Andrew Geissler5199d832021-09-24 16:47:35 -0500137 ${D}${systemd_system_unitdir}/sshd.socket ${D}${systemd_system_unitdir}/*.service
Andrew Geissler82c905d2020-04-13 13:39:40 -0500138
139 sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
140 ${D}${sysconfdir}/init.d/sshd
141
142 install -D -m 0755 ${WORKDIR}/sshd_check_keys ${D}${libexecdir}/${BPN}/sshd_check_keys
143}
144
145do_install_ptest () {
146 sed -i -e "s|^SFTPSERVER=.*|SFTPSERVER=${libexecdir}/sftp-server|" regress/test-exec.sh
147 cp -r regress ${D}${PTEST_PATH}
148}
149
Patrick Williams213cb262021-08-07 19:21:33 -0500150ALLOW_EMPTY:${PN} = "1"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500151
152PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server"
Patrick Williams213cb262021-08-07 19:21:33 -0500153FILES:${PN}-scp = "${bindir}/scp.${BPN}"
154FILES:${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
Andrew Geissler5199d832021-09-24 16:47:35 -0500155FILES:${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd ${systemd_system_unitdir}"
Patrick Williams213cb262021-08-07 19:21:33 -0500156FILES:${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config ${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd"
157FILES:${PN}-sshd += "${libexecdir}/${BPN}/sshd_check_keys"
158FILES:${PN}-sftp = "${bindir}/sftp"
159FILES:${PN}-sftp-server = "${libexecdir}/sftp-server"
160FILES:${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*"
161FILES:${PN}-keygen = "${bindir}/ssh-keygen"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500162
Patrick Williams213cb262021-08-07 19:21:33 -0500163RDEPENDS:${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
164RDEPENDS:${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
165RRECOMMENDS:${PN}-sshd:append:class-target = "\
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500166 ${@bb.utils.filter('PACKAGECONFIG', 'rng-tools', d)} \
167"
168
Andrew Geissler82c905d2020-04-13 13:39:40 -0500169# gdb would make attach-ptrace test pass rather than skip but not worth the build dependencies
Patrick Williams213cb262021-08-07 19:21:33 -0500170RDEPENDS:${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make sed sudo coreutils"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500171
Patrick Williams213cb262021-08-07 19:21:33 -0500172RPROVIDES:${PN}-ssh = "ssh"
173RPROVIDES:${PN}-sshd = "sshd"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500174
Patrick Williams213cb262021-08-07 19:21:33 -0500175RCONFLICTS:${PN} = "dropbear"
176RCONFLICTS:${PN}-sshd = "dropbear"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500177
Patrick Williams213cb262021-08-07 19:21:33 -0500178CONFFILES:${PN}-sshd = "${sysconfdir}/ssh/sshd_config"
179CONFFILES:${PN}-ssh = "${sysconfdir}/ssh/ssh_config"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500180
181ALTERNATIVE_PRIORITY = "90"
Patrick Williams213cb262021-08-07 19:21:33 -0500182ALTERNATIVE:${PN}-scp = "scp"
183ALTERNATIVE:${PN}-ssh = "ssh"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500184
185BBCLASSEXTEND += "nativesdk"