dropbear-2018.76-r1.ebuild (2747B)
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5
6 inherit eutils savedconfig pam user
7
8 DESCRIPTION="small SSH 2 client/server designed for small memory environments"
9 HOMEPAGE="https://matt.ucc.asn.au/dropbear/dropbear.html"
10 SRC_URI="https://matt.ucc.asn.au/dropbear/releases/${P}.tar.bz2
11 https://matt.ucc.asn.au/dropbear/testing/${P}.tar.bz2"
12
13 LICENSE="MIT"
14 SLOT="0"
15 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
16 IUSE="bsdpty minimal multicall pam +shadow static +syslog zlib"
17
18 LIB_DEPEND="zlib? ( sys-libs/zlib[static-libs(+)] )
19 dev-libs/libtomcrypt[static-libs(+)]
20 dev-libs/libtommath[static-libs(+)]"
21 RDEPEND="!static? ( ${LIB_DEPEND//\[static-libs(+)]} )
22 pam? ( virtual/pam )"
23 DEPEND="${RDEPEND}
24 static? ( ${LIB_DEPEND} )"
25 RDEPEND+=" pam? ( >=sys-auth/pambase-20080219.1 )"
26
27 REQUIRED_USE="pam? ( !static )"
28
29 set_options() {
30 progs=(
31 dropbear dbclient dropbearkey
32 $(usex minimal "" "dropbearconvert scp")
33 )
34 makeopts=(
35 MULTI=$(usex multicall 1 0)
36 STATIC=$(usex static 1 0)
37 )
38 }
39
40 src_prepare() {
41 epatch "${FILESDIR}/${PN}-0.46-dbscp.patch"
42 epatch "${FILESDIR}/dropbear-openssh-CVE-2018-20685.patch"
43 rm -fr libtomcrypt || die
44 rm -fr libtommath || die
45 sed \
46 -e '/SFTPSERVER_PATH/s:".*":"/usr/lib/misc/sftp-server":' \
47 default_options.h > localoptions.h || die
48 sed -i \
49 -e '/pam_start/s:sshd:dropbear:' \
50 svr-authpam.c || die
51 restore_config localoptions.h
52 }
53
54 src_configure() {
55 # We disable the hardening flags as our compiler already enables them
56 # by default as is appropriate for the target.
57 econf \
58 --disable-harden \
59 --disable-bundled-libtom \
60 $(use_enable zlib) \
61 $(use_enable pam) \
62 $(use_enable !bsdpty openpty) \
63 $(use_enable shadow) \
64 $(use_enable syslog)
65 }
66
67 src_compile() {
68 set_options
69 emake "${makeopts[@]}" PROGRAMS="${progs[*]}"
70 }
71
72 src_install() {
73 set_options
74 emake "${makeopts[@]}" PROGRAMS="${progs[*]}" DESTDIR="${D}" install
75 doman *.8
76 newinitd "${FILESDIR}"/dropbear.init.d dropbear
77 newconfd "${FILESDIR}"/dropbear.conf.d dropbear
78 dodoc CHANGES README SMALL MULTI
79
80 # The multi install target does not install the links right.
81 if use multicall ; then
82 cd "${ED}"/usr/bin
83 local x
84 for x in "${progs[@]}" ; do
85 ln -sf dropbearmulti ${x} || die "ln -s dropbearmulti to ${x} failed"
86 done
87 rm -f dropbear
88 dodir /usr/sbin
89 dosym ../bin/dropbearmulti /usr/sbin/dropbear
90 cd "${S}"
91 fi
92 save_config localoptions.h
93
94 if ! use minimal ; then
95 mv "${ED}"/usr/bin/{,db}scp || die
96 fi
97
98 pamd_mimic system-remote-login dropbear auth account password session
99 }
100
101 pkg_preinst() {
102 enewgroup sshd 22
103 enewuser sshd 22 -1 /var/empty sshd
104 }