[arch-commits] Commit in iptables/trunk (7 files)

Dan McGee dan at archlinux.org
Sat Jul 23 14:02:25 EDT 2011


    Date: Saturday, July 23, 2011 @ 14:02:25
  Author: dan
Revision: 132371

iptables verbump and rc.d script rewrite

* Use new state files in /var/lib/iptables to do the reset rather than the crazy looping business we had before
* Remove unnecessary "sleep 2" in rc.d scripts
* Clean up PKGBUILD, remove uname usage, quote directory names, add linux-api-headers makedepends

Added:
  iptables/trunk/empty-filter.rules
  iptables/trunk/empty-mangle.rules
  iptables/trunk/empty-nat.rules
  iptables/trunk/empty-raw.rules
Modified:
  iptables/trunk/PKGBUILD
  iptables/trunk/ip6tables
  iptables/trunk/iptables

--------------------+
 PKGBUILD           |   50 +++++++++++++++++++++++++++++++-------------------
 empty-filter.rules |    6 ++++++
 empty-mangle.rules |    8 ++++++++
 empty-nat.rules    |    7 +++++++
 empty-raw.rules    |    5 +++++
 ip6tables          |   29 ++---------------------------
 iptables           |   27 +--------------------------
 7 files changed, 60 insertions(+), 72 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2011-07-23 17:24:56 UTC (rev 132370)
+++ PKGBUILD	2011-07-23 18:02:25 UTC (rev 132371)
@@ -3,51 +3,63 @@
 # Contributor: Thomas Baechler <thomas at archlinux.org>
 
 pkgname=iptables
-pkgver=1.4.11.1
+pkgver=1.4.12
 pkgrel=1
 pkgdesc="A Linux kernel packet control tool"
 arch=('i686' 'x86_64')
 license=('GPL2')
-url="http://www.netfilter.org/"
+url="http://www.netfilter.org/projects/iptables/index.html"
 depends=('glibc' 'bash')
+makedepends=('linux-api-headers')
 options=('!libtool')
 source=(http://www.iptables.org/projects/iptables/files/${pkgname}-${pkgver}.tar.bz2
         iptables
         ip6tables
         empty.rules
         simple_firewall.rules
-        iptables.conf.d)
+        iptables.conf.d
+        empty-filter.rules
+        empty-mangle.rules
+        empty-nat.rules
+        empty-raw.rules)
 backup=(etc/conf.d/iptables)
-sha1sums=('2aa0d215485133f2817973b0914a132f628d9f3a'
-          'd7540316581bb66c5594885882a14ba394e95098'
-          '70d70113e3a23f0fe99404c5536507a887a4ca5c'
+sha1sums=('6c3f6eceadf5dab570d757d74a7194ef75be3ee3'
+          '5bb6fa526665cdd728c26f0f282f5a51f220cf88'
+          '2db68906b603e5268736f48c8e251f3a49da1d75'
           '83b3363878e3660ce23b2ad325b53cbd6c796ecf'
           '9907f9e815592837abc7fa3264a401567b7606ab'
-          '1c52444ffbecc09f56bb325db49e924dd32f9213')
+          'cdb830137192bbe002c6d01058656bd053ed0ddd'
+          'd9f9f06b46b4187648e860afa0552335aafe3ce4'
+          'c45b738b5ec4cfb11611b984c21a83b91a2d58f3'
+          '1694d79b3e6e9d9d543f6a6e75fed06066c9a6c6'
+          '7db53bb882f62f6c677cc8559cff83d8bae2ef73')
 
 build() {
-  cd ${srcdir}/${pkgname}-${pkgver}
+  cd "${srcdir}/${pkgname}-${pkgver}"
 
   # http://bugs.archlinux.org/task/17046
   sed -i '87 i libxt_RATEEST.so: libxt_RATEEST.oo' extensions/GNUmakefile.in
   sed -i '88 i \\t${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -lm -shared ${LDFLAGS} -o $@ $<;\n' extensions/GNUmakefile.in
 
- ./configure --prefix=/usr --with-kernel=usr/src/linux-$(uname -r) \
-	--libexecdir=/usr/lib/iptables --sysconfdir=/etc \
-	--with-xtlibdir=/usr/lib/iptables \
-	--enable-devel --enable-libipq
+ ./configure --prefix=/usr \
+     --libexecdir=/usr/lib/iptables --sysconfdir=/etc \
+     --with-xtlibdir=/usr/lib/iptables \
+     --enable-devel --enable-libipq
 
   make
 }
 
 package() {
-  cd ${srcdir}/${pkgname}-${pkgver}
+  cd "${srcdir}/${pkgname}-${pkgver}"
+  make DESTDIR="${pkgdir}" install
 
-  make DESTDIR=${pkgdir} install
+  cd "${srcdir}"
+  install -D -m755 iptables "${pkgdir}"/etc/rc.d/iptables
+  install -D -m755 ip6tables "${pkgdir}"/etc/rc.d/ip6tables
+  install -D -m644 empty.rules "${pkgdir}"/etc/iptables/empty.rules
+  install -D -m644 simple_firewall.rules "${pkgdir}"/etc/iptables/simple_firewall.rules
+  install -D -m644 iptables.conf.d "${pkgdir}"/etc/conf.d/iptables
 
-  install -D -m755 ../iptables ${pkgdir}/etc/rc.d/iptables
-  install -D -m755 ../ip6tables ${pkgdir}/etc/rc.d/ip6tables
-  install -D -m644 ../empty.rules ${pkgdir}/etc/iptables/empty.rules
-  install -D -m644 ../simple_firewall.rules ${pkgdir}/etc/iptables/simple_firewall.rules
-  install -D -m644 ../iptables.conf.d ${pkgdir}/etc/conf.d/iptables
+  mkdir -p "${pkgdir}/var/lib/iptables"
+  install -m644 empty-{filter,mangle,nat,raw}.rules ${pkgdir}/var/lib/iptables/
 }

Added: empty-filter.rules
===================================================================
--- empty-filter.rules	                        (rev 0)
+++ empty-filter.rules	2011-07-23 18:02:25 UTC (rev 132371)
@@ -0,0 +1,6 @@
+# Empty iptables filter table rule file
+*filter
+:INPUT ACCEPT [0:0]
+:FORWARD ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+COMMIT

Added: empty-mangle.rules
===================================================================
--- empty-mangle.rules	                        (rev 0)
+++ empty-mangle.rules	2011-07-23 18:02:25 UTC (rev 132371)
@@ -0,0 +1,8 @@
+# Empty iptables mangle table rules file
+*mangle
+:PREROUTING ACCEPT [0:0]
+:INPUT ACCEPT [0:0]
+:FORWARD ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+:POSTROUTING ACCEPT [0:0]
+COMMIT

Added: empty-nat.rules
===================================================================
--- empty-nat.rules	                        (rev 0)
+++ empty-nat.rules	2011-07-23 18:02:25 UTC (rev 132371)
@@ -0,0 +1,7 @@
+# Empty iptables nat table rules file
+*nat
+:PREROUTING ACCEPT [0:0]
+:INPUT ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+:POSTROUTING ACCEPT [0:0]
+COMMIT

Added: empty-raw.rules
===================================================================
--- empty-raw.rules	                        (rev 0)
+++ empty-raw.rules	2011-07-23 18:02:25 UTC (rev 132371)
@@ -0,0 +1,5 @@
+# Empty iptables raw table rules file
+*raw
+:PREROUTING ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+COMMIT

Modified: ip6tables
===================================================================
--- ip6tables	2011-07-23 17:24:56 UTC (rev 132370)
+++ ip6tables	2011-07-23 18:02:25 UTC (rev 132371)
@@ -12,7 +12,7 @@
 case "$1" in
 	start)
 		if [ ! -f "$IP6TABLES_CONF" ]; then
-			echo "Cannot load iptables rules: $IP6TABLES_CONF is missing!" >&2
+			echo "Cannot load ip6tables rules: $IP6TABLES_CONF is missing!" >&2
 			exit 1
 		fi
 		stat_busy "Starting IP6 Tables"
@@ -37,37 +37,13 @@
 		if ! ck_daemon ip6tables; then
 			fail=0
 			for table in $(cat /proc/net/ip6_tables_names); do
-				ip6tables -t $table -F &>/dev/null && \
-					ip6tables -t $table -X &>/dev/null && \
-					ip6tables -t $table -Z &>/dev/null
+				ip6tables-restore < /var/lib/iptables/empty-$table.rules
 				[ $? -gt 0 ] && fail=1
 			done
 			if [ $fail -gt 0 ]; then
 				stat_fail
 			else
 				rm_daemon ip6tables
-				# reset policies
-				for table in filter mangle raw; do
-					if grep -qw $table /proc/net/ip6_tables_names; then
-						ip6tables -t $table -P OUTPUT ACCEPT
-					fi
-				done
-				for table in filter mangle; do
-					if grep -qw $table /proc/net/ip6_tables_names; then
-						ip6tables -t $table -P INPUT ACCEPT
-						ip6tables -t $table -P FORWARD ACCEPT
-					fi
-				done
-				for table in mangle raw; do
-					if grep -qw $table /proc/net/ip6_tables_names; then
-						ip6tables -t $table -P PREROUTING ACCEPT
-					fi
-				done
-				for table in mangle; do
-					if grep -qw $table /proc/net/ip6_tables_names; then
-						ip6tables -t $table -P POSTROUTING ACCEPT
-					fi
-				done
 				stat_done
 			fi
 		else
@@ -76,7 +52,6 @@
 		;;
 	restart)
 		$0 stop
-		sleep 2
 		$0 start
 		;;
 	save)

Modified: iptables
===================================================================
--- iptables	2011-07-23 17:24:56 UTC (rev 132370)
+++ iptables	2011-07-23 18:02:25 UTC (rev 132371)
@@ -36,37 +36,13 @@
 		if ! ck_daemon iptables; then
 			fail=0
 			for table in $(cat /proc/net/ip_tables_names); do
-				iptables -t $table -F &>/dev/null && \
-					iptables -t $table -X &>/dev/null && \
-					iptables -t $table -Z &>/dev/null
+				iptables-restore < /var/lib/iptables/empty-$table.rules
 				[ $? -gt 0 ] && fail=1
 			done
 			if [ $fail -gt 0 ]; then
 				stat_fail
 			else
 				rm_daemon iptables
-				# reset policies
-				for table in filter nat mangle raw; do
-					if grep -qw $table /proc/net/ip_tables_names; then
-						iptables -t $table -P OUTPUT ACCEPT
-					fi
-				done
-				for table in filter mangle; do
-					if grep -qw $table /proc/net/ip_tables_names; then
-						iptables -t $table -P INPUT ACCEPT
-						iptables -t $table -P FORWARD ACCEPT
-					fi
-				done
-				for table in nat mangle raw; do
-					if grep -qw $table /proc/net/ip_tables_names; then
-						iptables -t $table -P PREROUTING ACCEPT
-					fi
-				done
-				for table in nat mangle; do
-					if grep -qw $table /proc/net/ip_tables_names; then
-						iptables -t $table -P POSTROUTING ACCEPT
-					fi
-				done
 				stat_done
 			fi
 		else
@@ -75,7 +51,6 @@
 		;;
 	restart)
 		$0 stop
-		sleep 2
 		$0 start
 		;;
 	save)



More information about the arch-commits mailing list