summaryrefslogtreecommitdiff
blob: 94f35f618f46a910e6d201e437a9a138ce5db9fd (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/snort/snort-2.0.6.ebuild,v 1.10 2005/01/29 05:12:51 dragonheart Exp $

inherit eutils

DESCRIPTION="Libpcap-based packet sniffer/logger/lightweight IDS"
HOMEPAGE="http://www.snort.org/"
SRC_URI="http://www.snort.org/dl/${P}.tar.gz
	prelude? ( http://www.prelude-ids.org/download/releases/snort-prelude-reporting-patch-0.2.5.tar.gz )"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86 -sparc -alpha ~amd64 ~ppc"
IUSE="ssl postgres mysql prelude flexresp samba"
# snort 2.0.x does not support snmp yet Bug #26310
# IUSE="${IUSE} snmp"

DEPEND="virtual/libc
	virtual/libpcap
	flexresp? (	<net-libs/libnet-1.1
				>=net-libs/libnet-1.0.2a-r3 )
	postgres? ( >=dev-db/postgresql-7.2 )
	mysql? ( >=dev-db/mysql-3.23.26 )
	ssl? ( >=dev-libs/openssl-0.9.6b )
	prelude? ( >=dev-libs/libprelude-0.8 )"
#	snmp? ( >=net-analyzer/net-snmp-5.0 )
RDEPEND="virtual/libc
	dev-lang/perl
	virtual/libpcap
	postgres? ( >=dev-db/postgresql-7.2 )
	mysql? ( >=dev-db/mysql-3.23.26 )
	ssl? ( >=dev-libs/openssl-0.9.6b )
	samba? ( net-fs/samba )
	prelude? ( >=dev-libs/libprelude-0.8 )"

src_unpack() {
	unpack ${A}

	cd ${S}
	#is this needed in 2.0? -Method
	#epatch ${FILESDIR}/${P}-configure.patch
	use flexresp && epatch ${FILESDIR}/${PV}-libnet-1.0.patch

	epatch ${FILESDIR}/${P}-gcc3.patch

	epatch ${FILESDIR}/snort-drop-calculation.diff

	sed "s:var RULE_PATH ../rules:var RULE_PATH /etc/snort:" < etc/snort.conf > etc/snort.conf.distrib

	use prelude && (
		epatch ../${P/.6/.2}-prelude.diff
		sh ./autogen.sh
	)
}

src_compile() {
	local myconf
	use flexresp && myconf="$myconf --enable-flexresp" # There is no --diable-flexresp, can't use use_enable
	use samba && myconf="$myconf --enable-smbalerts" # There is no --diable-smbalerts, can't use use_enable

#		`use_with snmp` \
#		 --enable-pthreads \ # Not supported, never was, and now also removed

	econf \
		`use_with postgres postgresql` \
		`use_with mysql` \
		`use_with ssl openssl` \
		`use_with prelude` \
		--without-odbc \
		--without-oracle \
		$myconf || die "bad ./configure"

	emake || die "compile problem"
}

src_install() {
	make DESTDIR=${D} install || die

	dodir /var/log/snort
	keepdir /var/log/snort/

	insinto /usr/lib/snort/bin
	doins contrib/{create_mysql,snortlog,*.pl}

	dodoc COPYING LICENSE doc/*
	docinto contrib ; dodoc contrib/*

	insinto /etc/snort
	doins etc/reference.config etc/classification.config rules/*.rules etc/*.map
	use prelude && doins etc/prelude-classification.config
	doins etc/snort.conf.distrib

	exeinto /etc/init.d ; newexe ${FILESDIR}/snort.rc6 snort
	insinto /etc/conf.d ; newins ${FILESDIR}/snort.confd snort
}

pkg_postinst() {
	enewgroup snort
	enewuser snort -1 /bin/false /var/log/snort snort
	usermod -d "/var/log/snort" snort || die "usermod problem"
	usermod -g "snort" snort || die "usermod problem"
	usermod -s "/bin/false" snort || die "usermod problem"
	echo "ignore any message about CREATE_HOME above..."

	chown snort:snort /var/log/snort
	chmod 0770 /var/log/snort
}