Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | SUMMARY = "A suite of security-related network utilities based on \ |
| 2 | the SSH protocol including the ssh client and sshd server" |
| 3 | DESCRIPTION = "Secure rlogin/rsh/rcp/telnet replacement (OpenSSH) \ |
| 4 | Ssh (Secure Shell) is a program for logging into a remote machine \ |
| 5 | and for executing commands on a remote machine." |
| 6 | HOMEPAGE = "http://www.openssh.com/" |
| 7 | SECTION = "console/network" |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 8 | LICENSE = "BSD-2-Clause & BSD-3-Clause & BSD-4-Clause & BSD & ISC & MIT" |
| 9 | LIC_FILES_CHKSUM = "file://LICENCE;md5=d9d2753bdef9f19466dc7bc959114b11" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10 | |
| 11 | DEPENDS = "zlib openssl virtual/crypt" |
| 12 | DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}" |
| 13 | |
| 14 | SRC_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 Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 28 | SRC_URI[sha256sum] = "f52f3f41d429aa9918e38cf200af225ccdd8e66f052da572870c89737646ec25" |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 29 | |
| 30 | # This CVE is specific to OpenSSH server, as used in Fedora and Red Hat Enterprise Linux 7 |
| 31 | # and when running in a Kerberos environment. As such it is not relevant to OpenEmbedded |
| 32 | CVE_CHECK_WHITELIST += "CVE-2014-9278" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 33 | |
| 34 | PAM_SRC_URI = "file://sshd" |
| 35 | |
| 36 | inherit manpages useradd update-rc.d update-alternatives systemd |
| 37 | |
| 38 | USERADD_PACKAGES = "${PN}-sshd" |
| 39 | USERADD_PARAM_${PN}-sshd = "--system --no-create-home --home-dir /var/run/sshd --shell /bin/false --user-group sshd" |
| 40 | INITSCRIPT_PACKAGES = "${PN}-sshd" |
| 41 | INITSCRIPT_NAME_${PN}-sshd = "sshd" |
| 42 | INITSCRIPT_PARAMS_${PN}-sshd = "defaults 9" |
| 43 | |
| 44 | SYSTEMD_PACKAGES = "${PN}-sshd" |
| 45 | SYSTEMD_SERVICE_${PN}-sshd = "sshd.socket" |
| 46 | |
| 47 | inherit autotools-brokensep ptest |
| 48 | |
Andrew Geissler | c3d88e4 | 2020-10-02 09:45:00 -0500 | [diff] [blame] | 49 | PACKAGECONFIG ??= "rng-tools" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 50 | PACKAGECONFIG[kerberos] = "--with-kerberos5,--without-kerberos5,krb5" |
| 51 | PACKAGECONFIG[ldns] = "--with-ldns,--without-ldns,ldns" |
| 52 | PACKAGECONFIG[libedit] = "--with-libedit,--without-libedit,libedit" |
| 53 | PACKAGECONFIG[manpages] = "--with-mantype=man,--with-mantype=cat" |
| 54 | |
Andrew Geissler | c3d88e4 | 2020-10-02 09:45:00 -0500 | [diff] [blame] | 55 | # Add RRECOMMENDS to rng-tools for sshd package |
| 56 | PACKAGECONFIG[rng-tools] = "" |
| 57 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 58 | EXTRA_AUTORECONF += "--exclude=aclocal" |
| 59 | |
| 60 | # login path is hardcoded in sshd |
| 61 | EXTRA_OECONF = "'LOGIN_PROGRAM=${base_bindir}/login' \ |
| 62 | ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '--with-pam', '--without-pam', d)} \ |
| 63 | --without-zlib-version-check \ |
| 64 | --with-privsep-path=${localstatedir}/run/sshd \ |
| 65 | --sysconfdir=${sysconfdir}/ssh \ |
| 66 | --with-xauth=${bindir}/xauth \ |
| 67 | --disable-strip \ |
| 68 | " |
| 69 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 70 | # musl doesn't implement wtmp/utmp and logwtmp |
| 71 | EXTRA_OECONF_append_libc-musl = " --disable-wtmp --disable-lastlog" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 72 | |
| 73 | # Since we do not depend on libbsd, we do not want configure to use it |
| 74 | # just because it finds libutil.h. But, specifying --disable-libutil |
| 75 | # causes compile errors, so... |
| 76 | CACHED_CONFIGUREVARS += "ac_cv_header_bsd_libutil_h=no ac_cv_header_libutil_h=no" |
| 77 | |
| 78 | # passwd path is hardcoded in sshd |
| 79 | CACHED_CONFIGUREVARS += "ac_cv_path_PATH_PASSWD_PROG=${bindir}/passwd" |
| 80 | |
| 81 | # We don't want to depend on libblockfile |
| 82 | CACHED_CONFIGUREVARS += "ac_cv_header_maillock_h=no" |
| 83 | |
| 84 | do_configure_prepend () { |
| 85 | export LD="${CC}" |
| 86 | install -m 0644 ${WORKDIR}/sshd_config ${B}/ |
| 87 | install -m 0644 ${WORKDIR}/ssh_config ${B}/ |
| 88 | } |
| 89 | |
| 90 | do_compile_ptest() { |
| 91 | # skip regress/unittests/ binaries: this will silently skip |
| 92 | # unittests in run-ptests which is good because they are so slow. |
| 93 | oe_runmake regress/modpipe regress/setuid-allowed regress/netcat \ |
| 94 | regress/check-perm regress/mkdtemp |
| 95 | } |
| 96 | |
| 97 | do_install_append () { |
| 98 | if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then |
| 99 | install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd |
| 100 | sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/sshd_config |
| 101 | fi |
| 102 | |
| 103 | if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then |
| 104 | sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' ${D}${sysconfdir}/ssh/sshd_config |
| 105 | fi |
| 106 | |
| 107 | install -d ${D}${sysconfdir}/init.d |
| 108 | install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/sshd |
| 109 | rm -f ${D}${bindir}/slogin ${D}${datadir}/Ssh.bin |
| 110 | rmdir ${D}${localstatedir}/run/sshd ${D}${localstatedir}/run ${D}${localstatedir} |
| 111 | install -d ${D}/${sysconfdir}/default/volatiles |
| 112 | install -m 644 ${WORKDIR}/volatiles.99_sshd ${D}/${sysconfdir}/default/volatiles/99_sshd |
| 113 | install -m 0755 ${S}/contrib/ssh-copy-id ${D}${bindir} |
| 114 | |
| 115 | # Create config files for read-only rootfs |
| 116 | install -d ${D}${sysconfdir}/ssh |
| 117 | install -m 644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_readonly |
| 118 | sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly |
| 119 | echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly |
| 120 | echo "HostKey /var/run/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly |
| 121 | echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly |
| 122 | |
| 123 | install -d ${D}${systemd_unitdir}/system |
| 124 | install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_unitdir}/system |
| 125 | install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_unitdir}/system |
| 126 | install -c -m 0644 ${WORKDIR}/sshdgenkeys.service ${D}${systemd_unitdir}/system |
| 127 | sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \ |
| 128 | -e 's,@SBINDIR@,${sbindir},g' \ |
| 129 | -e 's,@BINDIR@,${bindir},g' \ |
| 130 | -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \ |
| 131 | ${D}${systemd_unitdir}/system/sshd.socket ${D}${systemd_unitdir}/system/*.service |
| 132 | |
| 133 | sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \ |
| 134 | ${D}${sysconfdir}/init.d/sshd |
| 135 | |
| 136 | install -D -m 0755 ${WORKDIR}/sshd_check_keys ${D}${libexecdir}/${BPN}/sshd_check_keys |
| 137 | } |
| 138 | |
| 139 | do_install_ptest () { |
| 140 | sed -i -e "s|^SFTPSERVER=.*|SFTPSERVER=${libexecdir}/sftp-server|" regress/test-exec.sh |
| 141 | cp -r regress ${D}${PTEST_PATH} |
| 142 | } |
| 143 | |
| 144 | ALLOW_EMPTY_${PN} = "1" |
| 145 | |
| 146 | PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server" |
| 147 | FILES_${PN}-scp = "${bindir}/scp.${BPN}" |
| 148 | FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config" |
| 149 | FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd ${systemd_unitdir}/system" |
| 150 | FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config ${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd" |
| 151 | FILES_${PN}-sshd += "${libexecdir}/${BPN}/sshd_check_keys" |
| 152 | FILES_${PN}-sftp = "${bindir}/sftp" |
| 153 | FILES_${PN}-sftp-server = "${libexecdir}/sftp-server" |
| 154 | FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*" |
| 155 | FILES_${PN}-keygen = "${bindir}/ssh-keygen" |
| 156 | |
| 157 | RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen" |
| 158 | RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}" |
Andrew Geissler | c3d88e4 | 2020-10-02 09:45:00 -0500 | [diff] [blame] | 159 | RRECOMMENDS_${PN}-sshd_append_class-target = "\ |
| 160 | ${@bb.utils.filter('PACKAGECONFIG', 'rng-tools', d)} \ |
| 161 | " |
| 162 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 163 | # gdb would make attach-ptrace test pass rather than skip but not worth the build dependencies |
| 164 | RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make sed sudo coreutils" |
| 165 | |
| 166 | RPROVIDES_${PN}-ssh = "ssh" |
| 167 | RPROVIDES_${PN}-sshd = "sshd" |
| 168 | |
| 169 | RCONFLICTS_${PN} = "dropbear" |
| 170 | RCONFLICTS_${PN}-sshd = "dropbear" |
| 171 | |
| 172 | CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config" |
| 173 | CONFFILES_${PN}-ssh = "${sysconfdir}/ssh/ssh_config" |
| 174 | |
| 175 | ALTERNATIVE_PRIORITY = "90" |
| 176 | ALTERNATIVE_${PN}-scp = "scp" |
| 177 | ALTERNATIVE_${PN}-ssh = "ssh" |
| 178 | |
| 179 | BBCLASSEXTEND += "nativesdk" |