blob: bbb8fb091adec5278db45bbc99c7313d8dbcac23 [file] [log] [blame]
Patrick Williamsac13d5f2023-11-24 18:59:46 -06001SUMMARY = "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=072979064e691d342002f43cd89c0394"
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.service \
20 file://sshd.socket \
21 file://sshd@.service \
22 file://sshdgenkeys.service \
23 file://volatiles.99_sshd \
24 file://run-ptest \
25 file://fix-potential-signed-overflow-in-pointer-arithmatic.patch \
26 file://sshd_check_keys \
27 file://add-test-support-for-busybox.patch \
28 file://0001-regress-banner.sh-log-input-and-output-files-on-erro.patch \
29 file://0001-systemd-Add-optional-support-for-systemd-sd_notify.patch \
30 "
31SRC_URI[sha256sum] = "f026e7b79ba7fb540f75182af96dc8a8f1db395f922bbc9f6ca603672686086b"
32
33CVE_STATUS[CVE-2007-2768] = "not-applicable-config: This CVE is specific to OpenSSH with the pam opie which we don't build/use here."
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_STATUS[CVE-2014-9278] = "not-applicable-platform: This CVE is specific to OpenSSH server, as used in Fedora and \
38Red Hat Enterprise Linux 7 and when running in a Kerberos environment"
39
40CVE_STATUS[CVE-2008-3844] = "not-applicable-platform: Only applies to some distributed RHEL binaries."
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 sshd.service"
54
55inherit autotools-brokensep ptest pkgconfig
56DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
57
58PACKAGECONFIG ??= ""
59PACKAGECONFIG[kerberos] = "--with-kerberos5,--without-kerberos5,krb5"
60PACKAGECONFIG[ldns] = "--with-ldns,--without-ldns,ldns"
61PACKAGECONFIG[libedit] = "--with-libedit,--without-libedit,libedit"
62PACKAGECONFIG[manpages] = "--with-mantype=man,--with-mantype=cat"
63
64EXTRA_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 ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '--with-systemd', '--without-systemd', d)} \
75 "
76
77# musl doesn't implement wtmp/utmp and logwtmp
78EXTRA_OECONF:append:libc-musl = " --disable-wtmp --disable-lastlog"
79
80# Since we do not depend on libbsd, we do not want configure to use it
81# just because it finds libutil.h. But, specifying --disable-libutil
82# causes compile errors, so...
83CACHED_CONFIGUREVARS += "ac_cv_header_bsd_libutil_h=no ac_cv_header_libutil_h=no"
84
85# passwd path is hardcoded in sshd
86CACHED_CONFIGUREVARS += "ac_cv_path_PATH_PASSWD_PROG=${bindir}/passwd"
87
88# We don't want to depend on libblockfile
89CACHED_CONFIGUREVARS += "ac_cv_header_maillock_h=no"
90
91do_configure:prepend () {
92 export LD="${CC}"
93 install -m 0644 ${WORKDIR}/sshd_config ${B}/
94 install -m 0644 ${WORKDIR}/ssh_config ${B}/
95}
96
97do_compile_ptest() {
98 oe_runmake regress-binaries regress-unit-binaries
99}
100
101do_install:append () {
102 if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
103 install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
104 sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/sshd_config
105 fi
106
107 if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then
108 sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' ${D}${sysconfdir}/ssh/sshd_config
109 fi
110
111 install -d ${D}${sysconfdir}/init.d
112 install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/sshd
113 rm -f ${D}${bindir}/slogin ${D}${datadir}/Ssh.bin
114 rmdir ${D}${localstatedir}/run/sshd ${D}${localstatedir}/run ${D}${localstatedir}
115 install -d ${D}/${sysconfdir}/default/volatiles
116 install -m 644 ${WORKDIR}/volatiles.99_sshd ${D}/${sysconfdir}/default/volatiles/99_sshd
117 install -m 0755 ${S}/contrib/ssh-copy-id ${D}${bindir}
118
119 # Create config files for read-only rootfs
120 install -d ${D}${sysconfdir}/ssh
121 install -m 644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_readonly
122 sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly
123 echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
124 echo "HostKey /var/run/ssh/ssh_host_ecdsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
125 echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
126
127 install -d ${D}${systemd_system_unitdir}
128 install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
129 install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
130 install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
131 install -c -m 0644 ${WORKDIR}/sshdgenkeys.service ${D}${systemd_system_unitdir}
132 sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
133 -e 's,@SBINDIR@,${sbindir},g' \
134 -e 's,@BINDIR@,${bindir},g' \
135 -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
136 ${D}${systemd_system_unitdir}/sshd.socket ${D}${systemd_system_unitdir}/*.service
137
138 sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
139 ${D}${sysconfdir}/init.d/sshd
140
141 install -D -m 0755 ${WORKDIR}/sshd_check_keys ${D}${libexecdir}/${BPN}/sshd_check_keys
142}
143
144do_install_ptest () {
145 sed -i -e "s|^SFTPSERVER=.*|SFTPSERVER=${libexecdir}/sftp-server|" regress/test-exec.sh
146 cp -r regress ${D}${PTEST_PATH}
147 cp config.h ${D}${PTEST_PATH}
148}
149
150ALLOW_EMPTY:${PN} = "1"
151
152PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server"
153FILES:${PN}-scp = "${bindir}/scp.${BPN}"
154FILES:${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"
155FILES:${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd ${systemd_system_unitdir}"
156FILES:${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"
162
163RDEPENDS:${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen ${PN}-sftp-server"
164RDEPENDS:${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}"
165# gdb would make attach-ptrace test pass rather than skip but not worth the build dependencies
166RDEPENDS:${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make sed coreutils openssl-bin"
167
168RPROVIDES:${PN}-ssh = "ssh"
169RPROVIDES:${PN}-sshd = "sshd"
170
171RCONFLICTS:${PN} = "dropbear"
172RCONFLICTS:${PN}-sshd = "dropbear"
173
174CONFFILES:${PN}-sshd = "${sysconfdir}/ssh/sshd_config"
175CONFFILES:${PN}-ssh = "${sysconfdir}/ssh/ssh_config"
176
177ALTERNATIVE_PRIORITY = "90"
178ALTERNATIVE:${PN}-scp = "scp"
179ALTERNATIVE:${PN}-ssh = "ssh"
180
181BBCLASSEXTEND += "nativesdk"