Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Mar 2004 18:22:35 +0000
From:      Max Laier <max@love2party.net>
To:        current@freebsd.org
Subject:   Comments: pflog rc.d-script
Message-ID:  <200403311822.43420.max@love2party.net>

next in thread | raw e-mail | index | archive | help

--Boundary-03=_zxwaAAyW4yYGmmt
Content-Type: multipart/mixed;
  boundary="Boundary-01=_rxwaAL8J+IaCbk6"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--Boundary-01=_rxwaAL8J+IaCbk6
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,

after Bruce merged the new tcpdump 3.8.3 (big THANK YOU to Bill and Bruce f=
or=20
doing this!!!)  - 'pflogd' and 'tcpdump -i pflog0' finally do something=20
usefull ... time to provide a rc.d-script to start pflogd.

Here it is, please try and give me feedback as I plan to commit this soon.=
=20
Thanks.

=2D-=20
Best regards,				| mlaier@freebsd.org
Max Laier				| ICQ #67774661
http://pf4freebsd.love2party.net/	| mlaier@EFnet

--Boundary-01=_rxwaAL8J+IaCbk6
Content-Type: text/x-diff;
  charset="us-ascii";
  name="rcNG_pflog.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="rcNG_pflog.diff"

Index: etc/newsyslog.conf
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/etc/newsyslog.conf,v
retrieving revision 1.47
diff -u -r1.47 newsyslog.conf
=2D-- etc/newsyslog.conf	7 Aug 2003 21:04:40 -0000	1.47
+++ etc/newsyslog.conf	31 Mar 2004 18:10:35 -0000
@@ -36,3 +36,5 @@
 /var/log/weekly.log			640  5	   1	$W6D0 JN
 /var/log/wtmp				644  3	   *	@01T05 B
 /var/log/xferlog			600  7	   100	*     J
+# pflogd sample entry
+#/var/log/pflog				600  3	   100	*     JB    /var/run/pflogd.pid
Index: etc/defaults/rc.conf
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/etc/defaults/rc.conf,v
retrieving revision 1.202
diff -u -r1.202 rc.conf
=2D-- etc/defaults/rc.conf	23 Mar 2004 23:22:34 -0000	1.202
+++ etc/defaults/rc.conf	31 Mar 2004 17:17:49 -0000
@@ -107,6 +107,10 @@
 pf_rules=3D"/etc/pf.conf"		# rules definition file for pf
 pf_program=3D"/sbin/pfctl"	# where the pfctl program lives
 pf_flags=3D""			# additional flags for pfctl
+pflog_enable=3D"NO"		# Set to YES to enable packet filter logging
+pflog_logfile=3D"/var/log/pflogd"	# where pflogd shoule store the logfile
+pflog_program=3D"/sbin/pflogd"	# where the pflogd program lives
+pflog_flags=3D""			# additional flags for pflogd
 tcp_extensions=3D"YES"		# Set to NO to turn off RFC1323 extensions.
 log_in_vain=3D"0"			# >=3D1 to log connects to ports w/o listeners.
 tcp_keepalive=3D"YES"		# Enable stale TCP connection timeout (or NO).
Index: etc/rc.d/Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/etc/rc.d/Makefile,v
retrieving revision 1.37
diff -u -r1.37 Makefile
=2D-- etc/rc.d/Makefile	24 Mar 2004 21:54:44 -0000	1.37
+++ etc/rc.d/Makefile	31 Mar 2004 18:01:18 -0000
@@ -25,7 +25,7 @@
 	network_ipv6 nfsclient nfsd \
 	nfslocking nfsserver nisdomain ntpd ntpdate \
 	othermta \
=2D	pccard pcvt pf power_profile ppp-user pppoed pwcheck \
+	pccard pcvt pf pflog power_profile ppp-user pppoed pwcheck \
 	quota \
 	random rarpd rcconf.sh resolv root \
 	route6d routed routing rpcbind rtadvd rwho \
Index: etc/rc.d/pf
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/etc/rc.d/pf,v
retrieving revision 1.1
diff -u -r1.1 pf
=2D-- etc/rc.d/pf	23 Mar 2004 22:30:15 -0000	1.1
+++ etc/rc.d/pf	31 Mar 2004 17:51:33 -0000
@@ -4,7 +4,7 @@
 #
=20
 # PROVIDE: pf
=2D# REQUIRE: root beforenetlkm mountcritlocal netif
+# REQUIRE: root beforenetlkm mountcritlocal netif pflog
 # BEFORE:  DAEMON LOGIN
 # KEYWORD: FreeBSD nojail
=20
Index: etc/rc.d/pflog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: etc/rc.d/pflog
diff -N etc/rc.d/pflog
=2D-- /dev/null	1 Jan 1970 00:00:00 -0000
+++ etc/rc.d/pflog	31 Mar 2004 17:59:36 -0000
@@ -0,0 +1,85 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: pflog
+# REQUIRE: root beforenetlkm mountcritlocal netif
+# BEFORE:  DAEMON LOGIN
+# KEYWORD: FreeBSD nojail
+
+. /etc/rc.subr
+
+name=3D"pflog"
+rcvar=3D`set_rcvar`
+load_rc_config $name
+stop_precmd=3D"test -x ${pflog_program}"
+start_precmd=3D"pflog_prestart"
+start_cmd=3D"pflog_start"
+stop_cmd=3D"pflog_stop"
+resync_precmd=3D"$stop_precmd"
+resync_cmd=3D"pflog_resync"
+status_precmd=3D"$stop_precmd"
+status_cmd=3D"pflog_status"
+extra_commands=3D"resync status"
+
+pflog_prestart()
+{
+	# load pflog kernel module if needed
+	if ! kldstat -v | grep -q pflog\$; then
+		if kldload pflog; then
+			info 'pflog module loaded.'
+		else
+			err 1 'pflog module failed to load.'
+		fi
+	fi
+
+	# set pflog0 interface to up state
+	if ! ifconfig pflog0 up; then
+		warn 'pflog: COULD NOT SET UP pflog0'
+	fi
+
+	# check for pf rules
+	if [ ! -x "${pflog_program:-/sbin/pflogd}" ]
+	then
+		warn 'pflog: NO PFLOGD BINARY FOUND'
+		return 1
+	fi
+}
+
+pflog_start()
+{
+	echo -n "Enabling pflogd"
+	if ! ${pflog_program:-/sbin/pflogd} ${pflog_flags} \
+	    -f ${pflog_logfile:-/var/log/pflog}; then
+		echo " failed!"
+	else
+		echo "."
+	fi
+}
+
+pflog_stop()
+{
+	if [ -r /var/run/pflogd.pid ]; then
+		echo "Stopping pflogd."
+		kill `cat /var/run/pflogd.pid`
+	fi
+}
+
+pflog_resync()
+{
+	if [ -r /var/run/pflogd.pid ]; then
+		kill -SIGHUP `cat /var/run/pflogd.pid`
+	fi
+}
+
+pflog_status()
+{
+	if [ -r /var/run/pflogd.pid ]; then
+		ps -p `cat /var/run/pflogd.pid` | tail -n 1
+	else
+		echo 'pflogd not running.'
+	fi
+}
+
+run_rc_command "$1"

--Boundary-01=_rxwaAL8J+IaCbk6--

--Boundary-03=_zxwaAAyW4yYGmmt
Content-Type: application/pgp-signature
Content-Description: signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQBAawxzXyyEoT62BG0RAqHWAJ9pV6o3Kxe8LwwBCpleGhMmLa0TLQCfXzb9
OMCTiQ+4pvAMlGDYdL+bljM=
=EAvZ
-----END PGP SIGNATURE-----

--Boundary-03=_zxwaAAyW4yYGmmt--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403311822.43420.max>