diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2008-11-24 10:20:34 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2008-11-24 10:20:34 +0000 |
commit | e6f9cc1c67526b162f1a29b8dd6901cf5455e701 (patch) | |
tree | c92183fd838524cb5fc7d9623a304f9ead925a8e /core/iptables | |
parent | f12ece71a6d90d7245515a967e7218183c7c28fb (diff) | |
download | aports-e6f9cc1c67526b162f1a29b8dd6901cf5455e701.tar.bz2 aports-e6f9cc1c67526b162f1a29b8dd6901cf5455e701.tar.xz |
core/iptables: new aport
Diffstat (limited to 'core/iptables')
-rw-r--r-- | core/iptables/APKBUILD | 68 | ||||
-rw-r--r-- | core/iptables/iptables-1.4.2-as-needed.patch | 54 | ||||
-rw-r--r-- | core/iptables/iptables-1.4.2-include-in.patch | 12 | ||||
-rw-r--r-- | core/iptables/iptables-1.4.2-no-ldconfig.patch | 15 | ||||
-rw-r--r-- | core/iptables/iptables.confd | 11 | ||||
-rwxr-xr-x | core/iptables/iptables.initd | 114 |
6 files changed, 274 insertions, 0 deletions
diff --git a/core/iptables/APKBUILD b/core/iptables/APKBUILD new file mode 100644 index 0000000000..485ca7a99c --- /dev/null +++ b/core/iptables/APKBUILD @@ -0,0 +1,68 @@ +#!/bin/sh +# Maintainer: Natanael Copa <ncopa@alpinelinux.org> + +pkgname=iptables +pkgver=1.4.2 +pkgrel=0 +pkgdesc="Linux kernel firewall, NAT and packet mangling tools" +url="http://www.iptables.org/" +license=GPL-2 +source="http://iptables.org/projects/iptables/files/$pkgname-$pkgver.tar.bz2 + iptables-1.4.2-as-needed.patch + iptables-1.4.2-no-ldconfig.patch + iptables-1.4.2-include-in.patch + iptables.initd + iptables.confd + " +makedepends="linux-headers" +subpackages="ip6tables $pkgname-doc $pkgname-dev" + +build() { + local i + cd "$srcdir/$pkgname-$pkgver" + for i in ../*.patch; do + patch -p1 -i $i || return 1 + done + + ./configure --prefix=/usr \ + --mandir=/usr/share/man \ + --sbindir=/sbin \ + --without-kernel \ + --enable-devel \ + --enable-libipq \ + --enable-shared + make || return 1 + make install DESTDIR="$pkgdir" + + mkdir -p "$pkgdir"/usr/include/libiptc \ + "$pkgdir"/usr/lib \ + "$pkgdir"/var/lib/iptables \ + "$pkgdir"/etc/init.d \ + "$pkgdir"/etc/conf.d + install -m644 include/iptables.h include/ip6tables.h \ + "$pkgdir"/usr/include/ + install include/libiptc/*.h "$pkgdir"/usr/include/libiptc/ + install -m644 libiptc/libiptc.a "$pkgdir"/usr/lib + install -m755 "$startdir"/iptables.initd "$pkgdir"/etc/init.d/iptables + install -m644 "$startdir"/iptables.confd "$pkgdir"/etc/conf.d/iptables +} + +ip6tables() { + mkdir -p "$subpkgdir"/sbin \ + "$subpkgdir"/etc/init.d/ \ + "$subpkgdir"/var/lib/ip6tables \ + "$subpkgdir"/usr/libexec/xtables + + mv "$pkgdir"/sbin/ip6* "$subpkgdir"/sbin/ + mv "$pkgdir"/usr/libexec/xtables/libip6* \ + "$subpkgdir"/usr/libexec/xtables/ + install -m755 "$startdir"/iptables.initd \ + "$subpkgdir"/etc/init.d/ip6tables +} + +md5sums="a138d1c2e74321e0e4e228a9fb301c9a iptables-1.4.2.tar.bz2 +9279ad4cfa650c828bc3fff5368ad526 iptables-1.4.2-as-needed.patch +7b9c52caf34663186c32ea44b80c9a03 iptables-1.4.2-no-ldconfig.patch +ec3e80a1b0ea3e13e4e60824b7ebd1b9 iptables-1.4.2-include-in.patch +2202ac150a5dfe32a8363b0ad565ee1d iptables.initd +956ebf5ab69e5a1e1d3983541eab643b iptables.confd" diff --git a/core/iptables/iptables-1.4.2-as-needed.patch b/core/iptables/iptables-1.4.2-as-needed.patch new file mode 100644 index 0000000000..3782393f10 --- /dev/null +++ b/core/iptables/iptables-1.4.2-as-needed.patch @@ -0,0 +1,54 @@ +http://bugs.gentoo.org/244431 + +patch by Arfrever Frehtes Taifersar Arahesis + +--- a/Makefile.in ++++ b/Makefile.in +@@ -87,7 +87,7 @@ + "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)" + libLTLIBRARIES_INSTALL = $(INSTALL) + LTLIBRARIES = $(lib_LTLIBRARIES) +-libxtables_la_LIBADD = ++libxtables_la_DEPENDENCIES = + am_libxtables_la_OBJECTS = xtables.lo + libxtables_la_OBJECTS = $(am_libxtables_la_OBJECTS) + binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +@@ -353,11 +353,12 @@ + lib_LTLIBRARIES = libxtables.la + libxtables_la_SOURCES = xtables.c + libxtables_la_LDFLAGS = -version 0:0:0 ++libxtables_la_LIBADD = -ldl + + # iptables, dynamic + iptables_SOURCES = iptables-standalone.c iptables.c + iptables_LDFLAGS = -rdynamic +-iptables_LDADD = -ldl -lm libiptc/libiptc.a extensions/libext4.a libxtables.la ++iptables_LDADD = libiptc/libiptc.a extensions/libext4.a libxtables.la -ldl -lm + iptables_multi_SOURCES = iptables-multi.c iptables-save.c \ + iptables-restore.c iptables-xml.c \ + iptables-standalone.c iptables.c +@@ -375,13 +376,13 @@ + # iptables-multi, semi-static + iptables_static_SOURCES = ${iptables_multi_SOURCES} xtables.c + iptables_static_CFLAGS = ${iptables_multi_CFLAGS} -DNO_SHARED_LIBS=1 +-iptables_static_LDADD = -lm libiptc/libiptc.a extensions/libext4.a ++iptables_static_LDADD = libiptc/libiptc.a extensions/libext4.a -lm + iptables_xml_SOURCES = iptables-xml.c + + # ip6tables, dynamic + ip6tables_SOURCES = ip6tables-standalone.c ip6tables.c + ip6tables_LDFLAGS = -rdynamic +-ip6tables_LDADD = -ldl -lm libiptc/libiptc.a extensions/libext6.a libxtables.la ++ip6tables_LDADD = libiptc/libiptc.a extensions/libext6.a libxtables.la -ldl -lm + ip6tables_multi_SOURCES = ip6tables-multi.c ip6tables-save.c \ + ip6tables-restore.c ip6tables-standalone.c \ + ip6tables.c +@@ -399,7 +400,7 @@ + # iptables-multi, semi-static + ip6tables_static_SOURCES = ${ip6tables_multi_SOURCES} xtables.c + ip6tables_static_CFLAGS = ${ip6tables_multi_CFLAGS} -DNO_SHARED_LIBS=1 +-ip6tables_static_LDADD = -lm libiptc/libiptc.a extensions/libext6.a ++ip6tables_static_LDADD = libiptc/libiptc.a extensions/libext6.a -lm + noinst_LIBRARIES := libiptc/libiptc.a + man_MANS := iptables.8 iptables-restore.8 iptables-save.8 \ + iptables-xml.8 ip6tables.8 ip6tables-restore.8 \ diff --git a/core/iptables/iptables-1.4.2-include-in.patch b/core/iptables/iptables-1.4.2-include-in.patch new file mode 100644 index 0000000000..138fa564ca --- /dev/null +++ b/core/iptables/iptables-1.4.2-include-in.patch @@ -0,0 +1,12 @@ +pull in in.h as it sets up some proto defines that iptables relies on + +--- a/include/xtables.h.in ++++ b/include/xtables.h.in +@@ -5,6 +5,7 @@ + #include <sys/types.h> + #include <stdbool.h> + #include <net/if.h> ++#include <netinet/in.h> + #include <linux/types.h> + #include <linux/netfilter/x_tables.h> + diff --git a/core/iptables/iptables-1.4.2-no-ldconfig.patch b/core/iptables/iptables-1.4.2-no-ldconfig.patch new file mode 100644 index 0000000000..943ff4aef7 --- /dev/null +++ b/core/iptables/iptables-1.4.2-no-ldconfig.patch @@ -0,0 +1,15 @@ +avoid pointless overhead for DESTDIR builds + +http://bugzilla.netfilter.org/show_bug.cgi?id=560 + +--- a/Makefile.in ++++ b/Makefile.in +@@ -1530,7 +1530,7 @@ + # ldconfig may fail when we are not root (as is the case in build systems) + # so add appropriate protection that it does not let `make` fail. + install-exec-hook: +- -/sbin/ldconfig || :; ++ -[ -z "$(DESTDIR)" ] && /sbin/ldconfig + # Tell versions [3.59,3.63) of GNU make to not export all variables. + # Otherwise a system limit (for SysV at least) may be exceeded. + .NOEXPORT: diff --git a/core/iptables/iptables.confd b/core/iptables/iptables.confd new file mode 100644 index 0000000000..91287debdb --- /dev/null +++ b/core/iptables/iptables.confd @@ -0,0 +1,11 @@ +# /etc/conf.d/iptables + +# Location in which iptables initscript will save set rules on +# service shutdown +IPTABLES_SAVE="/var/lib/iptables/rules-save" + +# Options to pass to iptables-save and iptables-restore +SAVE_RESTORE_OPTIONS="-c" + +# Save state on stopping iptables +SAVE_ON_STOP="yes" diff --git a/core/iptables/iptables.initd b/core/iptables/iptables.initd new file mode 100755 index 0000000000..e63d8ea9e2 --- /dev/null +++ b/core/iptables/iptables.initd @@ -0,0 +1,114 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-firewall/iptables/files/iptables-1.3.2.init,v 1.6 2007/03/12 21:49:04 vapier Exp $ + +opts="save reload panic" + +iptables_name=${SVCNAME} +if [ "${iptables_name}" != "iptables" -a "${iptables_name}" != "ip6tables" ] ; then + iptables_name="iptables" +fi + +iptables_bin="/sbin/${iptables_name}" +case ${iptables_name} in + iptables) iptables_proc="/proc/net/ip_tables_names" + iptables_save=${IPTABLES_SAVE};; + ip6tables) iptables_proc="/proc/net/ip6_tables_names" + iptables_save=${IP6TABLES_SAVE};; +esac + +depend() { + before net + use logger +} + +set_table_policy() { + local chains table=$1 policy=$2 + case ${table} in + nat) chains="PREROUTING POSTROUTING OUTPUT";; + mangle) chains="PREROUTING INPUT FORWARD OUTPUT POSTROUTING";; + filter) chains="INPUT FORWARD OUTPUT";; + *) chains="";; + esac + local chain + for chain in ${chains} ; do + ${iptables_bin} -t ${table} -P ${chain} ${policy} + done +} + +checkkernel() { + if [ ! -e ${iptables_proc} ] ; then + eerror "Your kernel lacks ${iptables_name} support, please load" + eerror "appropriate modules and try again." + return 1 + fi + return 0 +} +checkconfig() { + if [ ! -f ${iptables_save} ] ; then + eerror "Not starting ${iptables_name}. First create some rules then run:" + eerror "/etc/init.d/${iptables_name} save" + return 1 + fi + return 0 +} + +start() { + checkconfig || return 1 + ebegin "Loading ${iptables_name} state and starting firewall" + ${iptables_bin}-restore ${SAVE_RESTORE_OPTIONS} < "${iptables_save}" + eend $? +} + +stop() { + if [ "${SAVE_ON_STOP}" = "yes" ] ; then + save || return 1 + fi + checkkernel || return 1 + ebegin "Stopping firewall" + local a + for a in $(cat ${iptables_proc}) ; do + set_table_policy $a ACCEPT + + ${iptables_bin} -F -t $a + ${iptables_bin} -X -t $a + done + eend $? +} + +reload() { + checkkernel || return 1 + ebegin "Flushing firewall" + local a + for a in $(cat ${iptables_proc}) ; do + ${iptables_bin} -F -t $a + ${iptables_bin} -X -t $a + done + eend $? + + start +} + +save() { + ebegin "Saving ${iptables_name} state" + touch "${iptables_save}" + chmod 0600 "${iptables_save}" + ${iptables_bin}-save ${SAVE_RESTORE_OPTIONS} > "${iptables_save}" + eend $? +} + +panic() { + checkkernel || return 1 + service_started ${iptables_name} && svc_stop + + local a + ebegin "Dropping all packets" + for a in $(cat ${iptables_proc}) ; do + ${iptables_bin} -F -t $a + ${iptables_bin} -X -t $a + + set_table_policy $a DROP + done + eend $? +} |