| 1 |
# Copyright 1999-2006 Gentoo Foundation |
|---|
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
|---|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/net-firewall/psad/psad-1.4.2.ebuild,v 1.3 2005/11/28 12:11:33 mcummings Exp $ |
|---|
| 4 |
|
|---|
| 5 |
inherit eutils perl-app |
|---|
| 6 |
|
|---|
| 7 |
IUSE="" |
|---|
| 8 |
|
|---|
| 9 |
DESCRIPTION="Port Scanning Attack Detection daemon" |
|---|
| 10 |
SRC_URI="http://www.cipherdyne.org/psad/download/${P}.tar.bz2" |
|---|
| 11 |
HOMEPAGE="http://www.cipherdyne.org/psad" |
|---|
| 12 |
|
|---|
| 13 |
SLOT="0" |
|---|
| 14 |
LICENSE="GPL-2" |
|---|
| 15 |
KEYWORDS="~x86 ~amd64 ~ppc ~alpha ~sparc" |
|---|
| 16 |
|
|---|
| 17 |
DEPEND="${DEPEND} |
|---|
| 18 |
dev-lang/perl" |
|---|
| 19 |
|
|---|
| 20 |
RDEPEND="virtual/logger |
|---|
| 21 |
dev-perl/Unix-Syslog |
|---|
| 22 |
dev-perl/Date-Calc |
|---|
| 23 |
virtual/mailx |
|---|
| 24 |
net-firewall/iptables" |
|---|
| 25 |
|
|---|
| 26 |
src_compile() { |
|---|
| 27 |
cd ${S}/Net-IPv4Addr |
|---|
| 28 |
SRC_PREP="no" perl-module_src_compile |
|---|
| 29 |
emake test |
|---|
| 30 |
|
|---|
| 31 |
cd ${S}/IPTables-Parse |
|---|
| 32 |
SRC_PREP="no" perl-module_src_compile |
|---|
| 33 |
emake test |
|---|
| 34 |
|
|---|
| 35 |
cd ${S}/IPTables-ChainMgr |
|---|
| 36 |
SRC_PREP="no" perl-module_src_compile |
|---|
| 37 |
emake test |
|---|
| 38 |
|
|---|
| 39 |
cd ${S} |
|---|
| 40 |
# We'll use the C binaries |
|---|
| 41 |
emake || die "Make failed: daemons" |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
src_install() { |
|---|
| 45 |
local myhostname= |
|---|
| 46 |
local mydomain= |
|---|
| 47 |
|
|---|
| 48 |
doman *.8 |
|---|
| 49 |
|
|---|
| 50 |
keepdir /var/lib/psad /var/log/psad /var/run/psad /var/lock/subsys/${PN} |
|---|
| 51 |
dodir /etc/psad |
|---|
| 52 |
|
|---|
| 53 |
cd ${S}/Net-IPv4Addr |
|---|
| 54 |
emake install DESTDIR=${D} || die "Install failed: Net-IPv4Addr.pm" |
|---|
| 55 |
|
|---|
| 56 |
cd ${S}/IPTables-ChainMgr |
|---|
| 57 |
emake install DESTDIR=${D} || die "Install failed: IPTables-Mgr.pm" |
|---|
| 58 |
|
|---|
| 59 |
cd ${S}/IPTables-Parse |
|---|
| 60 |
emake install DESTDIR=${D} || die "Install failed: IPTables-Parse.pm" |
|---|
| 61 |
|
|---|
| 62 |
cd ${S} |
|---|
| 63 |
insinto /usr |
|---|
| 64 |
dosbin kmsgsd psad psadwatchd |
|---|
| 65 |
newsbin fwcheck_psad.pl fwcheck_psad |
|---|
| 66 |
dobin pscan |
|---|
| 67 |
|
|---|
| 68 |
cd ${S} |
|---|
| 69 |
|
|---|
| 70 |
fix_psad_conf |
|---|
| 71 |
|
|---|
| 72 |
insinto /etc/psad |
|---|
| 73 |
doins *.conf |
|---|
| 74 |
doins psad_* |
|---|
| 75 |
doins auto_dl icmp_types posf signatures pf.os |
|---|
| 76 |
|
|---|
| 77 |
cd ${S}/init-scripts |
|---|
| 78 |
exeinto /etc/init.d |
|---|
| 79 |
newexe psad-init.gentoo psad |
|---|
| 80 |
|
|---|
| 81 |
cd ${S}/snort_rules |
|---|
| 82 |
dodir /etc/psad/snort_rules |
|---|
| 83 |
insinto /etc/psad/snort_rules |
|---|
| 84 |
doins *.rules |
|---|
| 85 |
|
|---|
| 86 |
cd ${S} |
|---|
| 87 |
dodoc BENCHMARK CREDITS Change* FW_EXAMPLE_RULES README LICENSE SCAN_LOG |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
pkg_postinst() { |
|---|
| 91 |
if [ ! -p ${ROOT}/var/lib/psad/psadfifo ] |
|---|
| 92 |
then |
|---|
| 93 |
ebegin "Creating syslog FIFO for PSAD" |
|---|
| 94 |
mknod -m 600 ${ROOT}/var/lib/psad/psadfifo p |
|---|
| 95 |
eend $? |
|---|
| 96 |
fi |
|---|
| 97 |
|
|---|
| 98 |
echo |
|---|
| 99 |
einfo "Please be sure to edit /etc/psad/psad.conf to reflect your system's" |
|---|
| 100 |
einfo "configuration or it may not work correctly or start up. Specifically, check" |
|---|
| 101 |
einfo "the validity of the HOSTNAME setting and replace the EMAIL_ADDRESSES and" |
|---|
| 102 |
einfo "HOME_NET settings at the least." |
|---|
| 103 |
echo |
|---|
| 104 |
if has_version ">=app-admin/syslog-ng-0.0.0" |
|---|
| 105 |
then |
|---|
| 106 |
ewarn "You appear to have installed syslog-ng. If you are using syslog-ng as your" |
|---|
| 107 |
ewarn "default system logger, please change the SYSLOG_DAEMON entry in" |
|---|
| 108 |
ewarn "/etc/psad/psad.conf to the following (per examples in psad.conf):" |
|---|
| 109 |
ewarn " SYSLOG_DAEMON syslog-ng;" |
|---|
| 110 |
echo |
|---|
| 111 |
fi |
|---|
| 112 |
if has_version ">=app-admin/sysklogd-0.0.0" |
|---|
| 113 |
then |
|---|
| 114 |
einfo "You have sysklogd installed. If this is your default system logger, no" |
|---|
| 115 |
einfo "special configuration is needed. If it is not, please set SYSLOG_DAEMON" |
|---|
| 116 |
einfo "in /etc/psad/psad.conf accordingly." |
|---|
| 117 |
echo |
|---|
| 118 |
fi |
|---|
| 119 |
if has_version ">=app-admin/metalog-0.0" |
|---|
| 120 |
then |
|---|
| 121 |
ewarn "You appear to have installed metalog. If you are using metalog as your" |
|---|
| 122 |
ewarn "default system logger, please change the SYSLOG_DAEMON entry in" |
|---|
| 123 |
ewarn "/etc/psad/psad.conf to the following (per examples in psad.conf):" |
|---|
| 124 |
ewarn " SYSLOG_DAEMON metalog" |
|---|
| 125 |
fi |
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
fix_psad_conf() { |
|---|
| 129 |
cp psad.conf psad.conf.orig |
|---|
| 130 |
|
|---|
| 131 |
# Ditch the _CHANGEME_ for hostname, substituting in our real hostname |
|---|
| 132 |
[ -e /etc/hostname ] && myhostname="$(< /etc/hostname)" |
|---|
| 133 |
[ "${myhostname}" == "" ] && myhostname="$HOSTNAME" |
|---|
| 134 |
mydomain=".$(grep ^domain /etc/resolv.conf | cut -d" " -f2)" |
|---|
| 135 |
sed -i "s:HOSTNAME\(.\+\)\_CHANGEME\_;:HOSTNAME\1${myhostname}${mydomain};:" psad.conf || die "fix_psad_conf failed" |
|---|
| 136 |
|
|---|
| 137 |
# Fix up paths |
|---|
| 138 |
sed -i "s:/sbin/syslogd:/usr/sbin/syslogd:g" psad.conf || die "fix_psad_conf failed" |
|---|
| 139 |
sed -i "s:/sbin/syslog-ng:/usr/sbin/syslog-ng:g" psad.conf || die "fix_psad_conf failed" |
|---|
| 140 |
sed -i "s:/bin/uname:/usr/bin/uname:g" psad.conf || die "fix_psad_conf failed" |
|---|
| 141 |
sed -i "s:/bin/mknod:/usr/bin/mknod:g" psad.conf || die "fix_psad_conf failed" |
|---|
| 142 |
} |
|---|