*/*: Drop stable ia64 keywords
[gentoo.git] / net-ftp / vsftpd / vsftpd-3.0.3-r3.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit eutils systemd toolchain-funcs
7
8 DESCRIPTION="Very Secure FTP Daemon written with speed, size and security in mind"
9 HOMEPAGE="http://vsftpd.beasts.org/"
10 SRC_URI="http://security.appspot.com/downloads/${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="~alpha amd64 arm hppa ~ia64 ppc ppc64 s390 sparc x86"
15 IUSE="caps libressl pam tcpd ssl selinux xinetd"
16
17 DEPEND="caps? ( >=sys-libs/libcap-2 )
18         pam? ( sys-libs/pam )
19         tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
20         ssl? (
21                 !libressl? ( dev-libs/openssl:0= )
22                 libressl? ( dev-libs/libressl:0= )
23         )"
24 RDEPEND="${DEPEND}
25         net-ftp/ftpbase
26         selinux? ( sec-policy/selinux-ftp )
27         xinetd? ( sys-apps/xinetd )"
28
29 src_prepare() {
30         local PATCHES=(
31                 # kerberos patch. bug #335980
32                 "${FILESDIR}/${PN}-2.3.2-kerberos.patch"
33
34                 # Patch the source, config and the manpage to use /etc/vsftpd/
35                 "${FILESDIR}/${PN}-2.3.5-gentoo.patch"
36
37                 # Fix building without the libcap
38                 "${FILESDIR}/${PN}-2.1.0-caps.patch"
39
40                 # Fix building on alpha. Bug #405829
41                 "${FILESDIR}/${PN}-3.0.2-alpha.patch"
42
43                 #Bug #335977
44                 "${FILESDIR}"/${PN}-3.0.0-Makefile.patch
45
46                 #Bug #450536
47                 "${FILESDIR}"/${PN}-3.0.2-remove-legacy-cap.patch
48
49                 #Bug #630704
50                 "${FILESDIR}"/${PN}-3.0.3-sparc.patch
51
52                 # https://bugs.gentoo.org/443898
53                 "${FILESDIR}"/vsftpd-disable-seccomp-sandbox.patch
54         )
55
56         # Configure vsftpd build defaults
57         use tcpd && echo "#define VSF_BUILD_TCPWRAPPERS" >> builddefs.h
58         use ssl && echo "#define VSF_BUILD_SSL" >> builddefs.h
59         use pam || echo "#undef VSF_BUILD_PAM" >> builddefs.h
60
61         # Ensure that we don't link against libcap unless asked
62         if ! use caps ; then
63                 sed -i '/^#define VSF_SYSDEP_HAVE_LIBCAP$/ d' sysdeputil.c || die
64                 eapply "${FILESDIR}"/${PN}-2.2.0-dont-link-caps.patch
65         fi
66
67         # Let portage control stripping
68         sed -i '/^LINK[[:space:]]*=[[:space:]]*/ s/-Wl,-s//' Makefile || die
69
70         default
71 }
72
73 src_compile() {
74         # Override LIBS variable. Bug #508192
75         LIBS=
76         use caps && LIBS+=" -lcap"
77         use pam && LIBS+=" -lpam"
78         use tcpd && LIBS+=" -lwrap"
79         use ssl && LIBS+=" -lssl -lcrypto"
80
81         CFLAGS="${CFLAGS}" \
82         CC="$(tc-getCC)" \
83         emake LIBS="${LIBS}"
84 }
85
86 src_install() {
87         into /usr
88         doman ${PN}.conf.5 ${PN}.8
89         dosbin ${PN}
90
91         dodoc AUDIT BENCHMARKS BUGS Changelog FAQ \
92                 README README.security REWARD SIZE \
93                 SPEED TODO TUNING || die "dodoc failed"
94         newdoc ${PN}.conf ${PN}.conf.example
95
96         docinto security
97         dodoc SECURITY/*
98
99         insinto "/usr/share/doc/${PF}/examples"
100         doins -r EXAMPLE/*
101
102         insinto /etc/${PN}
103         newins ${PN}.conf{,.example}
104
105         insinto /etc/logrotate.d
106         newins "${FILESDIR}/${PN}.logrotate" ${PN}
107
108         if use xinetd ; then
109                 insinto /etc/xinetd.d
110                 newins "${FILESDIR}/${PN}.xinetd" ${PN}
111         fi
112
113         newinitd "${FILESDIR}/${PN}.init" ${PN}
114
115         keepdir /usr/share/${PN}/empty
116
117         exeinto /usr/libexec
118         doexe "${FILESDIR}/vsftpd-checkconfig.sh"
119         systemd_dounit "${FILESDIR}/${PN}.service"
120         systemd_newunit "${FILESDIR}/${PN}_at.service" "${PN}@.service"
121         systemd_dounit "${FILESDIR}/${PN}.socket"
122 }
123
124 pkg_preinst() {
125         # If we use xinetd, then we set listen=NO
126         # so that our default config works under xinetd - fixes #78347
127         if use xinetd ; then
128                 sed -i 's/listen=YES/listen=NO/g' "${D}"/etc/${PN}/${PN}.conf.example
129         fi
130 }
131
132 pkg_postinst() {
133         einfo "vsftpd openRC init script can now be multiplexed."
134         einfo "The default init script forces /etc/vsftpd/vsftpd.conf to exist."
135         einfo "If you symlink the init script to another one, say vsftpd.foo"
136         einfo "then that uses /etc/vsftpd/foo.conf instead."
137         einfo
138         einfo "Example:"
139         einfo "   cd /etc/init.d"
140         einfo "   ln -s vsftpd vsftpd.foo"
141         einfo "You can now treat vsftpd.foo like any other service"
142 }