1 |
# Copyright 1999-2012 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/openssh-5.5_p1-r2.ebuild,v 1.17 2012/11/06 02:44:11 floppym Exp $ |
4 |
|
5 |
EAPI="2" |
6 |
inherit eutils user flag-o-matic multilib autotools pam |
7 |
|
8 |
# Make it more portable between straight releases |
9 |
# and _p? releases. |
10 |
PARCH=${P/_/} |
11 |
PARCH_54=${PARCH/5.5/5.4} |
12 |
|
13 |
HPN_PATCH="${PARCH}-hpn13v9.diff.gz" |
14 |
HPN_X509_PATCH="${PARCH_54}-hpn13v7-x509variant.diff.gz" |
15 |
LDAP_PATCH="${PARCH_54/openssh/openssh-lpk}-0.3.13.patch.gz" |
16 |
X509_VER="6.2.3" X509_PATCH="${PARCH}+x509-${X509_VER}.diff.gz" |
17 |
|
18 |
DESCRIPTION="Port of OpenBSD's free SSH release" |
19 |
HOMEPAGE="http://www.openssh.org/" |
20 |
SRC_URI="mirror://openbsd/OpenSSH/portable/${PARCH}.tar.gz |
21 |
${HPN_PATCH:+hpn? ( http://www.psc.edu/networking/projects/hpn-ssh/${HPN_PATCH} mirror://gentoo/${HPN_PATCH} )} |
22 |
${LDAP_PATCH:+ldap? ( mirror://gentoo/${LDAP_PATCH} )} |
23 |
${X509_PATCH:+X509? ( http://roumenpetrov.info/openssh/x509-${X509_VER}/${X509_PATCH} )} |
24 |
${HPN_X509_PATCH:+hpn? ( X509? ( mirror://gentoo/${HPN_X509_PATCH} ) )} |
25 |
" |
26 |
|
27 |
LICENSE="BSD" |
28 |
SLOT="0" |
29 |
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~sparc-fbsd ~x86-fbsd" |
30 |
IUSE="bindist hpn kerberos ldap libedit pam selinux skey static tcpd X X509" |
31 |
|
32 |
RDEPEND="pam? ( virtual/pam ) |
33 |
kerberos? ( virtual/krb5 ) |
34 |
selinux? ( >=sys-libs/libselinux-1.28 ) |
35 |
skey? ( >=sys-auth/skey-1.1.5-r1 ) |
36 |
ldap? ( net-nds/openldap ) |
37 |
libedit? ( dev-libs/libedit ) |
38 |
>=dev-libs/openssl-0.9.6d:0[bindist=] |
39 |
>=sys-libs/zlib-1.2.3 |
40 |
tcpd? ( >=sys-apps/tcp-wrappers-7.6 ) |
41 |
X? ( x11-apps/xauth ) |
42 |
userland_GNU? ( virtual/shadow )" |
43 |
DEPEND="${RDEPEND} |
44 |
virtual/pkgconfig |
45 |
virtual/os-headers |
46 |
sys-devel/autoconf" |
47 |
RDEPEND="${RDEPEND} |
48 |
pam? ( >=sys-auth/pambase-20081028 )" |
49 |
|
50 |
S=${WORKDIR}/${PARCH} |
51 |
|
52 |
pkg_setup() { |
53 |
# this sucks, but i'd rather have people unable to `emerge -u openssh` |
54 |
# than not be able to log in to their server any more |
55 |
maybe_fail() { [[ -z ${!2} ]] && echo ${1} ; } |
56 |
local fail=" |
57 |
$(use X509 && maybe_fail X509 X509_PATCH) |
58 |
$(use ldap && maybe_fail ldap LDAP_PATCH) |
59 |
$(use hpn && maybe_fail hpn HPN_PATCH) |
60 |
$(use X509 && use hpn && maybe_fail x509+hpn HPN_X509_PATCH) |
61 |
" |
62 |
fail=$(echo ${fail}) |
63 |
if [[ -n ${fail} ]] ; then |
64 |
eerror "Sorry, but this version does not yet support features" |
65 |
eerror "that you requested: ${fail}" |
66 |
eerror "Please mask ${PF} for now and check back later:" |
67 |
eerror " # echo '=${CATEGORY}/${PF}' >> /etc/portage/package.mask" |
68 |
die "booooo" |
69 |
fi |
70 |
} |
71 |
|
72 |
src_prepare() { |
73 |
sed -i \ |
74 |
-e '/_PATH_XAUTH/s:/usr/X11R6/bin/xauth:/usr/bin/xauth:' \ |
75 |
pathnames.h || die |
76 |
# keep this as we need it to avoid the conflict between LPK and HPN changing |
77 |
# this file. |
78 |
cp version.h version.h.pristine |
79 |
|
80 |
if use X509 ; then |
81 |
# Apply X509 patch |
82 |
epatch "${DISTDIR}"/${X509_PATCH} |
83 |
# Apply glue so that HPN will still work after X509 |
84 |
#epatch "${FILESDIR}"/${PN}-5.2_p1-x509-hpn-glue.patch |
85 |
fi |
86 |
if ! use X509 ; then |
87 |
if [[ -n ${LDAP_PATCH} ]] && use ldap ; then |
88 |
epatch "${DISTDIR}"/${LDAP_PATCH} |
89 |
epatch "${FILESDIR}"/${PN}-5.2p1-ldap-stdargs.diff #266654 |
90 |
# version.h patch conflict avoidence |
91 |
mv version.h version.h.lpk |
92 |
cp -f version.h.pristine version.h |
93 |
fi |
94 |
else |
95 |
use ldap && ewarn "Sorry, X509 and LDAP conflict internally, disabling LDAP" |
96 |
fi |
97 |
epatch "${FILESDIR}"/${PN}-5.4_p1-openssl.patch |
98 |
epatch "${FILESDIR}"/${PN}-4.7_p1-GSSAPI-dns.patch #165444 integrated into gsskex |
99 |
if [[ -n ${HPN_PATCH} ]] && use hpn; then |
100 |
if use X509 ; then |
101 |
epatch "${DISTDIR}"/${HPN_X509_PATCH} |
102 |
else |
103 |
epatch "${DISTDIR}"/${HPN_PATCH} |
104 |
fi |
105 |
# version.h patch conflict avoidence |
106 |
mv version.h version.h.hpn |
107 |
cp -f version.h.pristine version.h |
108 |
# The AES-CTR multithreaded variant is broken, and causes random hangs |
109 |
# when combined background threading and control sockets. To avoid |
110 |
# this, we change the internal table to use the non-multithread version |
111 |
# for the meantime. Do NOT remove this in new versions. See bug #354113, |
112 |
# comment #6 for testcase. |
113 |
# Upstream reference: http://www.psc.edu/networking/projects/hpn-ssh/ |
114 |
## Additionally, the MT-AES-CTR mode cipher replaces the default ST-AES-CTR mode |
115 |
## cipher. Be aware that if the client process is forked using the -f command line |
116 |
## option the process will hang as the parent thread gets 'divorced' from the key |
117 |
## generation threads. This issue will be resolved as soon as possible |
118 |
sed -i \ |
119 |
-e '/aes...-ctr.*SSH_CIPHER_SSH2/s,evp_aes_ctr_mt,evp_aes_128_ctr,' \ |
120 |
cipher.c || die |
121 |
fi |
122 |
epatch "${FILESDIR}"/${PN}-5.2_p1-autoconf.patch |
123 |
|
124 |
sed -i "s:-lcrypto:$(pkg-config --libs openssl):" configure{,.ac} || die |
125 |
|
126 |
# Disable PATH reset, trust what portage gives us. bug 254615 |
127 |
sed -i -e 's:^PATH=/:#PATH=/:' configure || die |
128 |
|
129 |
# Now we can build a sane merged version.h |
130 |
t="${T}"/version.h |
131 |
m="${t}.merge" f="${t}.final" |
132 |
cat version.h.{hpn,pristine,lpk} 2>/dev/null \ |
133 |
| sed '/^#define SSH_RELEASE/d' \ |
134 |
| sort | uniq >"${m}" |
135 |
sed -n -r \ |
136 |
-e '/^\//p' \ |
137 |
<"${m}" >"${f}" |
138 |
sed -n -r \ |
139 |
-e '/SSH_LPK/s,"lpk","-lpk",g' \ |
140 |
-e '/^#define/p' \ |
141 |
<"${m}" >>"${f}" |
142 |
v="SSH_VERSION SSH_PORTABLE" |
143 |
[[ -f version.h.hpn ]] && v="${v} SSH_HPN" |
144 |
[[ -f version.h.lpk ]] && v="${v} SSH_LPK" |
145 |
echo "#define SSH_RELEASE ${v}" >>"${f}" |
146 |
cp "${f}" version.h |
147 |
|
148 |
eautoreconf |
149 |
} |
150 |
|
151 |
static_use_with() { |
152 |
local flag=$1 |
153 |
if use static && use ${flag} ; then |
154 |
ewarn "Disabling '${flag}' support because of USE='static'" |
155 |
# rebuild args so that we invert the first one (USE flag) |
156 |
# but otherwise leave everything else working so we can |
157 |
# just leverage use_with |
158 |
shift |
159 |
[[ -z $1 ]] && flag="${flag} ${flag}" |
160 |
set -- !${flag} "$@" |
161 |
fi |
162 |
use_with "$@" |
163 |
} |
164 |
|
165 |
src_configure() { |
166 |
addwrite /dev/ptmx |
167 |
addpredict /etc/skey/skeykeys #skey configure code triggers this |
168 |
|
169 |
use static && append-ldflags -static |
170 |
|
171 |
econf \ |
172 |
--with-ldflags="${LDFLAGS}" \ |
173 |
--disable-strip \ |
174 |
--sysconfdir=/etc/ssh \ |
175 |
--libexecdir=/usr/$(get_libdir)/misc \ |
176 |
--datadir=/usr/share/openssh \ |
177 |
--with-privsep-path=/var/empty \ |
178 |
--with-privsep-user=sshd \ |
179 |
--with-md5-passwords \ |
180 |
--with-ssl-engine \ |
181 |
$(static_use_with pam) \ |
182 |
$(static_use_with kerberos kerberos5 /usr) \ |
183 |
${LDAP_PATCH:+$(use X509 || ( use ldap && use_with ldap ))} \ |
184 |
$(use_with libedit) \ |
185 |
$(use_with selinux) \ |
186 |
$(use_with skey) \ |
187 |
$(use_with tcpd tcp-wrappers) \ |
188 |
|| die |
189 |
} |
190 |
|
191 |
src_compile() { |
192 |
emake || die |
193 |
} |
194 |
|
195 |
src_install() { |
196 |
emake install-nokeys DESTDIR="${D}" || die |
197 |
fperms 600 /etc/ssh/sshd_config |
198 |
dobin contrib/ssh-copy-id |
199 |
newinitd "${FILESDIR}"/sshd.rc6 sshd |
200 |
newconfd "${FILESDIR}"/sshd.confd sshd |
201 |
keepdir /var/empty |
202 |
|
203 |
newpamd "${FILESDIR}"/sshd.pam_include.2 sshd |
204 |
if use pam ; then |
205 |
sed -i \ |
206 |
-e "/^#UsePAM /s:.*:UsePAM yes:" \ |
207 |
-e "/^#PasswordAuthentication /s:.*:PasswordAuthentication no:" \ |
208 |
-e "/^#PrintMotd /s:.*:PrintMotd no:" \ |
209 |
-e "/^#PrintLastLog /s:.*:PrintLastLog no:" \ |
210 |
"${D}"/etc/ssh/sshd_config || die "sed of configuration file failed" |
211 |
fi |
212 |
|
213 |
# This instruction is from the HPN webpage, |
214 |
# Used for the server logging functionality |
215 |
if [[ -n ${HPN_PATCH} ]] && use hpn; then |
216 |
keepdir /var/empty/dev |
217 |
fi |
218 |
|
219 |
doman contrib/ssh-copy-id.1 |
220 |
dodoc ChangeLog CREDITS OVERVIEW README* TODO sshd_config |
221 |
|
222 |
diropts -m 0700 |
223 |
dodir /etc/skel/.ssh |
224 |
} |
225 |
|
226 |
src_test() { |
227 |
local t tests skipped failed passed shell |
228 |
tests="interop-tests compat-tests" |
229 |
skipped="" |
230 |
shell=$(egetshell ${UID}) |
231 |
if [[ ${shell} == */nologin ]] || [[ ${shell} == */false ]] ; then |
232 |
elog "Running the full OpenSSH testsuite" |
233 |
elog "requires a usable shell for the 'portage'" |
234 |
elog "user, so we will run a subset only." |
235 |
skipped="${skipped} tests" |
236 |
else |
237 |
tests="${tests} tests" |
238 |
fi |
239 |
for t in ${tests} ; do |
240 |
# Some tests read from stdin ... |
241 |
emake -k -j1 ${t} </dev/null \ |
242 |
&& passed="${passed}${t} " \ |
243 |
|| failed="${failed}${t} " |
244 |
done |
245 |
einfo "Passed tests: ${passed}" |
246 |
ewarn "Skipped tests: ${skipped}" |
247 |
if [[ -n ${failed} ]] ; then |
248 |
ewarn "Failed tests: ${failed}" |
249 |
die "Some tests failed: ${failed}" |
250 |
else |
251 |
einfo "Failed tests: ${failed}" |
252 |
return 0 |
253 |
fi |
254 |
} |
255 |
|
256 |
pkg_postinst() { |
257 |
enewgroup sshd 22 |
258 |
enewuser sshd 22 -1 /var/empty sshd |
259 |
|
260 |
ewarn "Remember to merge your config files in /etc/ssh/ and then" |
261 |
ewarn "reload sshd: '/etc/init.d/sshd reload'." |
262 |
if use pam ; then |
263 |
echo |
264 |
ewarn "Please be aware users need a valid shell in /etc/passwd" |
265 |
ewarn "in order to be allowed to login." |
266 |
fi |
267 |
# This instruction is from the HPN webpage, |
268 |
# Used for the server logging functionality |
269 |
if [[ -n ${HPN_PATCH} ]] && use hpn; then |
270 |
echo |
271 |
einfo "For the HPN server logging patch, you must ensure that" |
272 |
einfo "your syslog application also listens at /var/empty/dev/log." |
273 |
fi |
274 |
} |