summaryrefslogtreecommitdiff
path: root/net-analyzer/fprobe/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /net-analyzer/fprobe/files
reinit the tree, so we can have metadata
Diffstat (limited to 'net-analyzer/fprobe/files')
-rw-r--r--net-analyzer/fprobe/files/conf.d-fprobe71
-rw-r--r--net-analyzer/fprobe/files/fprobe-1.1-pidfile-sanity.patch47
-rw-r--r--net-analyzer/fprobe/files/fprobe-1.1-setgroups.patch18
-rw-r--r--net-analyzer/fprobe/files/init.d-fprobe41
4 files changed, 177 insertions, 0 deletions
diff --git a/net-analyzer/fprobe/files/conf.d-fprobe b/net-analyzer/fprobe/files/conf.d-fprobe
new file mode 100644
index 000000000000..a93c5c10b207
--- /dev/null
+++ b/net-analyzer/fprobe/files/conf.d-fprobe
@@ -0,0 +1,71 @@
+# Config file for /etc/init.d/fprobe
+
+# Do we want the interface in promiscous mode [yes/no]
+#PROMISC=no
+
+# Interface
+IFACE=eth0
+
+# If configured, only capture packets matching this tcpdump expression
+#FILTER=""
+
+# Flow state timers
+#TIMER_EXPIRED=5
+#TIMER_FRAGMENTED=30
+#TIMER_IDLE=60
+#TIMER_ACTIVE=300
+
+# This is the default and should be left unless you know what you are doing
+#FLOW_VER=5
+
+# local ip. if configured fprobe will use this as the source IP for sending ALL flow data
+# If you want to specify a specific source address per collecter, customize it below
+#LOCALIP=
+
+# SNMP iface id
+SNMP_IFACE="${IFACE#eth}"
+
+# Maximum number of concurrent flows to track
+# using a specified amount of memory
+#MEMBULK=10000
+#MEMLIMIT=
+
+# Pending queue
+#PENDING=100
+
+# Kernel capture buffer size (kB)
+#KERNBUF=1024
+
+# Realtime priority [0=disabled, 1..99]
+#RTPRIO=0
+
+# Delay N nanoseconds after each B bytes
+#DELAY="0:0"
+
+# How much of the start of each packet to grab
+#SNAPLEN=256
+
+# chroot() to this location after startup
+CHROOT="/var/empty"
+
+# User to run as. must have perms to the pidfile directory /var/run/fprobe/
+USER=nobody
+
+# logging level for syslog (0=EMERG, ..., 6=INFO, 7=DEBUG)
+#LOGLEVEL=6
+
+# If you want to run multiple instances of fprobe,
+# You MUST set this variable to a unique INTEGER for each one!
+PIDFILE_ID=''
+
+# remote ip. this is where we send flows
+REMOTEIP=127.0.0.1
+# port to listen on
+PORT=2055
+# Collector type, see the manpage for valid types
+TYPE=''
+
+# If you want multiple collectors, just specify each one here
+COLLECTORS="${REMOTEIP}:${PORT}/${LOCALIP}/${TYPE}"
+
+# vim:ft=gentoo-conf-d:
diff --git a/net-analyzer/fprobe/files/fprobe-1.1-pidfile-sanity.patch b/net-analyzer/fprobe/files/fprobe-1.1-pidfile-sanity.patch
new file mode 100644
index 000000000000..c58c2a97c002
--- /dev/null
+++ b/net-analyzer/fprobe/files/fprobe-1.1-pidfile-sanity.patch
@@ -0,0 +1,47 @@
+If we are using the chroot() option or the setuid options, we must create the
+pidfile before doing the chroot OR the setreuid. It's actually best for
+start-stop-daemon if we create the pidfile from the master side of the fork()
+before it exits, since most of the startup checks happen after the chroot()
+unfortunetly.
+
+Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
+
+--- a/src/fprobe.c
++++ b/src/fprobe.c
+@@ -1379,7 +1379,8 @@
+
+ my_log_open(ident, verbosity, log_dest);
+ if (!(log_dest & 2)) {
+- switch (fork()) {
++ pid_t childpid = fork();
++ switch (childpid) {
+ case -1:
+ fprintf(stderr, "fork(): %s", strerror(errno));
+ exit(1);
+@@ -1392,6 +1393,12 @@
+ break;
+
+ default:
++ if (!(pidfile = fopen(pidfilepath, "w")))
++ my_log(LOG_ERR, "Can't create pid file. fopen(): %s", strerror(errno));
++ else {
++ fprintf(pidfile, "%ld\n", (long) childpid);
++ fclose(pidfile);
++ }
+ exit(0);
+ }
+ } else {
+@@ -1548,13 +1555,6 @@
+ }
+ }
+
+- if (!(pidfile = fopen(pidfilepath, "w")))
+- my_log(LOG_ERR, "Can't create pid file. fopen(): %s", strerror(errno));
+- else {
+- fprintf(pidfile, "%ld\n", (long) pid);
+- fclose(pidfile);
+- }
+-
+ my_log(LOG_INFO, "pid: %d", pid);
+ my_log(LOG_INFO, "interface: %s, datalink: %s (%d)",
+ dev, dlt[link_type_idx].descr, link_type);
diff --git a/net-analyzer/fprobe/files/fprobe-1.1-setgroups.patch b/net-analyzer/fprobe/files/fprobe-1.1-setgroups.patch
new file mode 100644
index 000000000000..803a2a9ce43a
--- /dev/null
+++ b/net-analyzer/fprobe/files/fprobe-1.1-setgroups.patch
@@ -0,0 +1,18 @@
+This seems to fail after the chroot(), so just squelch the exit for now.
+
+Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
+
+--- a/src/fprobe.c
++++ b/src/fprobe.c
+@@ -1541,10 +1541,10 @@
+ }
+
+ if (pw) {
+ if (setgroups(0, NULL) < 0) {
+ my_log(LOG_CRIT, "setgroups: %s", strerror(errno));
+- exit(1);
++ //exit(1);
+ }
+ if (setregid(pw->pw_gid, pw->pw_gid)) {
+ my_log(LOG_CRIT, "setregid(%u): %s", pw->pw_gid, strerror(errno));
+ exit(1);
diff --git a/net-analyzer/fprobe/files/init.d-fprobe b/net-analyzer/fprobe/files/init.d-fprobe
new file mode 100644
index 000000000000..c470af432c9c
--- /dev/null
+++ b/net-analyzer/fprobe/files/init.d-fprobe
@@ -0,0 +1,41 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+BIN=/usr/sbin/fprobe
+PIDFILE_EXTRA=""
+[ -n "$PIDFILE_ID" ] && PIDFILE_EXTRA="[$PIDFILE_ID]"
+PIDFILE="/var/run/fprobe$PIDFILE_EXTRA.pid"
+
+start() {
+ ebegin "Starting fprobe"
+ local OPTS=""
+ [ "${PROMISC}" = "yes" ] || OPTS="${OPTS} -p"
+ [ -n "${FILTER}" ] && OPTS="${OPTS} -f '${FILTER}'"
+ for optname in i:IFACE s:TIMER_EXPIRED g:TIME_FRAGMENTED d:TIMER_IDLE \
+ e:TIMER_ACTIVE n:FLOW_VER a:LOCALIP x:SNMP_IFACE b:MEMBULK \
+ m:MEMLIMIT q:PENDING B:KERNBUF r:RTPRIO t:DELAY S:SNAPLEN \
+ c:CHROOT u:USER v:LOGLEVEL ; do
+ opt="${optname%:*}" optvar="${optname#*:}"
+ eval optvalue='$'$optvar
+ [ -n "$optvalue" ] && OPTS="${OPTS} -${opt} ${optvalue}"
+ done
+ OPTS="${OPTS} -l 1:${PIDFILE_ID} ${COLLECTORS}"
+ start-stop-daemon --start --exec $BIN \
+ --pidfile ${PIDFILE} \
+ -- ${OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping fprobe"
+ start-stop-daemon --stop --quiet --exec $BIN \
+ --pidfile ${PIDFILE}
+ eend $?
+}
+
+# vim:ft=gentoo-init-d: