summaryrefslogtreecommitdiff
blob: b452dee49a005ca387ce8f521dbff566dcdb7057 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit systemd toolchain-funcs

DESCRIPTION="Very Secure FTP Daemon"
HOMEPAGE="https://security.appspot.com/vsftpd.html"
SRC_URI="https://security.appspot.com/downloads/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sparc ~x86"
IUSE="pam ssl tcpd"

DEPEND="
	>=sys-libs/libcap-2
	pam? ( sys-libs/pam )
	!pam? ( virtual/libcrypt:= )
	ssl? ( dev-libs/openssl:0= )
	tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
"

RDEPEND="${DEPEND}
	net-ftp/ftpbase
"

src_prepare() {
	local PATCHES=(
		"${FILESDIR}"/vsftpd-2.3.2-kerberos.patch
		"${FILESDIR}"/vsftpd-3.0.2-alpha.patch
		"${FILESDIR}"/vsftpd-3.0.3-sparc.patch
	)
	default
}

define() {
	sed -i -e "/#undef $1/c#define $1" "${S}"/builddefs.h || die
}

undef() {
	sed -i -e "/#define $1/c#undef $1" "${S}"/builddefs.h || die
}

src_configure() {
	libs=( -lcap )

	if use pam; then
		libs+=( -lpam )
	else
		undef VSF_BUILD_PAM
		libs+=( -lcrypt )
	fi

	if use ssl; then
		define VSF_BUILD_SSL
		libs+=( -lcrypto -lssl )
	fi

	if use tcpd; then
		define VSF_BUILD_TCPWRAPPERS
		libs+=( -lwrap )
	fi
}

src_compile() {
	local args=(
		CC="$(tc-getCC)"
		CFLAGS="${CFLAGS}"
		LDFLAGS="${LDFLAGS}"
		LIBS="${libs[*]}"
		LINK=
	)
	emake "${args[@]}"
}

src_install() {
	into /usr
	dosbin vsftpd

	doman vsftpd.conf.5 vsftpd.8

	insinto /etc/logrotate.d
	newins "${FILESDIR}"/vsftpd.logrotate vsftpd

	insinto /etc/xinetd.d
	newins "${FILESDIR}"/vsftpd.xinetd vsftpd

	newinitd "${FILESDIR}"/vsftpd.init-3.0.5 vsftpd

	systemd_newunit "${FILESDIR}"/vsftpd.service-3.0.5 vsftpd.service
	systemd_newunit "${FILESDIR}"/vsftpd_at.service-3.0.5 vsftpd@.service
	systemd_dounit "${FILESDIR}"/vsftpd.socket

	keepdir /usr/share/empty

	dodoc vsftpd.conf
	dodoc -r EXAMPLE SECURITY

	einstalldocs
}

pkg_preinst() {
	if [[ ! -e ${EROOT}/etc/vsftpd.conf && -e ${EROOT}/etc/vsftpd/vsftpd.conf ]]; then
		elog "Moving ${EROOT}/etc/vsftpd/vsftpd.conf to ${EROOT}/etc/vsftpd.conf"
		mv "${EROOT}"/etc/{vsftpd/,}vsftpd.conf || die
	fi
}