summaryrefslogtreecommitdiff
blob: e633824b77b7324cfeb23b4b037af6135c32d350 (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
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-apache/mod_httpbl/mod_httpbl-1.5.ebuild,v 1.2 2009/11/26 20:39:59 flameeyes Exp $

EAPI=2

inherit apache-module

DESCRIPTION="http:BL implementation for Apache 2"
HOMEPAGE="http://www.projecthoneypot.org/httpbl_download.php"
SRC_URI="http://httpbl.cvs.sourceforge.net/viewvc/*checkout*/httpbl/mod_httpbl_for_apache_2.0/mod_httpbl_source/mod_httpbl.c?revision=${PV} -> ${P}.c"

LICENSE="GPL-2"
SLOT="0"
IUSE="debug"

KEYWORDS="~amd64"

S=${WORKDIR}

APACHE2_MOD_FILE=".libs/${PN}.so"
APACHE2_MOD_CONF="99_mod_httpbl"
APACHE2_MOD_DEFINE="HTTPBL"

need_apache2

# We have to copy the file in the work directory because otherwise
# apxs will try to build it within distdir (which is luckily read
# only).
src_unpack() {
	cp "${DISTDIR}"/${P}.c ${PN}.c || die
}

src_prepare() {
	sed -i \
		-e '/#define VERBOSITY/i#ifndef VERBOSITY' \
		-e '/#define VERBOSITY/a#endif' \
		${PN}.c || die
}

src_compile() {
	APXS_FLAGS=
	for flag in ${CFLAGS}; do
		APXS_FLAGS="${APXS_FLAGS} -Wc,${flag}"
	done

	if use debug; then
		APXS_FLAGS="${APXS_FLAGS} -DVERBOSITY=APLOG_DEBUG"
	fi

	# Yes we need to prefix it _twice_
	for flag in ${LDFLAGS}; do
		APXS_FLAGS="${APXS_FLAGS} -Wl,${flag}"
	done

	${APXS} -c ${APXS_FLAGS} ${PN}.c || die
}

src_install() {
	apache-module_src_install

	keepdir /var/log/apache2/httpbl
	fowners apache:apache /var/log/apache2/httpbl || die
	fperms 0770 /var/log/apache2/httpbl || die

	keepdir /var/cache/mod_httpbl || die
	fowners apache:apache /var/cache/mod_httpbl || die
	fperms 0770 /var/cache/mod_httpbl || die
}

pkg_postinst() {
	apache-module_pkg_postinst

	elog "To use http:BL you will need the API key from Project Honey Pot"
	elog "that you can receive being an active member."
	elog "See ${HOMEPAGE} for details."
	elog ""
	elog "By default all requests are filtered with the blacklist, you probably"
	elog "want to restrict that to virtual hosts where actual applications are"
	elog "running and/or on possibly vulnerable locations."
}