net-dialup/ppp: Security revbump to fix CVE-2015-3310 (bug #546554).
[gentoo.git] / net-dialup / ppp / ppp-2.4.4-r25.ebuild
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="2"
6
7 inherit eutils multilib toolchain-funcs linux-info pam
8
9 DESCRIPTION="Point-to-Point Protocol (PPP)"
10 HOMEPAGE="http://www.samba.org/ppp"
11 SRC_URI="ftp://ftp.samba.org/pub/ppp/${P}.tar.gz
12         mirror://gentoo/${P}-gentoo-20091116.tar.gz
13         dhcp? ( http://www.netservers.co.uk/gpl/ppp-dhcpc.tgz )"
14
15 LICENSE="BSD GPL-2"
16 SLOT="0"
17 KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86"
18 IUSE="activefilter atm dhcp eap-tls gtk ipv6 mppe-mppc pam radius"
19
20 DEPEND="activefilter? ( >=net-libs/libpcap-0.9.4 )
21         atm? ( net-dialup/linux-atm )
22         pam? ( virtual/pam )
23         gtk? ( >=x11-libs/gtk+-2.8:2 )
24         eap-tls? ( net-misc/curl >=dev-libs/openssl-0.9.7 )"
25 RDEPEND="${DEPEND}"
26
27 pkg_setup() {
28         if use mppe-mppc; then
29                 echo
30                 ewarn "The mppe-mppc flag overwrites the pppd native MPPE support with MPPE-MPPC"
31                 ewarn "patch developed by Jan Dubiec."
32                 ewarn "The resulted pppd will work only with patched kernels with version <= 2.6.14."
33                 ewarn "You could obtain the kernel patch from MPPE-MPPC homepage:"
34                 ewarn "   http://mppe-mppc.alphacron.de/"
35                 ewarn "CAUTION: MPPC is a U.S. patented algorithm!"
36                 ewarn "Ask yourself if you really need it and, if you do, consult your lawyer first."
37                 ebeep
38         fi
39 }
40
41 src_prepare() {
42         epatch "${WORKDIR}/patch/make-vars.patch"
43         epatch "${WORKDIR}/patch/mpls.patch"
44         epatch "${WORKDIR}/patch/killaddr-smarter.patch"
45         epatch "${WORKDIR}/patch/wait-children.patch"
46         epatch "${WORKDIR}/patch/maxoctets-2Glimit.patch"
47         epatch "${WORKDIR}/patch/defaultgateway.patch"
48         epatch "${WORKDIR}/patch/mschapv2-initialize-response.patch"
49         epatch "${WORKDIR}/patch/linkpidfile.patch"
50         epatch "${WORKDIR}/patch/qa-fixes.patch"
51         epatch "${WORKDIR}/patch/kill-pg.patch"
52         epatch "${WORKDIR}/patch/auth-fail.patch"
53         epatch "${WORKDIR}/patch/defaultmetric.patch"
54         epatch "${WORKDIR}/patch/dev-ppp.patch"
55         epatch "${WORKDIR}/patch/gtk2.patch"
56         epatch "${WORKDIR}/patch/pppoe-lcp-timeout.patch"
57         epatch "${WORKDIR}/patch/passwordfd-read-early.patch"
58         epatch "${WORKDIR}/patch/pppd-usepeerwins.patch"
59         epatch "${WORKDIR}/patch/connect-errors.patch"
60         epatch "${WORKDIR}/patch/ppp-pppoe-mac.patch"
61
62         use eap-tls && {
63                 # see http://eaptls.spe.net/index.html for more info
64                 einfo "Enabling EAP-TLS support"
65                 epatch "${WORKDIR}/patch/eaptls-0.7-gentoo.patch"
66                 use mppe-mppc || epatch "${WORKDIR}/patch/eaptls-mppe-0.7.patch"
67         }
68
69         use mppe-mppc && {
70                 einfo "Enabling MPPE-MPPC support"
71                 epatch "${WORKDIR}/patch/mppe-mppc-1.1.patch"
72                 use eap-tls && epatch "${WORKDIR}/patch/eaptls-mppe-0.7-with-mppc.patch"
73         }
74
75         use atm && {
76                 einfo "Enabling PPPoATM support"
77                 sed -i "s/^#HAVE_LIBATM=yes/HAVE_LIBATM=yes/" pppd/plugins/pppoatm/Makefile.linux
78         }
79
80         use activefilter || {
81                 einfo "Disabling active filter"
82                 sed -i "s/^FILTER=y/#FILTER=y/" pppd/Makefile.linux
83         }
84
85         use pam && {
86                 einfo "Enabling PAM"
87                 sed -i "s/^#USE_PAM=y/USE_PAM=y/" pppd/Makefile.linux
88         }
89
90         use ipv6 && {
91                 einfo "Enabling IPv6"
92                 sed -i "s/#HAVE_INET6/HAVE_INET6/" pppd/Makefile.linux
93         }
94
95         einfo "Enabling CBCP"
96         sed -i "s/^#CBCP=y/CBCP=y/" pppd/Makefile.linux
97
98         use dhcp && {
99                 # copy the ppp-dhcp plugin files
100                 einfo "Copying ppp-dhcp plugin files..."
101                 tar -xzf "${DISTDIR}/ppp-dhcpc.tgz" -C pppd/plugins/ \
102                         && sed -i -e 's/SUBDIRS := rp-pppoe/SUBDIRS := rp-pppoe dhcp/' pppd/plugins/Makefile.linux \
103                         || die "ppp-dhcp plugin addition failed"
104                 epatch "${WORKDIR}/patch/dhcp-make-vars.patch"
105                 epatch "${WORKDIR}/patch/dhcp-sys_error_to_strerror.patch"
106         }
107
108         # Set correct libdir
109         sed -i -e "s:/lib/pppd:/$(get_libdir)/pppd:" \
110                 pppd/{pathnames.h,pppd.8}
111
112         if use radius; then
113                 #set the right paths in radiusclient.conf
114                 sed -i -e "s:/usr/local/etc:/etc:" \
115                         -e "s:/usr/local/sbin:/usr/sbin:" pppd/plugins/radius/etc/radiusclient.conf
116                 #set config dir to /etc/ppp/radius
117                 sed -i -e "s:/etc/radiusclient:/etc/ppp/radius:g" \
118                         pppd/plugins/radius/{*.8,*.c,*.h} \
119                         pppd/plugins/radius/etc/*
120         else
121                 einfo "Disabling radius"
122                 sed -i -e '/+= radius/s:^:#:' pppd/plugins/Makefile.linux
123         fi
124 }
125
126 src_configure() {
127         export CC="$(tc-getCC)"
128         export AR="$(tc-getAR)"
129         econf || die "econf failed"
130 }
131
132 src_compile() {
133         emake COPTS="${CFLAGS} -D_GNU_SOURCE" || die "compile failed"
134
135         #build pppgetpass
136         cd contrib/pppgetpass
137         if use gtk; then
138                 emake -f Makefile.linux || die "failed to build pppgetpass"
139         else
140                 emake pppgetpass.vt || die "failed to build pppgetpass"
141         fi
142 }
143
144 src_install() {
145         local i
146         for i in chat pppd pppdump pppstats ; do
147                 doman ${i}/${i}.8
148                 dosbin ${i}/${i} || die
149         done
150         fperms u+s-w /usr/sbin/pppd
151
152         # Install pppd header files
153         pushd pppd >/dev/null
154         emake INSTROOT="${D}" install-devel || die
155         popd >/dev/null
156
157         dosbin pppd/plugins/rp-pppoe/pppoe-discovery || die
158
159         dodir /etc/ppp/peers
160         insinto /etc/ppp
161         insopts -m0600
162         newins etc.ppp/pap-secrets pap-secrets.example
163         newins etc.ppp/chap-secrets chap-secrets.example
164
165         insopts -m0644
166         doins etc.ppp/options
167
168         exeinto /etc/ppp
169         for i in ip-up ip-down ; do
170                 doexe "${WORKDIR}/scripts/${i}" || die "failed to install ${i} script"
171                 insinto /etc/ppp/${i}.d
172                 use ipv6 && dosym ${i} /etc/ppp/${i/ip/ipv6}
173                 doins "${WORKDIR}/scripts/${i}.d"/* || die "failed to install ${i}.d scripts"
174         done
175
176         pamd_mimic_system ppp auth account session
177
178         local PLUGINS_DIR=/usr/$(get_libdir)/pppd/$(awk -F '"' '/VERSION/ {print $2}' pppd/patchlevel.h)
179         #closing " for syntax coloring
180         insinto "${PLUGINS_DIR}"
181         insopts -m0755
182         doins pppd/plugins/minconn.so || die "minconn.so not build"
183         doins pppd/plugins/passprompt.so || die "passprompt.so not build"
184         doins pppd/plugins/passwordfd.so || die "passwordfd.so not build"
185         doins pppd/plugins/winbind.so || die "winbind.so not build"
186         doins pppd/plugins/rp-pppoe/rp-pppoe.so || die "rp-pppoe.so not build"
187         if use atm; then
188                 doins pppd/plugins/pppoatm/pppoatm.so || die "pppoatm.so not build"
189         fi
190         if use dhcp; then
191                 doins pppd/plugins/dhcp/dhcpc.so || die "dhcpc.so not build"
192         fi
193         if use radius; then
194                 doins pppd/plugins/radius/radius.so || die "radius.so not build"
195                 doins pppd/plugins/radius/radattr.so || die "radattr.so not build"
196                 doins pppd/plugins/radius/radrealms.so || die "radrealms.so not build"
197
198                 #Copy radiusclient configuration files (#92878)
199                 insinto /etc/ppp/radius
200                 insopts -m0644
201                 doins pppd/plugins/radius/etc/{dictionary*,issue,port-id-map,radiusclient.conf,realms,servers}
202
203                 doman pppd/plugins/radius/pppd-radius.8
204                 doman pppd/plugins/radius/pppd-radattr.8
205         fi
206
207         insinto /etc/modprobe.d
208         insopts -m0644
209         newins "${FILESDIR}/modules.ppp" ppp.conf
210         if use mppe-mppc; then
211                 sed -i -e 's/ppp_mppe/ppp_mppe_mppc/' "${D}/etc/modprobe.d/ppp.conf"
212         fi
213
214         dodoc PLUGINS README* SETUP Changes-2.3 FAQ
215         dodoc "${FILESDIR}/README.mpls"
216
217         dosbin scripts/pon && \
218             dosbin scripts/poff && \
219             dosbin scripts/plog && \
220             doman scripts/pon.1 || die "failed to install pon&poff scripts"
221
222         # Adding misc. specialized scripts to doc dir
223         insinto /usr/share/doc/${PF}/scripts/chatchat
224         doins scripts/chatchat/* || die "failed to install chat scripts in doc dir"
225         insinto /usr/share/doc/${PF}/scripts
226         doins scripts/* || die "failed to install scripts in doc dir"
227
228         if use gtk; then
229                 dosbin contrib/pppgetpass/{pppgetpass.vt,pppgetpass.gtk}
230                 newsbin contrib/pppgetpass/pppgetpass.sh pppgetpass
231         else
232                 newsbin contrib/pppgetpass/pppgetpass.vt pppgetpass
233         fi
234         doman contrib/pppgetpass/pppgetpass.8
235 }
236
237 pkg_postinst() {
238         if linux-info_get_any_version && linux_config_src_exists; then
239                 echo
240                 ewarn "If the following test report contains a missing kernel configuration option that you need,"
241                 ewarn "you should reconfigure and rebuild your kernel before running pppd."
242                 CONFIG_CHECK="~PPP ~PPP_ASYNC ~PPP_SYNC_TTY"
243                 local ERROR_PPP="CONFIG_PPP:\t missing PPP support (REQUIRED)"
244                 local ERROR_PPP_ASYNC="CONFIG_PPP_ASYNC:\t missing asynchronous serial line discipline (optional, but highly recommended)"
245                 local WARNING_PPP_SYNC_TTY="CONFIG_PPP_SYNC_TTY:\t missing synchronous serial line discipline (optional; used by 'sync' pppd option)"
246                 if use activefilter ; then
247                         CONFIG_CHECK="${CONFIG_CHECK} ~PPP_FILTER"
248                         local ERROR_PPP_FILTER="CONFIG_PPP_FILTER:\t missing PPP filtering support (REQUIRED)"
249                 fi
250                 CONFIG_CHECK="${CONFIG_CHECK} ~PPP_DEFLATE ~PPP_BSDCOMP"
251                 local ERROR_PPP_DEFLATE="CONFIG_PPP_DEFLATE:\t missing Deflate compression (optional, but highly recommended)"
252                 local ERROR_PPP_BSDCOMP="CONFIG_PPP_BSDCOMP:\t missing BSD-Compress compression (optional, but highly recommended)"
253                 if use mppe-mppc ; then
254                         CONFIG_CHECK="${CONFIG_CHECK} ~PPP_MPPE_MPPC"
255                         local WARNING_PPP_MPPE_MPPC="CONFIG_PPP_MPPE_MPPC:\t missing MPPE/MPPC encryption/compression (optional, mostly used by PPTP links)"
256                 else
257                         CONFIG_CHECK="${CONFIG_CHECK} ~PPP_MPPE"
258                         local WARNING_PPP_MPPE="CONFIG_PPP_MPPE:\t missing MPPE encryption (optional, mostly used by PPTP links)"
259                 fi
260                 CONFIG_CHECK="${CONFIG_CHECK} ~PPPOE ~PACKET"
261                 local WARNING_PPPOE="CONFIG_PPPOE:\t missing PPPoE support (optional, needed by rp-pppoe plugin)"
262                 local WARNING_PACKET="CONFIG_PACKET:\t missing AF_PACKET support (optional, used by rp-pppoe and dhcpc plugins)"
263                 if use atm ; then
264                         CONFIG_CHECK="${CONFIG_CHECK} ~PPPOATM"
265                         local WARNING_PPPOATM="CONFIG_PPPOATM:\t missing PPPoA support (optional, needed by pppoatm plugin)"
266                 fi
267                 check_extra_config
268         fi
269
270         if [ ! -e "${ROOT}/dev/.devfsd" ] && [ ! -e "${ROOT}/dev/.udev" ] && [ ! -e "${ROOT}/dev/ppp" ]; then
271                 mknod "${ROOT}/dev/ppp" c 108 0
272         fi
273         if [ "$ROOT" = "/" ]; then
274                 if [ -x /sbin/update-modules ]; then
275                         /sbin/update-modules
276                 else
277                         /sbin/modules-update
278                 fi
279         fi
280
281         # create *-secrets files if not exists
282         [ -f "${ROOT}/etc/ppp/pap-secrets" ] || \
283                 cp -pP "${ROOT}/etc/ppp/pap-secrets.example" "${ROOT}/etc/ppp/pap-secrets"
284         [ -f "${ROOT}/etc/ppp/chap-secrets" ] || \
285                 cp -pP "${ROOT}/etc/ppp/chap-secrets.example" "${ROOT}/etc/ppp/chap-secrets"
286
287         # lib name has changed
288         sed -i -e "s:^pppoe.so:rp-pppoe.so:" "${ROOT}/etc/ppp/options"
289
290         if use radius && [[ $previous_less_than_2_4_3_r5 = 0 ]] ; then
291                 echo
292                 ewarn "As of ${PN}-2.4.3-r5, the RADIUS configuration files have moved from"
293                 ewarn "   /etc/radiusclient to /etc/ppp/radius."
294                 einfo "For your convenience, radiusclient directory was copied to the new location."
295         fi
296
297         echo
298         elog "Pon, poff and plog scripts have been supplied for experienced users."
299         elog "Users needing particular scripts (ssh,rsh,etc.) should check out the"
300         elog "/usr/share/doc/${PF}/scripts directory."
301
302         # move the old user-defined files into ip-{up,down}.d directories
303         # TO BE REMOVED AFTER SEPT 2008
304         local i
305         for i in ip-up ip-down; do
306                 if [ -f "${ROOT}"/etc/ppp/${i}.local ]; then
307                         mv /etc/ppp/${i}.local /etc/ppp/${i}.d/90-local.sh && \
308                                 ewarn "/etc/ppp/${i}.local has been moved to /etc/ppp/${i}.d/90-local.sh"
309                 fi
310         done
311 }