• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3RET=0
4tmpfile=""
5set -x
6
7
8clean_tmpfile()
9{
10        if [ ! -z "$tmpfile" ];then
11                rm -f "$tmpfile"
12        fi
13}
14
15trap clean_tmpfile EXIT
16
17do_diff()
18{
19	A="$1"
20	B="$2"
21
22	AT=$(mktemp)
23	grep -v "^#" "$A" > "$AT"
24
25	diff -u "$AT" "$B"
26
27	x=$?
28	rm -f "$AT"
29	echo "Return $x for $XT_MULTI $A"
30
31	return $x
32}
33
34tmpfile=$(mktemp) || exit 1
35do_simple()
36{
37	iptables="$1"
38	dumpfile="$2"
39
40	$XT_MULTI ${iptables}-restore < "$dumpfile"
41	$XT_MULTI ${iptables}-save | grep -v "^#" > "$tmpfile"
42	sed -i -e 's/-p 47 /-p gre /' "$tmpfile"
43	do_diff $dumpfile "$tmpfile"
44	if [ $? -ne 0 ]; then
45		# cp "$tmpfile" "$dumpfile.got"
46		RET=1
47	fi
48}
49
50do_simple "iptables" $(dirname "$0")/dumps/ipt-save-filter.txt
51do_simple "iptables" $(dirname "$0")/dumps/policy-drop.txt
52do_simple "iptables" $(dirname "$0")/dumps/wireless.txt
53
54exit $RET
55