From c0a2f19500c75126812bfcaef3910db0cb6b08e6 Mon Sep 17 00:00:00 2001
From: Tom Eastep <teastep@shorewall.net>
Date: Wed, 21 Nov 2012 10:24:14 -0800
Subject: [PATCH] Add an Audit action.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
---
 Shorewall/action.Audit | 54 ++++++++++++++++++++++++++++++++++++++++++
 Shorewall/actions.std  |  1 +
 2 files changed, 55 insertions(+)
 create mode 100644 Shorewall/action.Audit

diff --git a/Shorewall/action.Audit b/Shorewall/action.Audit
new file mode 100644
index 000000000..9d7912103
--- /dev/null
+++ b/Shorewall/action.Audit
@@ -0,0 +1,54 @@
+#
+# Shorewall 4 - AUDIT Action
+#
+#    /usr/share/shorewall/action.AUDIT
+#
+#     This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
+#
+#     (c) 2011 - Tom Eastep (teastep@shorewall.net)
+#
+#       Complete documentation is available at http://shorewall.net
+#
+#       This program is free software; you can redistribute it and/or modify
+#       it under the terms of Version 2 of the GNU General Public License
+#       as published by the Free Software Foundation.
+#
+#       This program is distributed in the hope that it will be useful,
+#       but WITHOUT ANY WARRANTY; without even the implied warranty of
+#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#       GNU General Public License for more details.
+#
+#       You should have received a copy of the GNU General Public License
+#       along with this program; if not, write to the Free Software
+#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+#   AUDIT[(type)]
+#
+#       Default type is drop
+#
+##########################################################################################
+FORMAT 2
+
+DEFAULTS drop
+
+?BEGIN PERL;
+
+use Shorewall::IPAddrs;
+use Shorewall::Config;
+use Shorewall::Chains;
+
+my ( $type ) = get_action_params( 1 );
+
+fatal_error "Invalid AUDIT type ($type)" unless $type =~ /^(?:accept|drop|reject)$/;
+
+require_capability('AUDIT_TARGET', 'The AUDIT action', 's');
+
+my $chainref         = get_action_chain;
+
+add_ijump( $chainref, j=> 'AUDIT', targetopts => "--type $type" );
+
+allow_optimize( $chainref );
+
+1;
+
+?END PERL;
diff --git a/Shorewall/actions.std b/Shorewall/actions.std
index d0996931a..f9c826352 100644
--- a/Shorewall/actions.std
+++ b/Shorewall/actions.std
@@ -35,6 +35,7 @@
 #ACTION
 A_Drop 		    # Audited Default Action for DROP policy
 A_Reject	    # Audited Default action for REJECT policy
+Audit               # Audits a request
 Broadcast	    # Handles Broadcast/Multicast/Anycast
 Drop		    # Default Action for DROP policy
 DropSmurfs          # Drop smurf packets