net-dialup/ppp: Security revbump fixing pppd EAP-TLS buffer overflow
[gentoo.git] / net-dialup / ppp / ppp-2.4.7-r6.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit linux-info multilib pam toolchain-funcs
7
8 PATCH_VER="6"
9 DESCRIPTION="Point-to-Point Protocol (PPP)"
10 HOMEPAGE="https://ppp.samba.org/"
11 SRC_URI="https://download.samba.org/pub/ppp/${P}.tar.gz
12         https://dev.gentoo.org/~polynomial-c/${P}-patches-${PATCH_VER}.tar.xz
13         http://www.netservers.net.uk/gpl/ppp-dhcpc.tgz"
14
15 LICENSE="BSD GPL-2"
16 SLOT="0/${PV}"
17 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
18 IUSE="activefilter atm dhcp eap-tls gtk ipv6 libressl pam radius"
19
20 DEPEND="activefilter? ( net-libs/libpcap )
21         atm? ( net-dialup/linux-atm )
22         pam? ( virtual/pam )
23         gtk? ( x11-libs/gtk+:2 )
24         eap-tls? (
25                 !libressl? ( dev-libs/openssl:0= )
26                 libressl? ( dev-libs/libressl:= )
27         )"
28 RDEPEND="${DEPEND}"
29 PDEPEND="net-dialup/ppp-scripts"
30
31 src_prepare() {
32         mv "${WORKDIR}/dhcp" "${S}/pppd/plugins" || die
33
34         if ! use eap-tls ; then
35                 rm "${WORKDIR}"/patch/8?_all_eaptls-* || die
36         fi
37         eapply "${WORKDIR}"/patch
38
39         if use atm ; then
40                 einfo "Enabling PPPoATM support"
41                 sed -i '/^#HAVE_LIBATM=yes/s:#::' \
42                         pppd/plugins/pppoatm/Makefile.linux || die
43         fi
44
45         if ! use activefilter ; then
46                 einfo "Disabling active filter"
47                 sed -i '/^FILTER=y/s:^:#:' pppd/Makefile.linux || die
48         fi
49
50         if use pam ; then
51                 einfo "Enabling PAM"
52                 sed -i '/^#USE_PAM=y/s:^#::' pppd/Makefile.linux || die
53         fi
54
55         if use ipv6 ; then
56                 einfo "Enabling IPv6"
57                 sed -i '/#HAVE_INET6/s:#::' pppd/Makefile.linux || die
58                 echo "+ipv6" >> etc.ppp/options || die
59         fi
60
61         einfo "Enabling CBCP"
62         sed -i '/^#CBCP=y/s:#::' pppd/Makefile.linux || die
63
64         if use dhcp ; then
65                 einfo "Adding ppp-dhcp plugin files"
66                 sed \
67                         -e '/^SUBDIRS :=/s:$: dhcp:' \
68                         -i pppd/plugins/Makefile.linux || die
69         fi
70
71         # Set correct libdir
72         sed -i -e "s:/lib/pppd:/$(get_libdir)/pppd:" \
73                 pppd/{pathnames.h,pppd.8} || die
74
75         if use radius ; then
76                 #set the right paths in radiusclient.conf
77                 sed -e "s:/usr/local/etc:/etc:" \
78                         -e "s:/usr/local/sbin:/usr/sbin:" \
79                         -i pppd/plugins/radius/etc/radiusclient.conf || die
80                 #set config dir to /etc/ppp/radius
81                 sed -i -e "s:/etc/radiusclient:/etc/ppp/radius:g" \
82                         pppd/plugins/radius/{*.8,*.c,*.h} \
83                         pppd/plugins/radius/etc/* || die
84         else
85                 einfo "Disabling radius"
86                 sed -i -e '/+= radius/s:^:#:' pppd/plugins/Makefile.linux || die
87         fi
88
89         eapply_user #549588
90 }
91
92 src_compile() {
93         tc-export AR CC
94         emake COPTS="${CFLAGS} -D_GNU_SOURCE"
95
96         # build pppgetpass
97         cd contrib/pppgetpass || die
98         if use gtk ; then
99                 emake -f Makefile.linux
100         else
101                 emake pppgetpass.vt
102         fi
103 }
104
105 src_install() {
106         local i
107         for i in chat pppd pppdump pppstats ; do
108                 doman ${i}/${i}.8
109                 dosbin ${i}/${i}
110         done
111         fperms u+s-w /usr/sbin/pppd
112
113         # Install pppd header files
114         emake -C pppd INSTROOT="${D}" install-devel
115
116         dosbin pppd/plugins/rp-pppoe/pppoe-discovery
117
118         dodir /etc/ppp/peers
119         insinto /etc/ppp
120         insopts -m0600
121         newins etc.ppp/pap-secrets pap-secrets.example
122         newins etc.ppp/chap-secrets chap-secrets.example
123
124         insopts -m0644
125         doins etc.ppp/options
126
127         pamd_mimic_system ppp auth account session
128
129         local PLUGINS_DIR="/usr/$(get_libdir)/pppd/${PV}"
130         # closing " for syntax coloring
131         insinto "${PLUGINS_DIR}"
132         insopts -m0755
133         doins pppd/plugins/minconn.so
134         doins pppd/plugins/passprompt.so
135         doins pppd/plugins/passwordfd.so
136         doins pppd/plugins/winbind.so
137         doins pppd/plugins/rp-pppoe/rp-pppoe.so
138         doins pppd/plugins/pppol2tp/openl2tp.so
139         doins pppd/plugins/pppol2tp/pppol2tp.so
140         if use atm ; then
141                 doins pppd/plugins/pppoatm/pppoatm.so
142         fi
143         if use dhcp ; then
144                 doins pppd/plugins/dhcp/dhcpc.so
145         fi
146         if use radius ; then
147                 doins pppd/plugins/radius/rad{ius,attr,realms}.so
148
149                 #Copy radiusclient configuration files (#92878)
150                 insinto /etc/ppp/radius
151                 insopts -m0644
152                 doins pppd/plugins/radius/etc/{dictionary*,issue,port-id-map,radiusclient.conf,realms,servers}
153
154                 doman pppd/plugins/radius/pppd-rad{ius,attr}.8
155         fi
156
157         insinto /etc/modprobe.d
158         insopts -m0644
159         newins "${FILESDIR}/modules.ppp" ppp.conf
160
161         dodoc PLUGINS README* SETUP Changes-2.3 FAQ
162         dodoc "${FILESDIR}/README.mpls"
163
164         dosbin scripts/p{on,off,log}
165         doman scripts/pon.1
166
167         # Adding misc. specialized scripts to doc dir
168         insinto /usr/share/doc/${PF}/scripts/chatchat
169         doins scripts/chatchat/*
170         insinto /usr/share/doc/${PF}/scripts
171         doins scripts/*
172
173         if use gtk ; then
174                 dosbin contrib/pppgetpass/{pppgetpass.vt,pppgetpass.gtk}
175                 newsbin contrib/pppgetpass/pppgetpass.sh pppgetpass
176         else
177                 newsbin contrib/pppgetpass/pppgetpass.vt pppgetpass
178         fi
179         doman contrib/pppgetpass/pppgetpass.8
180 }
181
182 pkg_postinst() {
183         if linux-info_get_any_version && linux_config_src_exists ; then
184                 echo
185                 ewarn "If the following test report contains a missing kernel configuration option that you need,"
186                 ewarn "you should reconfigure and rebuild your kernel before running pppd."
187                 CONFIG_CHECK="~PPP ~PPP_ASYNC ~PPP_SYNC_TTY"
188                 local ERROR_PPP="CONFIG_PPP:\t missing PPP support (REQUIRED)"
189                 local ERROR_PPP_ASYNC="CONFIG_PPP_ASYNC:\t missing asynchronous serial line discipline (optional, but highly recommended)"
190                 local WARNING_PPP_SYNC_TTY="CONFIG_PPP_SYNC_TTY:\t missing synchronous serial line discipline (optional; used by 'sync' pppd option)"
191                 if use activefilter ; then
192                         CONFIG_CHECK="${CONFIG_CHECK} ~PPP_FILTER"
193                         local ERROR_PPP_FILTER="CONFIG_PPP_FILTER:\t missing PPP filtering support (REQUIRED)"
194                 fi
195                 CONFIG_CHECK="${CONFIG_CHECK} ~PPP_DEFLATE ~PPP_BSDCOMP ~PPP_MPPE"
196                 local ERROR_PPP_DEFLATE="CONFIG_PPP_DEFLATE:\t missing Deflate compression (optional, but highly recommended)"
197                 local ERROR_PPP_BSDCOMP="CONFIG_PPP_BSDCOMP:\t missing BSD-Compress compression (optional, but highly recommended)"
198                 local WARNING_PPP_MPPE="CONFIG_PPP_MPPE:\t missing MPPE encryption (optional, mostly used by PPTP links)"
199                 CONFIG_CHECK="${CONFIG_CHECK} ~PPPOE ~PACKET"
200                 local WARNING_PPPOE="CONFIG_PPPOE:\t missing PPPoE support (optional, needed by rp-pppoe plugin)"
201                 local WARNING_PACKET="CONFIG_PACKET:\t missing AF_PACKET support (optional, used by rp-pppoe and dhcpc plugins)"
202                 if use atm ; then
203                         CONFIG_CHECK="${CONFIG_CHECK} ~PPPOATM"
204                         local WARNING_PPPOATM="CONFIG_PPPOATM:\t missing PPPoA support (optional, needed by pppoatm plugin)"
205                 fi
206                 check_extra_config
207         fi
208
209         # create *-secrets files if not exists
210         [ -f "${ROOT}/etc/ppp/pap-secrets" ] || \
211                 cp -pP "${ROOT}/etc/ppp/pap-secrets.example" "${ROOT}/etc/ppp/pap-secrets"
212         [ -f "${ROOT}/etc/ppp/chap-secrets" ] || \
213                 cp -pP "${ROOT}/etc/ppp/chap-secrets.example" "${ROOT}/etc/ppp/chap-secrets"
214
215         # lib name has changed
216         sed -i -e "s:^pppoe.so:rp-pppoe.so:" "${ROOT}/etc/ppp/options" || die
217
218         echo
219         elog "Pon, poff and plog scripts have been supplied for experienced users."
220         elog "Users needing particular scripts (ssh,rsh,etc.) should check out the"
221         elog "/usr/share/doc/${PF}/scripts directory."
222 }