aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Arena <rnalrd@alpinelinux.org>2013-01-25 10:30:47 +0000
committerLeonardo Arena <rnalrd@alpinelinux.org>2013-01-25 10:54:25 +0000
commit54ac885b4810846a7c36e7f7a02c6986acb7b426 (patch)
treee4c0826b055fdf1739c598a2591945290eef833a
parent07000597e6664f0832e163fc436b15a91b843014 (diff)
downloadalpine_aports-54ac885b4810846a7c36e7f7a02c6986acb7b426.tar.bz2
alpine_aports-54ac885b4810846a7c36e7f7a02c6986acb7b426.tar.xz
alpine_aports-54ac885b4810846a7c36e7f7a02c6986acb7b426.zip
main/fprobe-ulog: backported from edge
-rw-r--r--main/fprobe-ulog/APKBUILD51
-rw-r--r--main/fprobe-ulog/fprobe-1.1-pidfile-sanity.patch48
-rw-r--r--main/fprobe-ulog/fprobe-ulog.confd68
-rwxr-xr-xmain/fprobe-ulog/fprobe-ulog.initd39
4 files changed, 206 insertions, 0 deletions
diff --git a/main/fprobe-ulog/APKBUILD b/main/fprobe-ulog/APKBUILD
new file mode 100644
index 0000000000..76c665c878
--- /dev/null
+++ b/main/fprobe-ulog/APKBUILD
@@ -0,0 +1,51 @@
1# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
2pkgname=fprobe-ulog
3pkgver=1.1
4pkgrel=1
5pkgdesc="netfilter-based tool that collect network traffic"
6url="http://fprobe.sourceforge.net/"
7arch="all"
8license="GPL"
9depends=
10makedepends=""
11install=""
12subpackages="$pkgname-doc"
13source="http://downloads.sourceforge.net/project/fprobe/$pkgname/$pkgver/$pkgname-1.1.tar.bz2
14 fprobe-ulog.confd
15 fprobe-ulog.initd
16 fprobe-1.1-pidfile-sanity.patch
17 "
18
19_builddir="$srcdir"/$pkgname-$pkgver
20
21prepare() {
22 cd $_builddir
23 for i in ../*.patch
24 do
25 msg "Applying $i"
26 patch -p1 < ../$i || exit 1
27 done
28}
29
30build() {
31 cd "$_builddir"
32 ./configure --prefix=/usr \
33 --sysconfdir=/etc \
34 --mandir=/usr/share/man \
35 --infodir=/usr/share/info
36 make || return 1
37}
38
39package() {
40 cd "$_builddir"
41 make DESTDIR="$pkgdir" install
42
43 install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
44 install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
45
46}
47
48md5sums="cdb2e4edc47e8a3d5479eeabfb979ebc fprobe-ulog-1.1.tar.bz2
49a92104da52c99532d1d01007b78940fc fprobe-ulog.confd
50744975c055421223940a278517b34d47 fprobe-ulog.initd
51f1316ad835c1a2b6565b4dc448b022df fprobe-1.1-pidfile-sanity.patch"
diff --git a/main/fprobe-ulog/fprobe-1.1-pidfile-sanity.patch b/main/fprobe-ulog/fprobe-1.1-pidfile-sanity.patch
new file mode 100644
index 0000000000..5f7b79bd8c
--- /dev/null
+++ b/main/fprobe-ulog/fprobe-1.1-pidfile-sanity.patch
@@ -0,0 +1,48 @@
1If we are using the chroot() option or the setuid options, we must create the
2pidfile before doing the chroot OR the setreuid. It's actually best for
3start-stop-daemon if we create the pidfile from the master side of the fork()
4before it exits, since most of the startup checks happen after the chroot()
5unfortunetly.
6
7Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
8
9diff -Nuar fprobe-1.1.orig/src/fprobe.c fprobe-1.1/src/fprobe.c
10--- fprobe-1.1.orig/src/fprobe-ulog.c 2005-01-30 08:43:35.000000000 +0000
11+++ fprobe-1.1/src/fprobe-ulog.c 2008-03-16 20:51:24.000000000 +0000
12@@ -1379,7 +1379,8 @@
13
14 my_log_open(ident, verbosity, log_dest);
15 if (!(log_dest & 2)) {
16- switch (fork()) {
17+ pid_t childpid = fork();
18+ switch (childpid) {
19 case -1:
20 fprintf(stderr, "fork(): %s", strerror(errno));
21 exit(1);
22@@ -1392,6 +1393,12 @@
23 break;
24
25 default:
26+ if (!(pidfile = fopen(pidfilepath, "w")))
27+ my_log(LOG_ERR, "Can't create pid file. fopen(): %s", strerror(errno));
28+ else {
29+ fprintf(pidfile, "%ld\n", (long) childpid);
30+ fclose(pidfile);
31+ }
32 exit(0);
33 }
34 } else {
35@@ -1548,13 +1555,6 @@
36 }
37 }
38
39- if (!(pidfile = fopen(pidfilepath, "w")))
40- my_log(LOG_ERR, "Can't create pid file. fopen(): %s", strerror(errno));
41- else {
42- fprintf(pidfile, "%ld\n", (long) pid);
43- fclose(pidfile);
44- }
45-
46 my_log(LOG_INFO, "pid: %d", pid);
47 my_log(LOG_INFO, "interface: %s, datalink: %s (%d)",
48 dev, dlt[link_type_idx].descr, link_type);
diff --git a/main/fprobe-ulog/fprobe-ulog.confd b/main/fprobe-ulog/fprobe-ulog.confd
new file mode 100644
index 0000000000..758d97f463
--- /dev/null
+++ b/main/fprobe-ulog/fprobe-ulog.confd
@@ -0,0 +1,68 @@
1# Config file for /etc/init.d/fprobe
2DAEMON=/usr/sbin/fprobe-ulog
3
4# Do we want the interface in promiscous mode [yes/no]
5#PROMISC=no
6
7# If configured, only capture packets matching this tcpdump expression
8#FILTER=""
9
10# Flow state timers
11#TIMER_EXPIRED=5
12#TIMER_FRAGMENTED=30
13#TIMER_IDLE=60
14#TIMER_ACTIVE=300
15
16# This is the default and should be left unless you know what you are doing
17#FLOW_VER=5
18
19# local ip. if configured fprobe will use this as the source IP for sending ALL flow data
20# If you want to specify a specific source address per collecter, customize it below
21#LOCALIP=
22
23# SNMP iface id
24SNMP_IFACE="${IFACE//eth}"
25
26# Maximum number of concurrent flows to track
27# using a specified amount of memory
28#MEMBULK=10000
29#MEMLIMIT=
30
31# Pending queue
32#PENDING=100
33
34# Kernel capture buffer size (kB)
35#KERNBUF=1024
36
37# Realtime priority [0=disabled, 1..99]
38#RTPRIO=0
39
40# Delay N nanoseconds after each B bytes
41#DELAY="0:0"
42
43# How much of the start of each packet to grab
44#SNAPLEN=256
45
46# chroot() to this location after startup
47CHROOT="/var/empty"
48
49# User to run as. must have perms to the pidfile directory /var/run/fprobe/
50USER=nobody
51
52# logging level for syslog (0=EMERG, ..., 6=INFO, 7=DEBUG)
53#LOGLEVEL=6
54
55# If you want to run multiple instances of fprobe,
56# You MUST set this variable to a unique INTEGER for each one!
57PIDFILE_ID=''
58
59# remote ip. this is where we send flows
60REMOTEIP=127.0.0.1
61# port to listen on
62PORT=2055
63# Collector type, see the manpage for valid types
64TYPE=''
65
66# If you want multiple collectors, just specify each one here
67COLLECTORS="${REMOTEIP}:${PORT}/${LOCALIP}/${TYPE}"
68
diff --git a/main/fprobe-ulog/fprobe-ulog.initd b/main/fprobe-ulog/fprobe-ulog.initd
new file mode 100755
index 0000000000..d8f5c9acff
--- /dev/null
+++ b/main/fprobe-ulog/fprobe-ulog.initd
@@ -0,0 +1,39 @@
1#!/sbin/runscript
2# Copyright 1999-2008 Gentoo Foundation
3# Distributed under the terms of the GNU General Public License v2
4
5depend() {
6 need net
7 after firewall
8}
9
10PIDFILE_EXTRA=""
11[ -n "$PIDFILE_ID" ] && PIDFILE_EXTRA="[$PIDFILE_ID]"
12PIDFILE="/var/run/fprobe-ulog$PIDFILE_EXTRA.pid"
13
14start() {
15 ebegin "Starting fprobe-ulog"
16 local OPTS=""
17 set --
18 [ -n "${FILTER}" ] && set -- -f "${FILTER}"
19 for optname in s:TIMER_EXPIRED g:TIME_FRAGMENTED d:TIMER_IDLE \
20 e:TIMER_ACTIVE n:FLOW_VER a:LOCALIP X:SNMP_IFACE b:MEMBULK \
21 m:MEMLIMIT q:PENDING B:KERNBUF r:RTPRIO t:DELAY \
22 c:CHROOT u:USER v:LOGLEVEL ; do
23 opt="${optname/:*}" optvar="${optname/*:}"
24 eval optvalue="\$$optvar"
25 [ -n "$optvalue" ] && OPTS="${OPTS} -${opt} ${optvalue}"
26 done
27 OPTS="${OPTS} -l 1:${PIDFILE_ID} ${COLLECTORS}"
28 start-stop-daemon --start --exec $DAEMON \
29 --pidfile ${PIDFILE} \
30 -- "$@" ${OPTS}
31 eend $?
32}
33
34stop() {
35 ebegin "Stopping fprobe-ulog"
36 start-stop-daemon --stop --quiet --exec $DAEMON \
37 --pidfile ${PIDFILE}
38 eend $?
39}