net-dialup/ppp: Security cleanup
[gentoo.git] / net-dialup / openl2tp / openl2tp-1.8-r1.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit linux-info
7
8 DESCRIPTION="Userspace tools for kernel L2TP implementation"
9 HOMEPAGE="http://www.openl2tp.org/"
10 SRC_URI="mirror://sourceforge/openl2tp/${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="~amd64 ~x86"
15 IUSE="+client debug dmalloc doc +examples rpc server stats"
16
17 REQUIRED_USE="|| ( client server )"
18
19 BDEPEND="
20         >=net-libs/rpcsvc-proto-1.3.1-r1
21         sys-devel/bison
22         sys-devel/flex
23 "
24 DEPEND="
25         >=net-dialup/ppp-2.4.5
26         >=net-libs/libtirpc-1.0.3
27         sys-libs/readline:=
28         dmalloc? ( dev-libs/dmalloc )
29 "
30 RDEPEND="${DEPEND}
31         rpc? ( net-nds/rpcbind )
32 "
33
34 CONFIG_CHECK="~PPPOL2TP"
35
36 PATCHES=(
37         "${FILESDIR}/${P}-werror.patch"
38         "${FILESDIR}/${P}-ldflags.patch"
39         "${FILESDIR}/${P}-pppd-2.patch"
40         "${FILESDIR}/${P}-man.patch"
41         "${FILESDIR}/${P}-l2tpconfig.patch"
42         "${FILESDIR}/${P}-parallelbuild.patch"
43         "${FILESDIR}/${P}-optionsfile.patch"
44         "${FILESDIR}/${P}-clientip_as_ipparam.patch"
45         "${FILESDIR}/${P}-setkey.patch"
46         "${FILESDIR}/${P}-unused-var.patch"
47         "${FILESDIR}/${P}-configure-Makefile.patch"
48         "${FILESDIR}/${P}-cflags.patch"
49         "${FILESDIR}/${P}-tirpc.patch"
50 )
51
52 src_prepare() {
53         default
54         sed -i 's/CFLAGS.optimize/CFLAGS_optimize/g' Makefile */Makefile || die "Makefile sed failed"
55 }
56
57 src_configure() {
58         myconf=
59
60         use client      || myconf+=" L2TP_FEATURE_LAC_SUPPORT=n
61                                                          L2TP_FEATURE_LAIC_SUPPORT=n
62                                                          L2TP_FEATURE_LAOC_SUPPORT=n "
63
64         use server      || myconf+=" L2TP_FEATURE_LNS_SUPPORT=n
65                                                          L2TP_FEATURE_LNIC_SUPPORT=n
66                                                          L2TP_FEATURE_LNOC_SUPPORT=n "
67
68         use rpc         || myconf+=" L2TP_FEATURE_RPC_MANAGEMENT=n "
69
70         use stats       && myconf+=" L2TP_FEATURE_LOCAL_STAT_FILE=y "
71         use debug       && myconf+=" L2TP_DEBUG=y "
72         use dmalloc     && myconf+=" USE_DMALLOC=y "
73
74         echo ${myconf} > "${T}/myconf"
75 }
76
77 src_compile() {
78         emake $(cat "${T}/myconf")
79 }
80
81 src_install() {
82         emake $(cat "${T}/myconf") DESTDIR="${D}" install
83
84         if use examples; then
85                 docinto event_socket
86                 dodoc doc/{event_sock_example.c,README.event_sock}
87                 docinto
88                 dodoc -r "${FILESDIR}"/examples
89         fi
90
91         if use doc; then
92                 dodoc doc/*.txt
93                 newdoc plugins/README README.plugins
94                 dodoc -r ipsec
95         fi
96
97         newinitd "${FILESDIR}"/openl2tpd.initd openl2tpd
98         # init.d script is quite different for RPC and non-RPC versions.
99         use rpc || sed -i s/userpc=\"yes\"/userpc=\"no\"/ "${D}/etc/init.d/openl2tpd" || die "sed failed"
100         newconfd "${FILESDIR}"/openl2tpd.confd openl2tpd
101 }
102
103 pkg_postinst() {
104         if use rpc; then
105                 ewarn
106                 ewarn "RPC control does not provide any auth checks for control connection."
107                 ewarn "Unless you need this you should disable it, for reference:"
108                 ewarn "http://forums.openl2tp.org/viewtopic.php?f=4&t=41"
109                 ewarn
110                 ewarn "Therefore DO NOT USE RPC IN INSECURE ENVIRONMENTS!"
111         else
112                 ewarn
113                 ewarn "Without RPC support you won't be able to use l2tpconfig."
114                 ewarn "Please read http://forums.openl2tp.org/viewtopic.php?f=4&t=41"
115                 ewarn "for more information about the security risk before enabling."
116                 ewarn
117                 ewarn "If you are using numerical strings (e.g. login name containing only"
118                 ewarn "digits) or special characters in password, please use double quotes"
119                 ewarn "to enclose them."
120         fi
121         if use stats; then
122                 ewarn
123                 ewarn "To enable status files openl2tpd must be started with -S option."
124                 ewarn "Upstream warns about runtime overhead with status files enabled."
125         fi
126 }